babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376
  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_EXPLICIT: boolean;
  27173. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27174. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27175. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27176. INVERTCUBICMAP: boolean;
  27177. LOGARITHMICDEPTH: boolean;
  27178. REFRACTION: boolean;
  27179. REFRACTIONMAP_3D: boolean;
  27180. REFLECTIONOVERALPHA: boolean;
  27181. TWOSIDEDLIGHTING: boolean;
  27182. SHADOWFLOAT: boolean;
  27183. MORPHTARGETS: boolean;
  27184. MORPHTARGETS_NORMAL: boolean;
  27185. MORPHTARGETS_TANGENT: boolean;
  27186. MORPHTARGETS_UV: boolean;
  27187. NUM_MORPH_INFLUENCERS: number;
  27188. NONUNIFORMSCALING: boolean;
  27189. PREMULTIPLYALPHA: boolean;
  27190. IMAGEPROCESSING: boolean;
  27191. VIGNETTE: boolean;
  27192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27193. VIGNETTEBLENDMODEOPAQUE: boolean;
  27194. TONEMAPPING: boolean;
  27195. TONEMAPPING_ACES: boolean;
  27196. CONTRAST: boolean;
  27197. COLORCURVES: boolean;
  27198. COLORGRADING: boolean;
  27199. COLORGRADING3D: boolean;
  27200. SAMPLER3DGREENDEPTH: boolean;
  27201. SAMPLER3DBGRMAP: boolean;
  27202. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27203. MULTIVIEW: boolean;
  27204. /**
  27205. * If the reflection texture on this material is in linear color space
  27206. * @hidden
  27207. */
  27208. IS_REFLECTION_LINEAR: boolean;
  27209. /**
  27210. * If the refraction texture on this material is in linear color space
  27211. * @hidden
  27212. */
  27213. IS_REFRACTION_LINEAR: boolean;
  27214. EXPOSURE: boolean;
  27215. constructor();
  27216. setReflectionMode(modeToEnable: string): void;
  27217. }
  27218. /**
  27219. * This is the default material used in Babylon. It is the best trade off between quality
  27220. * and performances.
  27221. * @see http://doc.babylonjs.com/babylon101/materials
  27222. */
  27223. export class StandardMaterial extends PushMaterial {
  27224. private _diffuseTexture;
  27225. /**
  27226. * The basic texture of the material as viewed under a light.
  27227. */
  27228. diffuseTexture: Nullable<BaseTexture>;
  27229. private _ambientTexture;
  27230. /**
  27231. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27232. */
  27233. ambientTexture: Nullable<BaseTexture>;
  27234. private _opacityTexture;
  27235. /**
  27236. * Define the transparency of the material from a texture.
  27237. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27238. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27239. */
  27240. opacityTexture: Nullable<BaseTexture>;
  27241. private _reflectionTexture;
  27242. /**
  27243. * Define the texture used to display the reflection.
  27244. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27245. */
  27246. reflectionTexture: Nullable<BaseTexture>;
  27247. private _emissiveTexture;
  27248. /**
  27249. * Define texture of the material as if self lit.
  27250. * This will be mixed in the final result even in the absence of light.
  27251. */
  27252. emissiveTexture: Nullable<BaseTexture>;
  27253. private _specularTexture;
  27254. /**
  27255. * Define how the color and intensity of the highlight given by the light in the material.
  27256. */
  27257. specularTexture: Nullable<BaseTexture>;
  27258. private _bumpTexture;
  27259. /**
  27260. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27261. * 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.
  27262. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27263. */
  27264. bumpTexture: Nullable<BaseTexture>;
  27265. private _lightmapTexture;
  27266. /**
  27267. * Complex lighting can be computationally expensive to compute at runtime.
  27268. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27269. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27270. */
  27271. lightmapTexture: Nullable<BaseTexture>;
  27272. private _refractionTexture;
  27273. /**
  27274. * Define the texture used to display the refraction.
  27275. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27276. */
  27277. refractionTexture: Nullable<BaseTexture>;
  27278. /**
  27279. * The color of the material lit by the environmental background lighting.
  27280. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27281. */
  27282. ambientColor: Color3;
  27283. /**
  27284. * The basic color of the material as viewed under a light.
  27285. */
  27286. diffuseColor: Color3;
  27287. /**
  27288. * Define how the color and intensity of the highlight given by the light in the material.
  27289. */
  27290. specularColor: Color3;
  27291. /**
  27292. * Define the color of the material as if self lit.
  27293. * This will be mixed in the final result even in the absence of light.
  27294. */
  27295. emissiveColor: Color3;
  27296. /**
  27297. * Defines how sharp are the highlights in the material.
  27298. * The bigger the value the sharper giving a more glossy feeling to the result.
  27299. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27300. */
  27301. specularPower: number;
  27302. private _useAlphaFromDiffuseTexture;
  27303. /**
  27304. * Does the transparency come from the diffuse texture alpha channel.
  27305. */
  27306. useAlphaFromDiffuseTexture: boolean;
  27307. private _useEmissiveAsIllumination;
  27308. /**
  27309. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27310. */
  27311. useEmissiveAsIllumination: boolean;
  27312. private _linkEmissiveWithDiffuse;
  27313. /**
  27314. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27315. * the emissive level when the final color is close to one.
  27316. */
  27317. linkEmissiveWithDiffuse: boolean;
  27318. private _useSpecularOverAlpha;
  27319. /**
  27320. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27321. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27322. */
  27323. useSpecularOverAlpha: boolean;
  27324. private _useReflectionOverAlpha;
  27325. /**
  27326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27328. */
  27329. useReflectionOverAlpha: boolean;
  27330. private _disableLighting;
  27331. /**
  27332. * Does lights from the scene impacts this material.
  27333. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27334. */
  27335. disableLighting: boolean;
  27336. private _useObjectSpaceNormalMap;
  27337. /**
  27338. * Allows using an object space normal map (instead of tangent space).
  27339. */
  27340. useObjectSpaceNormalMap: boolean;
  27341. private _useParallax;
  27342. /**
  27343. * Is parallax enabled or not.
  27344. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27345. */
  27346. useParallax: boolean;
  27347. private _useParallaxOcclusion;
  27348. /**
  27349. * Is parallax occlusion enabled or not.
  27350. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27351. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27352. */
  27353. useParallaxOcclusion: boolean;
  27354. /**
  27355. * 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.
  27356. */
  27357. parallaxScaleBias: number;
  27358. private _roughness;
  27359. /**
  27360. * Helps to define how blurry the reflections should appears in the material.
  27361. */
  27362. roughness: number;
  27363. /**
  27364. * In case of refraction, define the value of the index of refraction.
  27365. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27366. */
  27367. indexOfRefraction: number;
  27368. /**
  27369. * Invert the refraction texture alongside the y axis.
  27370. * It can be useful with procedural textures or probe for instance.
  27371. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27372. */
  27373. invertRefractionY: boolean;
  27374. /**
  27375. * Defines the alpha limits in alpha test mode.
  27376. */
  27377. alphaCutOff: number;
  27378. private _useLightmapAsShadowmap;
  27379. /**
  27380. * In case of light mapping, define whether the map contains light or shadow informations.
  27381. */
  27382. useLightmapAsShadowmap: boolean;
  27383. private _diffuseFresnelParameters;
  27384. /**
  27385. * Define the diffuse fresnel parameters of the material.
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27387. */
  27388. diffuseFresnelParameters: FresnelParameters;
  27389. private _opacityFresnelParameters;
  27390. /**
  27391. * Define the opacity fresnel parameters of the material.
  27392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27393. */
  27394. opacityFresnelParameters: FresnelParameters;
  27395. private _reflectionFresnelParameters;
  27396. /**
  27397. * Define the reflection fresnel parameters of the material.
  27398. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27399. */
  27400. reflectionFresnelParameters: FresnelParameters;
  27401. private _refractionFresnelParameters;
  27402. /**
  27403. * Define the refraction fresnel parameters of the material.
  27404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27405. */
  27406. refractionFresnelParameters: FresnelParameters;
  27407. private _emissiveFresnelParameters;
  27408. /**
  27409. * Define the emissive fresnel parameters of the material.
  27410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27411. */
  27412. emissiveFresnelParameters: FresnelParameters;
  27413. private _useReflectionFresnelFromSpecular;
  27414. /**
  27415. * If true automatically deducts the fresnels values from the material specularity.
  27416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27417. */
  27418. useReflectionFresnelFromSpecular: boolean;
  27419. private _useGlossinessFromSpecularMapAlpha;
  27420. /**
  27421. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27422. */
  27423. useGlossinessFromSpecularMapAlpha: boolean;
  27424. private _maxSimultaneousLights;
  27425. /**
  27426. * Defines the maximum number of lights that can be used in the material
  27427. */
  27428. maxSimultaneousLights: number;
  27429. private _invertNormalMapX;
  27430. /**
  27431. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27432. */
  27433. invertNormalMapX: boolean;
  27434. private _invertNormalMapY;
  27435. /**
  27436. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27437. */
  27438. invertNormalMapY: boolean;
  27439. private _twoSidedLighting;
  27440. /**
  27441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27442. */
  27443. twoSidedLighting: boolean;
  27444. /**
  27445. * Default configuration related to image processing available in the standard Material.
  27446. */
  27447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27448. /**
  27449. * Gets the image processing configuration used either in this material.
  27450. */
  27451. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27452. /**
  27453. * Sets the Default image processing configuration used either in the this material.
  27454. *
  27455. * If sets to null, the scene one is in use.
  27456. */
  27457. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27458. /**
  27459. * Keep track of the image processing observer to allow dispose and replace.
  27460. */
  27461. private _imageProcessingObserver;
  27462. /**
  27463. * Attaches a new image processing configuration to the Standard Material.
  27464. * @param configuration
  27465. */
  27466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27467. /**
  27468. * Gets wether the color curves effect is enabled.
  27469. */
  27470. get cameraColorCurvesEnabled(): boolean;
  27471. /**
  27472. * Sets wether the color curves effect is enabled.
  27473. */
  27474. set cameraColorCurvesEnabled(value: boolean);
  27475. /**
  27476. * Gets wether the color grading effect is enabled.
  27477. */
  27478. get cameraColorGradingEnabled(): boolean;
  27479. /**
  27480. * Gets wether the color grading effect is enabled.
  27481. */
  27482. set cameraColorGradingEnabled(value: boolean);
  27483. /**
  27484. * Gets wether tonemapping is enabled or not.
  27485. */
  27486. get cameraToneMappingEnabled(): boolean;
  27487. /**
  27488. * Sets wether tonemapping is enabled or not
  27489. */
  27490. set cameraToneMappingEnabled(value: boolean);
  27491. /**
  27492. * The camera exposure used on this material.
  27493. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27494. * This corresponds to a photographic exposure.
  27495. */
  27496. get cameraExposure(): number;
  27497. /**
  27498. * The camera exposure used on this material.
  27499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27500. * This corresponds to a photographic exposure.
  27501. */
  27502. set cameraExposure(value: number);
  27503. /**
  27504. * Gets The camera contrast used on this material.
  27505. */
  27506. get cameraContrast(): number;
  27507. /**
  27508. * Sets The camera contrast used on this material.
  27509. */
  27510. set cameraContrast(value: number);
  27511. /**
  27512. * Gets the Color Grading 2D Lookup Texture.
  27513. */
  27514. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27515. /**
  27516. * Sets the Color Grading 2D Lookup Texture.
  27517. */
  27518. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27519. /**
  27520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27522. * 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;
  27523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27524. */
  27525. get cameraColorCurves(): Nullable<ColorCurves>;
  27526. /**
  27527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27529. * 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;
  27530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27531. */
  27532. set cameraColorCurves(value: Nullable<ColorCurves>);
  27533. /**
  27534. * Custom callback helping to override the default shader used in the material.
  27535. */
  27536. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27537. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27538. protected _worldViewProjectionMatrix: Matrix;
  27539. protected _globalAmbientColor: Color3;
  27540. protected _useLogarithmicDepth: boolean;
  27541. protected _rebuildInParallel: boolean;
  27542. /**
  27543. * Instantiates a new standard material.
  27544. * This is the default material used in Babylon. It is the best trade off between quality
  27545. * and performances.
  27546. * @see http://doc.babylonjs.com/babylon101/materials
  27547. * @param name Define the name of the material in the scene
  27548. * @param scene Define the scene the material belong to
  27549. */
  27550. constructor(name: string, scene: Scene);
  27551. /**
  27552. * Gets a boolean indicating that current material needs to register RTT
  27553. */
  27554. get hasRenderTargetTextures(): boolean;
  27555. /**
  27556. * Gets the current class name of the material e.g. "StandardMaterial"
  27557. * Mainly use in serialization.
  27558. * @returns the class name
  27559. */
  27560. getClassName(): string;
  27561. /**
  27562. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27563. * You can try switching to logarithmic depth.
  27564. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27565. */
  27566. get useLogarithmicDepth(): boolean;
  27567. set useLogarithmicDepth(value: boolean);
  27568. /**
  27569. * Specifies if the material will require alpha blending
  27570. * @returns a boolean specifying if alpha blending is needed
  27571. */
  27572. needAlphaBlending(): boolean;
  27573. /**
  27574. * Specifies if this material should be rendered in alpha test mode
  27575. * @returns a boolean specifying if an alpha test is needed.
  27576. */
  27577. needAlphaTesting(): boolean;
  27578. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27579. /**
  27580. * Get the texture used for alpha test purpose.
  27581. * @returns the diffuse texture in case of the standard material.
  27582. */
  27583. getAlphaTestTexture(): Nullable<BaseTexture>;
  27584. /**
  27585. * Get if the submesh is ready to be used and all its information available.
  27586. * Child classes can use it to update shaders
  27587. * @param mesh defines the mesh to check
  27588. * @param subMesh defines which submesh to check
  27589. * @param useInstances specifies that instances should be used
  27590. * @returns a boolean indicating that the submesh is ready or not
  27591. */
  27592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27593. /**
  27594. * Builds the material UBO layouts.
  27595. * Used internally during the effect preparation.
  27596. */
  27597. buildUniformLayout(): void;
  27598. /**
  27599. * Unbinds the material from the mesh
  27600. */
  27601. unbind(): void;
  27602. /**
  27603. * Binds the submesh to this material by preparing the effect and shader to draw
  27604. * @param world defines the world transformation matrix
  27605. * @param mesh defines the mesh containing the submesh
  27606. * @param subMesh defines the submesh to bind the material to
  27607. */
  27608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27609. /**
  27610. * Get the list of animatables in the material.
  27611. * @returns the list of animatables object used in the material
  27612. */
  27613. getAnimatables(): IAnimatable[];
  27614. /**
  27615. * Gets the active textures from the material
  27616. * @returns an array of textures
  27617. */
  27618. getActiveTextures(): BaseTexture[];
  27619. /**
  27620. * Specifies if the material uses a texture
  27621. * @param texture defines the texture to check against the material
  27622. * @returns a boolean specifying if the material uses the texture
  27623. */
  27624. hasTexture(texture: BaseTexture): boolean;
  27625. /**
  27626. * Disposes the material
  27627. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27628. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27629. */
  27630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27631. /**
  27632. * Makes a duplicate of the material, and gives it a new name
  27633. * @param name defines the new name for the duplicated material
  27634. * @returns the cloned material
  27635. */
  27636. clone(name: string): StandardMaterial;
  27637. /**
  27638. * Serializes this material in a JSON representation
  27639. * @returns the serialized material object
  27640. */
  27641. serialize(): any;
  27642. /**
  27643. * Creates a standard material from parsed material data
  27644. * @param source defines the JSON representation of the material
  27645. * @param scene defines the hosting scene
  27646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27647. * @returns a new standard material
  27648. */
  27649. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27650. /**
  27651. * Are diffuse textures enabled in the application.
  27652. */
  27653. static get DiffuseTextureEnabled(): boolean;
  27654. static set DiffuseTextureEnabled(value: boolean);
  27655. /**
  27656. * Are ambient textures enabled in the application.
  27657. */
  27658. static get AmbientTextureEnabled(): boolean;
  27659. static set AmbientTextureEnabled(value: boolean);
  27660. /**
  27661. * Are opacity textures enabled in the application.
  27662. */
  27663. static get OpacityTextureEnabled(): boolean;
  27664. static set OpacityTextureEnabled(value: boolean);
  27665. /**
  27666. * Are reflection textures enabled in the application.
  27667. */
  27668. static get ReflectionTextureEnabled(): boolean;
  27669. static set ReflectionTextureEnabled(value: boolean);
  27670. /**
  27671. * Are emissive textures enabled in the application.
  27672. */
  27673. static get EmissiveTextureEnabled(): boolean;
  27674. static set EmissiveTextureEnabled(value: boolean);
  27675. /**
  27676. * Are specular textures enabled in the application.
  27677. */
  27678. static get SpecularTextureEnabled(): boolean;
  27679. static set SpecularTextureEnabled(value: boolean);
  27680. /**
  27681. * Are bump textures enabled in the application.
  27682. */
  27683. static get BumpTextureEnabled(): boolean;
  27684. static set BumpTextureEnabled(value: boolean);
  27685. /**
  27686. * Are lightmap textures enabled in the application.
  27687. */
  27688. static get LightmapTextureEnabled(): boolean;
  27689. static set LightmapTextureEnabled(value: boolean);
  27690. /**
  27691. * Are refraction textures enabled in the application.
  27692. */
  27693. static get RefractionTextureEnabled(): boolean;
  27694. static set RefractionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are color grading textures enabled in the application.
  27697. */
  27698. static get ColorGradingTextureEnabled(): boolean;
  27699. static set ColorGradingTextureEnabled(value: boolean);
  27700. /**
  27701. * Are fresnels enabled in the application.
  27702. */
  27703. static get FresnelEnabled(): boolean;
  27704. static set FresnelEnabled(value: boolean);
  27705. }
  27706. }
  27707. declare module "babylonjs/Particles/solidParticleSystem" {
  27708. import { Nullable } from "babylonjs/types";
  27709. import { Vector3 } from "babylonjs/Maths/math.vector";
  27710. import { Mesh } from "babylonjs/Meshes/mesh";
  27711. import { Scene, IDisposable } from "babylonjs/scene";
  27712. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27713. import { Material } from "babylonjs/Materials/material";
  27714. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27715. /**
  27716. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27717. *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.
  27718. * The SPS is also a particle system. It provides some methods to manage the particles.
  27719. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27720. *
  27721. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27722. */
  27723. export class SolidParticleSystem implements IDisposable {
  27724. /**
  27725. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27726. * Example : var p = SPS.particles[i];
  27727. */
  27728. particles: SolidParticle[];
  27729. /**
  27730. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27731. */
  27732. nbParticles: number;
  27733. /**
  27734. * If the particles must ever face the camera (default false). Useful for planar particles.
  27735. */
  27736. billboard: boolean;
  27737. /**
  27738. * Recompute normals when adding a shape
  27739. */
  27740. recomputeNormals: boolean;
  27741. /**
  27742. * This a counter ofr your own usage. It's not set by any SPS functions.
  27743. */
  27744. counter: number;
  27745. /**
  27746. * The SPS name. This name is also given to the underlying mesh.
  27747. */
  27748. name: string;
  27749. /**
  27750. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27751. */
  27752. mesh: Mesh;
  27753. /**
  27754. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27755. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27756. */
  27757. vars: any;
  27758. /**
  27759. * This array is populated when the SPS is set as 'pickable'.
  27760. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27761. * Each element of this array is an object `{idx: int, faceId: int}`.
  27762. * `idx` is the picked particle index in the `SPS.particles` array
  27763. * `faceId` is the picked face index counted within this particle.
  27764. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27765. */
  27766. pickedParticles: {
  27767. idx: number;
  27768. faceId: number;
  27769. }[];
  27770. /**
  27771. * This array is populated when `enableDepthSort` is set to true.
  27772. * Each element of this array is an instance of the class DepthSortedParticle.
  27773. */
  27774. depthSortedParticles: DepthSortedParticle[];
  27775. /**
  27776. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27777. * @hidden
  27778. */
  27779. _bSphereOnly: boolean;
  27780. /**
  27781. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27782. * @hidden
  27783. */
  27784. _bSphereRadiusFactor: number;
  27785. private _scene;
  27786. private _positions;
  27787. private _indices;
  27788. private _normals;
  27789. private _colors;
  27790. private _uvs;
  27791. private _indices32;
  27792. private _positions32;
  27793. private _normals32;
  27794. private _fixedNormal32;
  27795. private _colors32;
  27796. private _uvs32;
  27797. private _index;
  27798. private _updatable;
  27799. private _pickable;
  27800. private _isVisibilityBoxLocked;
  27801. private _alwaysVisible;
  27802. private _depthSort;
  27803. private _expandable;
  27804. private _shapeCounter;
  27805. private _copy;
  27806. private _color;
  27807. private _computeParticleColor;
  27808. private _computeParticleTexture;
  27809. private _computeParticleRotation;
  27810. private _computeParticleVertex;
  27811. private _computeBoundingBox;
  27812. private _depthSortParticles;
  27813. private _camera;
  27814. private _mustUnrotateFixedNormals;
  27815. private _particlesIntersect;
  27816. private _needs32Bits;
  27817. private _isNotBuilt;
  27818. private _lastParticleId;
  27819. private _idxOfId;
  27820. private _multimaterialEnabled;
  27821. private _useModelMaterial;
  27822. private _indicesByMaterial;
  27823. private _materialIndexes;
  27824. private _depthSortFunction;
  27825. private _materialSortFunction;
  27826. private _materials;
  27827. private _multimaterial;
  27828. private _materialIndexesById;
  27829. private _defaultMaterial;
  27830. private _autoUpdateSubMeshes;
  27831. /**
  27832. * Creates a SPS (Solid Particle System) object.
  27833. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27834. * @param scene (Scene) is the scene in which the SPS is added.
  27835. * @param options defines the options of the sps e.g.
  27836. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27837. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27838. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27839. * * 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.
  27840. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27841. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27842. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27843. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27844. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27845. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27846. */
  27847. constructor(name: string, scene: Scene, options?: {
  27848. updatable?: boolean;
  27849. isPickable?: boolean;
  27850. enableDepthSort?: boolean;
  27851. particleIntersection?: boolean;
  27852. boundingSphereOnly?: boolean;
  27853. bSphereRadiusFactor?: number;
  27854. expandable?: boolean;
  27855. useModelMaterial?: boolean;
  27856. enableMultiMaterial?: boolean;
  27857. });
  27858. /**
  27859. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27860. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27861. * @returns the created mesh
  27862. */
  27863. buildMesh(): Mesh;
  27864. /**
  27865. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27866. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27867. * Thus the particles generated from `digest()` have their property `position` set yet.
  27868. * @param mesh ( Mesh ) is the mesh to be digested
  27869. * @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
  27870. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27871. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27872. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27873. * @returns the current SPS
  27874. */
  27875. digest(mesh: Mesh, options?: {
  27876. facetNb?: number;
  27877. number?: number;
  27878. delta?: number;
  27879. storage?: [];
  27880. }): SolidParticleSystem;
  27881. /**
  27882. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27883. * @hidden
  27884. */
  27885. private _unrotateFixedNormals;
  27886. /**
  27887. * Resets the temporary working copy particle
  27888. * @hidden
  27889. */
  27890. private _resetCopy;
  27891. /**
  27892. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27893. * @param p the current index in the positions array to be updated
  27894. * @param ind the current index in the indices array
  27895. * @param shape a Vector3 array, the shape geometry
  27896. * @param positions the positions array to be updated
  27897. * @param meshInd the shape indices array
  27898. * @param indices the indices array to be updated
  27899. * @param meshUV the shape uv array
  27900. * @param uvs the uv array to be updated
  27901. * @param meshCol the shape color array
  27902. * @param colors the color array to be updated
  27903. * @param meshNor the shape normals array
  27904. * @param normals the normals array to be updated
  27905. * @param idx the particle index
  27906. * @param idxInShape the particle index in its shape
  27907. * @param options the addShape() method passed options
  27908. * @model the particle model
  27909. * @hidden
  27910. */
  27911. private _meshBuilder;
  27912. /**
  27913. * Returns a shape Vector3 array from positions float array
  27914. * @param positions float array
  27915. * @returns a vector3 array
  27916. * @hidden
  27917. */
  27918. private _posToShape;
  27919. /**
  27920. * Returns a shapeUV array from a float uvs (array deep copy)
  27921. * @param uvs as a float array
  27922. * @returns a shapeUV array
  27923. * @hidden
  27924. */
  27925. private _uvsToShapeUV;
  27926. /**
  27927. * Adds a new particle object in the particles array
  27928. * @param idx particle index in particles array
  27929. * @param id particle id
  27930. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27931. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27932. * @param model particle ModelShape object
  27933. * @param shapeId model shape identifier
  27934. * @param idxInShape index of the particle in the current model
  27935. * @param bInfo model bounding info object
  27936. * @param storage target storage array, if any
  27937. * @hidden
  27938. */
  27939. private _addParticle;
  27940. /**
  27941. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27942. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27943. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27944. * @param nb (positive integer) the number of particles to be created from this model
  27945. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27946. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27947. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27948. * @returns the number of shapes in the system
  27949. */
  27950. addShape(mesh: Mesh, nb: number, options?: {
  27951. positionFunction?: any;
  27952. vertexFunction?: any;
  27953. storage?: [];
  27954. }): number;
  27955. /**
  27956. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27957. * @hidden
  27958. */
  27959. private _rebuildParticle;
  27960. /**
  27961. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27962. * @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.
  27963. * @returns the SPS.
  27964. */
  27965. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27966. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27967. * Returns an array with the removed particles.
  27968. * 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.
  27969. * The SPS can't be empty so at least one particle needs to remain in place.
  27970. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27971. * @param start index of the first particle to remove
  27972. * @param end index of the last particle to remove (included)
  27973. * @returns an array populated with the removed particles
  27974. */
  27975. removeParticles(start: number, end: number): SolidParticle[];
  27976. /**
  27977. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27978. * @param solidParticleArray an array populated with Solid Particles objects
  27979. * @returns the SPS
  27980. */
  27981. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27982. /**
  27983. * Creates a new particle and modifies the SPS mesh geometry :
  27984. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27985. * - calls _addParticle() to populate the particle array
  27986. * factorized code from addShape() and insertParticlesFromArray()
  27987. * @param idx particle index in the particles array
  27988. * @param i particle index in its shape
  27989. * @param modelShape particle ModelShape object
  27990. * @param shape shape vertex array
  27991. * @param meshInd shape indices array
  27992. * @param meshUV shape uv array
  27993. * @param meshCol shape color array
  27994. * @param meshNor shape normals array
  27995. * @param bbInfo shape bounding info
  27996. * @param storage target particle storage
  27997. * @options addShape() passed options
  27998. * @hidden
  27999. */
  28000. private _insertNewParticle;
  28001. /**
  28002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28003. * This method calls `updateParticle()` for each particle of the SPS.
  28004. * For an animated SPS, it is usually called within the render loop.
  28005. * 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.
  28006. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28007. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28008. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28009. * @returns the SPS.
  28010. */
  28011. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28012. /**
  28013. * Disposes the SPS.
  28014. */
  28015. dispose(): void;
  28016. /**
  28017. * Returns a SolidParticle object from its identifier : particle.id
  28018. * @param id (integer) the particle Id
  28019. * @returns the searched particle or null if not found in the SPS.
  28020. */
  28021. getParticleById(id: number): Nullable<SolidParticle>;
  28022. /**
  28023. * Returns a new array populated with the particles having the passed shapeId.
  28024. * @param shapeId (integer) the shape identifier
  28025. * @returns a new solid particle array
  28026. */
  28027. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28028. /**
  28029. * Populates the passed array "ref" with the particles having the passed shapeId.
  28030. * @param shapeId the shape identifier
  28031. * @returns the SPS
  28032. * @param ref
  28033. */
  28034. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28035. /**
  28036. * Computes the required SubMeshes according the materials assigned to the particles.
  28037. * @returns the solid particle system.
  28038. * Does nothing if called before the SPS mesh is built.
  28039. */
  28040. computeSubMeshes(): SolidParticleSystem;
  28041. /**
  28042. * Sorts the solid particles by material when MultiMaterial is enabled.
  28043. * Updates the indices32 array.
  28044. * Updates the indicesByMaterial array.
  28045. * Updates the mesh indices array.
  28046. * @returns the SPS
  28047. * @hidden
  28048. */
  28049. private _sortParticlesByMaterial;
  28050. /**
  28051. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28052. * @hidden
  28053. */
  28054. private _setMaterialIndexesById;
  28055. /**
  28056. * Returns an array with unique values of Materials from the passed array
  28057. * @param array the material array to be checked and filtered
  28058. * @hidden
  28059. */
  28060. private _filterUniqueMaterialId;
  28061. /**
  28062. * Sets a new Standard Material as _defaultMaterial if not already set.
  28063. * @hidden
  28064. */
  28065. private _setDefaultMaterial;
  28066. /**
  28067. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28069. * @returns the SPS.
  28070. */
  28071. refreshVisibleSize(): SolidParticleSystem;
  28072. /**
  28073. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28074. * @param size the size (float) of the visibility box
  28075. * note : this doesn't lock the SPS mesh bounding box.
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28077. */
  28078. setVisibilityBox(size: number): void;
  28079. /**
  28080. * Gets whether the SPS as always visible or not
  28081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28082. */
  28083. get isAlwaysVisible(): boolean;
  28084. /**
  28085. * Sets the SPS as always visible or not
  28086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28087. */
  28088. set isAlwaysVisible(val: boolean);
  28089. /**
  28090. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28091. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28092. */
  28093. set isVisibilityBoxLocked(val: boolean);
  28094. /**
  28095. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28096. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28097. */
  28098. get isVisibilityBoxLocked(): boolean;
  28099. /**
  28100. * Tells to `setParticles()` to compute the particle rotations or not.
  28101. * Default value : true. The SPS is faster when it's set to false.
  28102. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28103. */
  28104. set computeParticleRotation(val: boolean);
  28105. /**
  28106. * Tells to `setParticles()` to compute the particle colors or not.
  28107. * Default value : true. The SPS is faster when it's set to false.
  28108. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28109. */
  28110. set computeParticleColor(val: boolean);
  28111. set computeParticleTexture(val: boolean);
  28112. /**
  28113. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28114. * Default value : false. The SPS is faster when it's set to false.
  28115. * Note : the particle custom vertex positions aren't stored values.
  28116. */
  28117. set computeParticleVertex(val: boolean);
  28118. /**
  28119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28120. */
  28121. set computeBoundingBox(val: boolean);
  28122. /**
  28123. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28124. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28125. * Default : `true`
  28126. */
  28127. set depthSortParticles(val: boolean);
  28128. /**
  28129. * Gets if `setParticles()` computes the particle rotations or not.
  28130. * Default value : true. The SPS is faster when it's set to false.
  28131. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28132. */
  28133. get computeParticleRotation(): boolean;
  28134. /**
  28135. * Gets if `setParticles()` computes the particle colors or not.
  28136. * Default value : true. The SPS is faster when it's set to false.
  28137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28138. */
  28139. get computeParticleColor(): boolean;
  28140. /**
  28141. * Gets if `setParticles()` computes the particle textures or not.
  28142. * Default value : true. The SPS is faster when it's set to false.
  28143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28144. */
  28145. get computeParticleTexture(): boolean;
  28146. /**
  28147. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28148. * Default value : false. The SPS is faster when it's set to false.
  28149. * Note : the particle custom vertex positions aren't stored values.
  28150. */
  28151. get computeParticleVertex(): boolean;
  28152. /**
  28153. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28154. */
  28155. get computeBoundingBox(): boolean;
  28156. /**
  28157. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28158. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28159. * Default : `true`
  28160. */
  28161. get depthSortParticles(): boolean;
  28162. /**
  28163. * Gets if the SPS is created as expandable at construction time.
  28164. * Default : `false`
  28165. */
  28166. get expandable(): boolean;
  28167. /**
  28168. * Gets if the SPS supports the Multi Materials
  28169. */
  28170. get multimaterialEnabled(): boolean;
  28171. /**
  28172. * Gets if the SPS uses the model materials for its own multimaterial.
  28173. */
  28174. get useModelMaterial(): boolean;
  28175. /**
  28176. * The SPS used material array.
  28177. */
  28178. get materials(): Material[];
  28179. /**
  28180. * Sets the SPS MultiMaterial from the passed materials.
  28181. * Note : the passed array is internally copied and not used then by reference.
  28182. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28183. */
  28184. setMultiMaterial(materials: Material[]): void;
  28185. /**
  28186. * The SPS computed multimaterial object
  28187. */
  28188. get multimaterial(): MultiMaterial;
  28189. set multimaterial(mm: MultiMaterial);
  28190. /**
  28191. * If the subMeshes must be updated on the next call to setParticles()
  28192. */
  28193. get autoUpdateSubMeshes(): boolean;
  28194. set autoUpdateSubMeshes(val: boolean);
  28195. /**
  28196. * This function does nothing. It may be overwritten to set all the particle first values.
  28197. * The SPS doesn't call this function, you may have to call it by your own.
  28198. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28199. */
  28200. initParticles(): void;
  28201. /**
  28202. * This function does nothing. It may be overwritten to recycle a particle.
  28203. * The SPS doesn't call this function, you may have to call it by your own.
  28204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28205. * @param particle The particle to recycle
  28206. * @returns the recycled particle
  28207. */
  28208. recycleParticle(particle: SolidParticle): SolidParticle;
  28209. /**
  28210. * Updates a particle : this function should be overwritten by the user.
  28211. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28213. * @example : just set a particle position or velocity and recycle conditions
  28214. * @param particle The particle to update
  28215. * @returns the updated particle
  28216. */
  28217. updateParticle(particle: SolidParticle): SolidParticle;
  28218. /**
  28219. * Updates a vertex of a particle : it can be overwritten by the user.
  28220. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28221. * @param particle the current particle
  28222. * @param vertex the current index of the current particle
  28223. * @param pt the index of the current vertex in the particle shape
  28224. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28225. * @example : just set a vertex particle position
  28226. * @returns the updated vertex
  28227. */
  28228. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28229. /**
  28230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28231. * This does nothing and may be overwritten by the user.
  28232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28234. * @param update the boolean update value actually passed to setParticles()
  28235. */
  28236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28237. /**
  28238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28239. * This will be passed three parameters.
  28240. * This does nothing and may be overwritten by the user.
  28241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28243. * @param update the boolean update value actually passed to setParticles()
  28244. */
  28245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28246. }
  28247. }
  28248. declare module "babylonjs/Particles/solidParticle" {
  28249. import { Nullable } from "babylonjs/types";
  28250. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28251. import { Color4 } from "babylonjs/Maths/math.color";
  28252. import { Mesh } from "babylonjs/Meshes/mesh";
  28253. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28254. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28255. import { Plane } from "babylonjs/Maths/math.plane";
  28256. import { Material } from "babylonjs/Materials/material";
  28257. /**
  28258. * Represents one particle of a solid particle system.
  28259. */
  28260. export class SolidParticle {
  28261. /**
  28262. * particle global index
  28263. */
  28264. idx: number;
  28265. /**
  28266. * particle identifier
  28267. */
  28268. id: number;
  28269. /**
  28270. * The color of the particle
  28271. */
  28272. color: Nullable<Color4>;
  28273. /**
  28274. * The world space position of the particle.
  28275. */
  28276. position: Vector3;
  28277. /**
  28278. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28279. */
  28280. rotation: Vector3;
  28281. /**
  28282. * The world space rotation quaternion of the particle.
  28283. */
  28284. rotationQuaternion: Nullable<Quaternion>;
  28285. /**
  28286. * The scaling of the particle.
  28287. */
  28288. scaling: Vector3;
  28289. /**
  28290. * The uvs of the particle.
  28291. */
  28292. uvs: Vector4;
  28293. /**
  28294. * The current speed of the particle.
  28295. */
  28296. velocity: Vector3;
  28297. /**
  28298. * The pivot point in the particle local space.
  28299. */
  28300. pivot: Vector3;
  28301. /**
  28302. * Must the particle be translated from its pivot point in its local space ?
  28303. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28304. * Default : false
  28305. */
  28306. translateFromPivot: boolean;
  28307. /**
  28308. * Is the particle active or not ?
  28309. */
  28310. alive: boolean;
  28311. /**
  28312. * Is the particle visible or not ?
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Index of this particle in the global "positions" array (Internal use)
  28317. * @hidden
  28318. */
  28319. _pos: number;
  28320. /**
  28321. * @hidden Index of this particle in the global "indices" array (Internal use)
  28322. */
  28323. _ind: number;
  28324. /**
  28325. * @hidden ModelShape of this particle (Internal use)
  28326. */
  28327. _model: ModelShape;
  28328. /**
  28329. * ModelShape id of this particle
  28330. */
  28331. shapeId: number;
  28332. /**
  28333. * Index of the particle in its shape id
  28334. */
  28335. idxInShape: number;
  28336. /**
  28337. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28338. */
  28339. _modelBoundingInfo: BoundingInfo;
  28340. /**
  28341. * @hidden Particle BoundingInfo object (Internal use)
  28342. */
  28343. _boundingInfo: BoundingInfo;
  28344. /**
  28345. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28346. */
  28347. _sps: SolidParticleSystem;
  28348. /**
  28349. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28350. */
  28351. _stillInvisible: boolean;
  28352. /**
  28353. * @hidden Last computed particle rotation matrix
  28354. */
  28355. _rotationMatrix: number[];
  28356. /**
  28357. * Parent particle Id, if any.
  28358. * Default null.
  28359. */
  28360. parentId: Nullable<number>;
  28361. /**
  28362. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28363. */
  28364. materialIndex: Nullable<number>;
  28365. /**
  28366. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28367. * The possible values are :
  28368. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28369. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28370. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28372. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28373. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28374. * */
  28375. cullingStrategy: number;
  28376. /**
  28377. * @hidden Internal global position in the SPS.
  28378. */
  28379. _globalPosition: Vector3;
  28380. /**
  28381. * Creates a Solid Particle object.
  28382. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28383. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28384. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28385. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28386. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28387. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28388. * @param shapeId (integer) is the model shape identifier in the SPS.
  28389. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28390. * @param sps defines the sps it is associated to
  28391. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28392. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28393. */
  28394. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28395. /**
  28396. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28397. * @param target the particle target
  28398. * @returns the current particle
  28399. */
  28400. copyToRef(target: SolidParticle): SolidParticle;
  28401. /**
  28402. * Legacy support, changed scale to scaling
  28403. */
  28404. get scale(): Vector3;
  28405. /**
  28406. * Legacy support, changed scale to scaling
  28407. */
  28408. set scale(scale: Vector3);
  28409. /**
  28410. * Legacy support, changed quaternion to rotationQuaternion
  28411. */
  28412. get quaternion(): Nullable<Quaternion>;
  28413. /**
  28414. * Legacy support, changed quaternion to rotationQuaternion
  28415. */
  28416. set quaternion(q: Nullable<Quaternion>);
  28417. /**
  28418. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28419. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28420. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28421. * @returns true if it intersects
  28422. */
  28423. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28424. /**
  28425. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28426. * A particle is in the frustum if its bounding box intersects the frustum
  28427. * @param frustumPlanes defines the frustum to test
  28428. * @returns true if the particle is in the frustum planes
  28429. */
  28430. isInFrustum(frustumPlanes: Plane[]): boolean;
  28431. /**
  28432. * get the rotation matrix of the particle
  28433. * @hidden
  28434. */
  28435. getRotationMatrix(m: Matrix): void;
  28436. }
  28437. /**
  28438. * Represents the shape of the model used by one particle of a solid particle system.
  28439. * SPS internal tool, don't use it manually.
  28440. */
  28441. export class ModelShape {
  28442. /**
  28443. * The shape id
  28444. * @hidden
  28445. */
  28446. shapeID: number;
  28447. /**
  28448. * flat array of model positions (internal use)
  28449. * @hidden
  28450. */
  28451. _shape: Vector3[];
  28452. /**
  28453. * flat array of model UVs (internal use)
  28454. * @hidden
  28455. */
  28456. _shapeUV: number[];
  28457. /**
  28458. * color array of the model
  28459. * @hidden
  28460. */
  28461. _shapeColors: number[];
  28462. /**
  28463. * indices array of the model
  28464. * @hidden
  28465. */
  28466. _indices: number[];
  28467. /**
  28468. * normals array of the model
  28469. * @hidden
  28470. */
  28471. _normals: number[];
  28472. /**
  28473. * length of the shape in the model indices array (internal use)
  28474. * @hidden
  28475. */
  28476. _indicesLength: number;
  28477. /**
  28478. * Custom position function (internal use)
  28479. * @hidden
  28480. */
  28481. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28482. /**
  28483. * Custom vertex function (internal use)
  28484. * @hidden
  28485. */
  28486. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28487. /**
  28488. * Model material (internal use)
  28489. * @hidden
  28490. */
  28491. _material: Nullable<Material>;
  28492. /**
  28493. * 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.
  28494. * SPS internal tool, don't use it manually.
  28495. * @hidden
  28496. */
  28497. 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>);
  28498. }
  28499. /**
  28500. * Represents a Depth Sorted Particle in the solid particle system.
  28501. * @hidden
  28502. */
  28503. export class DepthSortedParticle {
  28504. /**
  28505. * Index of the particle in the "indices" array
  28506. */
  28507. ind: number;
  28508. /**
  28509. * Length of the particle shape in the "indices" array
  28510. */
  28511. indicesLength: number;
  28512. /**
  28513. * Squared distance from the particle to the camera
  28514. */
  28515. sqDistance: number;
  28516. /**
  28517. * Material index when used with MultiMaterials
  28518. */
  28519. materialIndex: number;
  28520. /**
  28521. * Creates a new sorted particle
  28522. * @param materialIndex
  28523. */
  28524. constructor(ind: number, indLength: number, materialIndex: number);
  28525. }
  28526. }
  28527. declare module "babylonjs/Collisions/meshCollisionData" {
  28528. import { Collider } from "babylonjs/Collisions/collider";
  28529. import { Vector3 } from "babylonjs/Maths/math.vector";
  28530. import { Nullable } from "babylonjs/types";
  28531. import { Observer } from "babylonjs/Misc/observable";
  28532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28533. /**
  28534. * @hidden
  28535. */
  28536. export class _MeshCollisionData {
  28537. _checkCollisions: boolean;
  28538. _collisionMask: number;
  28539. _collisionGroup: number;
  28540. _collider: Nullable<Collider>;
  28541. _oldPositionForCollisions: Vector3;
  28542. _diffPositionForCollisions: Vector3;
  28543. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28544. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28545. }
  28546. }
  28547. declare module "babylonjs/Meshes/abstractMesh" {
  28548. import { Observable } from "babylonjs/Misc/observable";
  28549. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28550. import { Camera } from "babylonjs/Cameras/camera";
  28551. import { Scene, IDisposable } from "babylonjs/scene";
  28552. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28553. import { Node } from "babylonjs/node";
  28554. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28556. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28557. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28558. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28559. import { Material } from "babylonjs/Materials/material";
  28560. import { Light } from "babylonjs/Lights/light";
  28561. import { Skeleton } from "babylonjs/Bones/skeleton";
  28562. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28563. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28564. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28565. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28566. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28567. import { Plane } from "babylonjs/Maths/math.plane";
  28568. import { Ray } from "babylonjs/Culling/ray";
  28569. import { Collider } from "babylonjs/Collisions/collider";
  28570. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28571. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28572. /** @hidden */
  28573. class _FacetDataStorage {
  28574. facetPositions: Vector3[];
  28575. facetNormals: Vector3[];
  28576. facetPartitioning: number[][];
  28577. facetNb: number;
  28578. partitioningSubdivisions: number;
  28579. partitioningBBoxRatio: number;
  28580. facetDataEnabled: boolean;
  28581. facetParameters: any;
  28582. bbSize: Vector3;
  28583. subDiv: {
  28584. max: number;
  28585. X: number;
  28586. Y: number;
  28587. Z: number;
  28588. };
  28589. facetDepthSort: boolean;
  28590. facetDepthSortEnabled: boolean;
  28591. depthSortedIndices: IndicesArray;
  28592. depthSortedFacets: {
  28593. ind: number;
  28594. sqDistance: number;
  28595. }[];
  28596. facetDepthSortFunction: (f1: {
  28597. ind: number;
  28598. sqDistance: number;
  28599. }, f2: {
  28600. ind: number;
  28601. sqDistance: number;
  28602. }) => number;
  28603. facetDepthSortFrom: Vector3;
  28604. facetDepthSortOrigin: Vector3;
  28605. invertedMatrix: Matrix;
  28606. }
  28607. /**
  28608. * @hidden
  28609. **/
  28610. class _InternalAbstractMeshDataInfo {
  28611. _hasVertexAlpha: boolean;
  28612. _useVertexColors: boolean;
  28613. _numBoneInfluencers: number;
  28614. _applyFog: boolean;
  28615. _receiveShadows: boolean;
  28616. _facetData: _FacetDataStorage;
  28617. _visibility: number;
  28618. _skeleton: Nullable<Skeleton>;
  28619. _layerMask: number;
  28620. _computeBonesUsingShaders: boolean;
  28621. _isActive: boolean;
  28622. _onlyForInstances: boolean;
  28623. _isActiveIntermediate: boolean;
  28624. _onlyForInstancesIntermediate: boolean;
  28625. _actAsRegularMesh: boolean;
  28626. }
  28627. /**
  28628. * Class used to store all common mesh properties
  28629. */
  28630. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28631. /** No occlusion */
  28632. static OCCLUSION_TYPE_NONE: number;
  28633. /** Occlusion set to optimisitic */
  28634. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28635. /** Occlusion set to strict */
  28636. static OCCLUSION_TYPE_STRICT: number;
  28637. /** Use an accurante occlusion algorithm */
  28638. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28639. /** Use a conservative occlusion algorithm */
  28640. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28641. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28642. * Test order :
  28643. * Is the bounding sphere outside the frustum ?
  28644. * If not, are the bounding box vertices outside the frustum ?
  28645. * It not, then the cullable object is in the frustum.
  28646. */
  28647. static readonly CULLINGSTRATEGY_STANDARD: number;
  28648. /** Culling strategy : Bounding Sphere Only.
  28649. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28650. * It's also less accurate than the standard because some not visible objects can still be selected.
  28651. * Test : is the bounding sphere outside the frustum ?
  28652. * If not, then the cullable object is in the frustum.
  28653. */
  28654. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28655. /** Culling strategy : Optimistic Inclusion.
  28656. * This in an inclusion test first, then the standard exclusion test.
  28657. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28658. * 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.
  28659. * Anyway, it's as accurate as the standard strategy.
  28660. * Test :
  28661. * Is the cullable object bounding sphere center in the frustum ?
  28662. * If not, apply the default culling strategy.
  28663. */
  28664. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28665. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28666. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28667. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28668. * 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.
  28669. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28670. * Test :
  28671. * Is the cullable object bounding sphere center in the frustum ?
  28672. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28673. */
  28674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28675. /**
  28676. * No billboard
  28677. */
  28678. static get BILLBOARDMODE_NONE(): number;
  28679. /** Billboard on X axis */
  28680. static get BILLBOARDMODE_X(): number;
  28681. /** Billboard on Y axis */
  28682. static get BILLBOARDMODE_Y(): number;
  28683. /** Billboard on Z axis */
  28684. static get BILLBOARDMODE_Z(): number;
  28685. /** Billboard on all axes */
  28686. static get BILLBOARDMODE_ALL(): number;
  28687. /** Billboard on using position instead of orientation */
  28688. static get BILLBOARDMODE_USE_POSITION(): number;
  28689. /** @hidden */
  28690. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28691. /**
  28692. * The culling strategy to use to check whether the mesh must be rendered or not.
  28693. * This value can be changed at any time and will be used on the next render mesh selection.
  28694. * The possible values are :
  28695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28699. * Please read each static variable documentation to get details about the culling process.
  28700. * */
  28701. cullingStrategy: number;
  28702. /**
  28703. * Gets the number of facets in the mesh
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28705. */
  28706. get facetNb(): number;
  28707. /**
  28708. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28710. */
  28711. get partitioningSubdivisions(): number;
  28712. set partitioningSubdivisions(nb: number);
  28713. /**
  28714. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28715. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28717. */
  28718. get partitioningBBoxRatio(): number;
  28719. set partitioningBBoxRatio(ratio: number);
  28720. /**
  28721. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28722. * Works only for updatable meshes.
  28723. * Doesn't work with multi-materials
  28724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28725. */
  28726. get mustDepthSortFacets(): boolean;
  28727. set mustDepthSortFacets(sort: boolean);
  28728. /**
  28729. * The location (Vector3) where the facet depth sort must be computed from.
  28730. * By default, the active camera position.
  28731. * Used only when facet depth sort is enabled
  28732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28733. */
  28734. get facetDepthSortFrom(): Vector3;
  28735. set facetDepthSortFrom(location: Vector3);
  28736. /**
  28737. * gets a boolean indicating if facetData is enabled
  28738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28739. */
  28740. get isFacetDataEnabled(): boolean;
  28741. /** @hidden */
  28742. _updateNonUniformScalingState(value: boolean): boolean;
  28743. /**
  28744. * An event triggered when this mesh collides with another one
  28745. */
  28746. onCollideObservable: Observable<AbstractMesh>;
  28747. /** Set a function to call when this mesh collides with another one */
  28748. set onCollide(callback: () => void);
  28749. /**
  28750. * An event triggered when the collision's position changes
  28751. */
  28752. onCollisionPositionChangeObservable: Observable<Vector3>;
  28753. /** Set a function to call when the collision's position changes */
  28754. set onCollisionPositionChange(callback: () => void);
  28755. /**
  28756. * An event triggered when material is changed
  28757. */
  28758. onMaterialChangedObservable: Observable<AbstractMesh>;
  28759. /**
  28760. * Gets or sets the orientation for POV movement & rotation
  28761. */
  28762. definedFacingForward: boolean;
  28763. /** @hidden */
  28764. _occlusionQuery: Nullable<WebGLQuery>;
  28765. /** @hidden */
  28766. _renderingGroup: Nullable<RenderingGroup>;
  28767. /**
  28768. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28769. */
  28770. get visibility(): number;
  28771. /**
  28772. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28773. */
  28774. set visibility(value: number);
  28775. /** Gets or sets the alpha index used to sort transparent meshes
  28776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28777. */
  28778. alphaIndex: number;
  28779. /**
  28780. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28781. */
  28782. isVisible: boolean;
  28783. /**
  28784. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28785. */
  28786. isPickable: boolean;
  28787. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28788. showSubMeshesBoundingBox: boolean;
  28789. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28790. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28791. */
  28792. isBlocker: boolean;
  28793. /**
  28794. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28795. */
  28796. enablePointerMoveEvents: boolean;
  28797. /**
  28798. * Specifies the rendering group id for this mesh (0 by default)
  28799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28800. */
  28801. renderingGroupId: number;
  28802. private _material;
  28803. /** Gets or sets current material */
  28804. get material(): Nullable<Material>;
  28805. set material(value: Nullable<Material>);
  28806. /**
  28807. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28808. * @see http://doc.babylonjs.com/babylon101/shadows
  28809. */
  28810. get receiveShadows(): boolean;
  28811. set receiveShadows(value: boolean);
  28812. /** Defines color to use when rendering outline */
  28813. outlineColor: Color3;
  28814. /** Define width to use when rendering outline */
  28815. outlineWidth: number;
  28816. /** Defines color to use when rendering overlay */
  28817. overlayColor: Color3;
  28818. /** Defines alpha to use when rendering overlay */
  28819. overlayAlpha: number;
  28820. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28821. get hasVertexAlpha(): boolean;
  28822. set hasVertexAlpha(value: boolean);
  28823. /** 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) */
  28824. get useVertexColors(): boolean;
  28825. set useVertexColors(value: boolean);
  28826. /**
  28827. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28828. */
  28829. get computeBonesUsingShaders(): boolean;
  28830. set computeBonesUsingShaders(value: boolean);
  28831. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28832. get numBoneInfluencers(): number;
  28833. set numBoneInfluencers(value: number);
  28834. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28835. get applyFog(): boolean;
  28836. set applyFog(value: boolean);
  28837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28838. useOctreeForRenderingSelection: boolean;
  28839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28840. useOctreeForPicking: boolean;
  28841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28842. useOctreeForCollisions: boolean;
  28843. /**
  28844. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28845. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28846. */
  28847. get layerMask(): number;
  28848. set layerMask(value: number);
  28849. /**
  28850. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28851. */
  28852. alwaysSelectAsActiveMesh: boolean;
  28853. /**
  28854. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28855. */
  28856. doNotSyncBoundingInfo: boolean;
  28857. /**
  28858. * Gets or sets the current action manager
  28859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28860. */
  28861. actionManager: Nullable<AbstractActionManager>;
  28862. private _meshCollisionData;
  28863. /**
  28864. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28866. */
  28867. ellipsoid: Vector3;
  28868. /**
  28869. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28870. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28871. */
  28872. ellipsoidOffset: Vector3;
  28873. /**
  28874. * Gets or sets a collision mask used to mask collisions (default is -1).
  28875. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28876. */
  28877. get collisionMask(): number;
  28878. set collisionMask(mask: number);
  28879. /**
  28880. * Gets or sets the current collision group mask (-1 by default).
  28881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28882. */
  28883. get collisionGroup(): number;
  28884. set collisionGroup(mask: number);
  28885. /**
  28886. * Defines edge width used when edgesRenderer is enabled
  28887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28888. */
  28889. edgesWidth: number;
  28890. /**
  28891. * Defines edge color used when edgesRenderer is enabled
  28892. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28893. */
  28894. edgesColor: Color4;
  28895. /** @hidden */
  28896. _edgesRenderer: Nullable<IEdgesRenderer>;
  28897. /** @hidden */
  28898. _masterMesh: Nullable<AbstractMesh>;
  28899. /** @hidden */
  28900. _boundingInfo: Nullable<BoundingInfo>;
  28901. /** @hidden */
  28902. _renderId: number;
  28903. /**
  28904. * Gets or sets the list of subMeshes
  28905. * @see http://doc.babylonjs.com/how_to/multi_materials
  28906. */
  28907. subMeshes: SubMesh[];
  28908. /** @hidden */
  28909. _intersectionsInProgress: AbstractMesh[];
  28910. /** @hidden */
  28911. _unIndexed: boolean;
  28912. /** @hidden */
  28913. _lightSources: Light[];
  28914. /** Gets the list of lights affecting that mesh */
  28915. get lightSources(): Light[];
  28916. /** @hidden */
  28917. get _positions(): Nullable<Vector3[]>;
  28918. /** @hidden */
  28919. _waitingData: {
  28920. lods: Nullable<any>;
  28921. actions: Nullable<any>;
  28922. freezeWorldMatrix: Nullable<boolean>;
  28923. };
  28924. /** @hidden */
  28925. _bonesTransformMatrices: Nullable<Float32Array>;
  28926. /** @hidden */
  28927. _transformMatrixTexture: Nullable<RawTexture>;
  28928. /**
  28929. * Gets or sets a skeleton to apply skining transformations
  28930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28931. */
  28932. set skeleton(value: Nullable<Skeleton>);
  28933. get skeleton(): Nullable<Skeleton>;
  28934. /**
  28935. * An event triggered when the mesh is rebuilt.
  28936. */
  28937. onRebuildObservable: Observable<AbstractMesh>;
  28938. /**
  28939. * Creates a new AbstractMesh
  28940. * @param name defines the name of the mesh
  28941. * @param scene defines the hosting scene
  28942. */
  28943. constructor(name: string, scene?: Nullable<Scene>);
  28944. /**
  28945. * Returns the string "AbstractMesh"
  28946. * @returns "AbstractMesh"
  28947. */
  28948. getClassName(): string;
  28949. /**
  28950. * Gets a string representation of the current mesh
  28951. * @param fullDetails defines a boolean indicating if full details must be included
  28952. * @returns a string representation of the current mesh
  28953. */
  28954. toString(fullDetails?: boolean): string;
  28955. /**
  28956. * @hidden
  28957. */
  28958. protected _getEffectiveParent(): Nullable<Node>;
  28959. /** @hidden */
  28960. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28961. /** @hidden */
  28962. _rebuild(): void;
  28963. /** @hidden */
  28964. _resyncLightSources(): void;
  28965. /** @hidden */
  28966. _resyncLightSource(light: Light): void;
  28967. /** @hidden */
  28968. _unBindEffect(): void;
  28969. /** @hidden */
  28970. _removeLightSource(light: Light, dispose: boolean): void;
  28971. private _markSubMeshesAsDirty;
  28972. /** @hidden */
  28973. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28974. /** @hidden */
  28975. _markSubMeshesAsAttributesDirty(): void;
  28976. /** @hidden */
  28977. _markSubMeshesAsMiscDirty(): void;
  28978. /**
  28979. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28980. */
  28981. get scaling(): Vector3;
  28982. set scaling(newScaling: Vector3);
  28983. /**
  28984. * Returns true if the mesh is blocked. Implemented by child classes
  28985. */
  28986. get isBlocked(): boolean;
  28987. /**
  28988. * Returns the mesh itself by default. Implemented by child classes
  28989. * @param camera defines the camera to use to pick the right LOD level
  28990. * @returns the currentAbstractMesh
  28991. */
  28992. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28993. /**
  28994. * Returns 0 by default. Implemented by child classes
  28995. * @returns an integer
  28996. */
  28997. getTotalVertices(): number;
  28998. /**
  28999. * Returns a positive integer : the total number of indices in this mesh geometry.
  29000. * @returns the numner of indices or zero if the mesh has no geometry.
  29001. */
  29002. getTotalIndices(): number;
  29003. /**
  29004. * Returns null by default. Implemented by child classes
  29005. * @returns null
  29006. */
  29007. getIndices(): Nullable<IndicesArray>;
  29008. /**
  29009. * Returns the array of the requested vertex data kind. Implemented by child classes
  29010. * @param kind defines the vertex data kind to use
  29011. * @returns null
  29012. */
  29013. getVerticesData(kind: string): Nullable<FloatArray>;
  29014. /**
  29015. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29016. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29017. * Note that a new underlying VertexBuffer object is created each call.
  29018. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29019. * @param kind defines vertex data kind:
  29020. * * VertexBuffer.PositionKind
  29021. * * VertexBuffer.UVKind
  29022. * * VertexBuffer.UV2Kind
  29023. * * VertexBuffer.UV3Kind
  29024. * * VertexBuffer.UV4Kind
  29025. * * VertexBuffer.UV5Kind
  29026. * * VertexBuffer.UV6Kind
  29027. * * VertexBuffer.ColorKind
  29028. * * VertexBuffer.MatricesIndicesKind
  29029. * * VertexBuffer.MatricesIndicesExtraKind
  29030. * * VertexBuffer.MatricesWeightsKind
  29031. * * VertexBuffer.MatricesWeightsExtraKind
  29032. * @param data defines the data source
  29033. * @param updatable defines if the data must be flagged as updatable (or static)
  29034. * @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
  29035. * @returns the current mesh
  29036. */
  29037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29038. /**
  29039. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29040. * If the mesh has no geometry, it is simply returned as it is.
  29041. * @param kind defines vertex data kind:
  29042. * * VertexBuffer.PositionKind
  29043. * * VertexBuffer.UVKind
  29044. * * VertexBuffer.UV2Kind
  29045. * * VertexBuffer.UV3Kind
  29046. * * VertexBuffer.UV4Kind
  29047. * * VertexBuffer.UV5Kind
  29048. * * VertexBuffer.UV6Kind
  29049. * * VertexBuffer.ColorKind
  29050. * * VertexBuffer.MatricesIndicesKind
  29051. * * VertexBuffer.MatricesIndicesExtraKind
  29052. * * VertexBuffer.MatricesWeightsKind
  29053. * * VertexBuffer.MatricesWeightsExtraKind
  29054. * @param data defines the data source
  29055. * @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
  29056. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29057. * @returns the current mesh
  29058. */
  29059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29060. /**
  29061. * Sets the mesh indices,
  29062. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29063. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29064. * @param totalVertices Defines the total number of vertices
  29065. * @returns the current mesh
  29066. */
  29067. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29068. /**
  29069. * Gets a boolean indicating if specific vertex data is present
  29070. * @param kind defines the vertex data kind to use
  29071. * @returns true is data kind is present
  29072. */
  29073. isVerticesDataPresent(kind: string): boolean;
  29074. /**
  29075. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29076. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29077. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29078. * @returns a BoundingInfo
  29079. */
  29080. getBoundingInfo(): BoundingInfo;
  29081. /**
  29082. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29083. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29084. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29085. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29086. * @returns the current mesh
  29087. */
  29088. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29089. /**
  29090. * Overwrite the current bounding info
  29091. * @param boundingInfo defines the new bounding info
  29092. * @returns the current mesh
  29093. */
  29094. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29095. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29096. get useBones(): boolean;
  29097. /** @hidden */
  29098. _preActivate(): void;
  29099. /** @hidden */
  29100. _preActivateForIntermediateRendering(renderId: number): void;
  29101. /** @hidden */
  29102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29103. /** @hidden */
  29104. _postActivate(): void;
  29105. /** @hidden */
  29106. _freeze(): void;
  29107. /** @hidden */
  29108. _unFreeze(): void;
  29109. /**
  29110. * Gets the current world matrix
  29111. * @returns a Matrix
  29112. */
  29113. getWorldMatrix(): Matrix;
  29114. /** @hidden */
  29115. _getWorldMatrixDeterminant(): number;
  29116. /**
  29117. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29118. */
  29119. get isAnInstance(): boolean;
  29120. /**
  29121. * Gets a boolean indicating if this mesh has instances
  29122. */
  29123. get hasInstances(): boolean;
  29124. /**
  29125. * Perform relative position change from the point of view of behind the front of the mesh.
  29126. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29127. * Supports definition of mesh facing forward or backward
  29128. * @param amountRight defines the distance on the right axis
  29129. * @param amountUp defines the distance on the up axis
  29130. * @param amountForward defines the distance on the forward axis
  29131. * @returns the current mesh
  29132. */
  29133. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29134. /**
  29135. * Calculate relative position change from the point of view of behind the front of the mesh.
  29136. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29137. * Supports definition of mesh facing forward or backward
  29138. * @param amountRight defines the distance on the right axis
  29139. * @param amountUp defines the distance on the up axis
  29140. * @param amountForward defines the distance on the forward axis
  29141. * @returns the new displacement vector
  29142. */
  29143. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29144. /**
  29145. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29146. * Supports definition of mesh facing forward or backward
  29147. * @param flipBack defines the flip
  29148. * @param twirlClockwise defines the twirl
  29149. * @param tiltRight defines the tilt
  29150. * @returns the current mesh
  29151. */
  29152. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29153. /**
  29154. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29155. * Supports definition of mesh facing forward or backward.
  29156. * @param flipBack defines the flip
  29157. * @param twirlClockwise defines the twirl
  29158. * @param tiltRight defines the tilt
  29159. * @returns the new rotation vector
  29160. */
  29161. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29162. /**
  29163. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29164. * This means the mesh underlying bounding box and sphere are recomputed.
  29165. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29166. * @returns the current mesh
  29167. */
  29168. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29169. /** @hidden */
  29170. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29171. /** @hidden */
  29172. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29173. /** @hidden */
  29174. _updateBoundingInfo(): AbstractMesh;
  29175. /** @hidden */
  29176. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29177. /** @hidden */
  29178. protected _afterComputeWorldMatrix(): void;
  29179. /** @hidden */
  29180. get _effectiveMesh(): AbstractMesh;
  29181. /**
  29182. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29183. * A mesh is in the frustum if its bounding box intersects the frustum
  29184. * @param frustumPlanes defines the frustum to test
  29185. * @returns true if the mesh is in the frustum planes
  29186. */
  29187. isInFrustum(frustumPlanes: Plane[]): boolean;
  29188. /**
  29189. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29190. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29191. * @param frustumPlanes defines the frustum to test
  29192. * @returns true if the mesh is completely in the frustum planes
  29193. */
  29194. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29195. /**
  29196. * True if the mesh intersects another mesh or a SolidParticle object
  29197. * @param mesh defines a target mesh or SolidParticle to test
  29198. * @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)
  29199. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29200. * @returns true if there is an intersection
  29201. */
  29202. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29203. /**
  29204. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29205. * @param point defines the point to test
  29206. * @returns true if there is an intersection
  29207. */
  29208. intersectsPoint(point: Vector3): boolean;
  29209. /**
  29210. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29212. */
  29213. get checkCollisions(): boolean;
  29214. set checkCollisions(collisionEnabled: boolean);
  29215. /**
  29216. * Gets Collider object used to compute collisions (not physics)
  29217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29218. */
  29219. get collider(): Nullable<Collider>;
  29220. /**
  29221. * Move the mesh using collision engine
  29222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29223. * @param displacement defines the requested displacement vector
  29224. * @returns the current mesh
  29225. */
  29226. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29227. private _onCollisionPositionChange;
  29228. /** @hidden */
  29229. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29230. /** @hidden */
  29231. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29232. /** @hidden */
  29233. _checkCollision(collider: Collider): AbstractMesh;
  29234. /** @hidden */
  29235. _generatePointsArray(): boolean;
  29236. /**
  29237. * Checks if the passed Ray intersects with the mesh
  29238. * @param ray defines the ray to use
  29239. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29241. * @returns the picking info
  29242. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29243. */
  29244. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29245. /**
  29246. * Clones the current mesh
  29247. * @param name defines the mesh name
  29248. * @param newParent defines the new mesh parent
  29249. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29250. * @returns the new mesh
  29251. */
  29252. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29253. /**
  29254. * Disposes all the submeshes of the current meshnp
  29255. * @returns the current mesh
  29256. */
  29257. releaseSubMeshes(): AbstractMesh;
  29258. /**
  29259. * Releases resources associated with this abstract mesh.
  29260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29262. */
  29263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29264. /**
  29265. * Adds the passed mesh as a child to the current mesh
  29266. * @param mesh defines the child mesh
  29267. * @returns the current mesh
  29268. */
  29269. addChild(mesh: AbstractMesh): AbstractMesh;
  29270. /**
  29271. * Removes the passed mesh from the current mesh children list
  29272. * @param mesh defines the child mesh
  29273. * @returns the current mesh
  29274. */
  29275. removeChild(mesh: AbstractMesh): AbstractMesh;
  29276. /** @hidden */
  29277. private _initFacetData;
  29278. /**
  29279. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29280. * This method can be called within the render loop.
  29281. * 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
  29282. * @returns the current mesh
  29283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29284. */
  29285. updateFacetData(): AbstractMesh;
  29286. /**
  29287. * Returns the facetLocalNormals array.
  29288. * The normals are expressed in the mesh local spac
  29289. * @returns an array of Vector3
  29290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29291. */
  29292. getFacetLocalNormals(): Vector3[];
  29293. /**
  29294. * Returns the facetLocalPositions array.
  29295. * The facet positions are expressed in the mesh local space
  29296. * @returns an array of Vector3
  29297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29298. */
  29299. getFacetLocalPositions(): Vector3[];
  29300. /**
  29301. * Returns the facetLocalPartioning array
  29302. * @returns an array of array of numbers
  29303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29304. */
  29305. getFacetLocalPartitioning(): number[][];
  29306. /**
  29307. * Returns the i-th facet position in the world system.
  29308. * This method allocates a new Vector3 per call
  29309. * @param i defines the facet index
  29310. * @returns a new Vector3
  29311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29312. */
  29313. getFacetPosition(i: number): Vector3;
  29314. /**
  29315. * Sets the reference Vector3 with the i-th facet position in the world system
  29316. * @param i defines the facet index
  29317. * @param ref defines the target vector
  29318. * @returns the current mesh
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29320. */
  29321. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29322. /**
  29323. * Returns the i-th facet normal in the world system.
  29324. * This method allocates a new Vector3 per call
  29325. * @param i defines the facet index
  29326. * @returns a new Vector3
  29327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29328. */
  29329. getFacetNormal(i: number): Vector3;
  29330. /**
  29331. * Sets the reference Vector3 with the i-th facet normal in the world system
  29332. * @param i defines the facet index
  29333. * @param ref defines the target vector
  29334. * @returns the current mesh
  29335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29336. */
  29337. getFacetNormalToRef(i: number, ref: Vector3): this;
  29338. /**
  29339. * 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)
  29340. * @param x defines x coordinate
  29341. * @param y defines y coordinate
  29342. * @param z defines z coordinate
  29343. * @returns the array of facet indexes
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29347. /**
  29348. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29349. * @param projected sets as the (x,y,z) world projection on the facet
  29350. * @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
  29351. * @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
  29352. * @param x defines x coordinate
  29353. * @param y defines y coordinate
  29354. * @param z defines z coordinate
  29355. * @returns the face index if found (or null instead)
  29356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29357. */
  29358. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29359. /**
  29360. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29361. * @param projected sets as the (x,y,z) local projection on the facet
  29362. * @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
  29363. * @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
  29364. * @param x defines x coordinate
  29365. * @param y defines y coordinate
  29366. * @param z defines z coordinate
  29367. * @returns the face index if found (or null instead)
  29368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29369. */
  29370. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29371. /**
  29372. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29373. * @returns the parameters
  29374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29375. */
  29376. getFacetDataParameters(): any;
  29377. /**
  29378. * Disables the feature FacetData and frees the related memory
  29379. * @returns the current mesh
  29380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29381. */
  29382. disableFacetData(): AbstractMesh;
  29383. /**
  29384. * Updates the AbstractMesh indices array
  29385. * @param indices defines the data source
  29386. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29387. * @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)
  29388. * @returns the current mesh
  29389. */
  29390. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29391. /**
  29392. * Creates new normals data for the mesh
  29393. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29394. * @returns the current mesh
  29395. */
  29396. createNormals(updatable: boolean): AbstractMesh;
  29397. /**
  29398. * Align the mesh with a normal
  29399. * @param normal defines the normal to use
  29400. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29401. * @returns the current mesh
  29402. */
  29403. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29404. /** @hidden */
  29405. _checkOcclusionQuery(): boolean;
  29406. /**
  29407. * Disables the mesh edge rendering mode
  29408. * @returns the currentAbstractMesh
  29409. */
  29410. disableEdgesRendering(): AbstractMesh;
  29411. /**
  29412. * Enables the edge rendering mode on the mesh.
  29413. * This mode makes the mesh edges visible
  29414. * @param epsilon defines the maximal distance between two angles to detect a face
  29415. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29416. * @returns the currentAbstractMesh
  29417. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29418. */
  29419. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29420. }
  29421. }
  29422. declare module "babylonjs/Actions/actionEvent" {
  29423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29424. import { Nullable } from "babylonjs/types";
  29425. import { Sprite } from "babylonjs/Sprites/sprite";
  29426. import { Scene } from "babylonjs/scene";
  29427. import { Vector2 } from "babylonjs/Maths/math.vector";
  29428. /**
  29429. * Interface used to define ActionEvent
  29430. */
  29431. export interface IActionEvent {
  29432. /** The mesh or sprite that triggered the action */
  29433. source: any;
  29434. /** The X mouse cursor position at the time of the event */
  29435. pointerX: number;
  29436. /** The Y mouse cursor position at the time of the event */
  29437. pointerY: number;
  29438. /** The mesh that is currently pointed at (can be null) */
  29439. meshUnderPointer: Nullable<AbstractMesh>;
  29440. /** the original (browser) event that triggered the ActionEvent */
  29441. sourceEvent?: any;
  29442. /** additional data for the event */
  29443. additionalData?: any;
  29444. }
  29445. /**
  29446. * ActionEvent is the event being sent when an action is triggered.
  29447. */
  29448. export class ActionEvent implements IActionEvent {
  29449. /** The mesh or sprite that triggered the action */
  29450. source: any;
  29451. /** The X mouse cursor position at the time of the event */
  29452. pointerX: number;
  29453. /** The Y mouse cursor position at the time of the event */
  29454. pointerY: number;
  29455. /** The mesh that is currently pointed at (can be null) */
  29456. meshUnderPointer: Nullable<AbstractMesh>;
  29457. /** the original (browser) event that triggered the ActionEvent */
  29458. sourceEvent?: any;
  29459. /** additional data for the event */
  29460. additionalData?: any;
  29461. /**
  29462. * Creates a new ActionEvent
  29463. * @param source The mesh or sprite that triggered the action
  29464. * @param pointerX The X mouse cursor position at the time of the event
  29465. * @param pointerY The Y mouse cursor position at the time of the event
  29466. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29467. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29468. * @param additionalData additional data for the event
  29469. */
  29470. constructor(
  29471. /** The mesh or sprite that triggered the action */
  29472. source: any,
  29473. /** The X mouse cursor position at the time of the event */
  29474. pointerX: number,
  29475. /** The Y mouse cursor position at the time of the event */
  29476. pointerY: number,
  29477. /** The mesh that is currently pointed at (can be null) */
  29478. meshUnderPointer: Nullable<AbstractMesh>,
  29479. /** the original (browser) event that triggered the ActionEvent */
  29480. sourceEvent?: any,
  29481. /** additional data for the event */
  29482. additionalData?: any);
  29483. /**
  29484. * Helper function to auto-create an ActionEvent from a source mesh.
  29485. * @param source The source mesh that triggered the event
  29486. * @param evt The original (browser) event
  29487. * @param additionalData additional data for the event
  29488. * @returns the new ActionEvent
  29489. */
  29490. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29491. /**
  29492. * Helper function to auto-create an ActionEvent from a source sprite
  29493. * @param source The source sprite that triggered the event
  29494. * @param scene Scene associated with the sprite
  29495. * @param evt The original (browser) event
  29496. * @param additionalData additional data for the event
  29497. * @returns the new ActionEvent
  29498. */
  29499. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29500. /**
  29501. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29502. * @param scene the scene where the event occurred
  29503. * @param evt The original (browser) event
  29504. * @returns the new ActionEvent
  29505. */
  29506. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29507. /**
  29508. * Helper function to auto-create an ActionEvent from a primitive
  29509. * @param prim defines the target primitive
  29510. * @param pointerPos defines the pointer position
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29516. }
  29517. }
  29518. declare module "babylonjs/Actions/abstractActionManager" {
  29519. import { IDisposable } from "babylonjs/scene";
  29520. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29521. import { IAction } from "babylonjs/Actions/action";
  29522. import { Nullable } from "babylonjs/types";
  29523. /**
  29524. * Abstract class used to decouple action Manager from scene and meshes.
  29525. * Do not instantiate.
  29526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29527. */
  29528. export abstract class AbstractActionManager implements IDisposable {
  29529. /** Gets the list of active triggers */
  29530. static Triggers: {
  29531. [key: string]: number;
  29532. };
  29533. /** Gets the cursor to use when hovering items */
  29534. hoverCursor: string;
  29535. /** Gets the list of actions */
  29536. actions: IAction[];
  29537. /**
  29538. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29539. */
  29540. isRecursive: boolean;
  29541. /**
  29542. * Releases all associated resources
  29543. */
  29544. abstract dispose(): void;
  29545. /**
  29546. * Does this action manager has pointer triggers
  29547. */
  29548. abstract get hasPointerTriggers(): boolean;
  29549. /**
  29550. * Does this action manager has pick triggers
  29551. */
  29552. abstract get hasPickTriggers(): boolean;
  29553. /**
  29554. * Process a specific trigger
  29555. * @param trigger defines the trigger to process
  29556. * @param evt defines the event details to be processed
  29557. */
  29558. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29559. /**
  29560. * Does this action manager handles actions of any of the given triggers
  29561. * @param triggers defines the triggers to be tested
  29562. * @return a boolean indicating whether one (or more) of the triggers is handled
  29563. */
  29564. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29565. /**
  29566. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29567. * speed.
  29568. * @param triggerA defines the trigger to be tested
  29569. * @param triggerB defines the trigger to be tested
  29570. * @return a boolean indicating whether one (or more) of the triggers is handled
  29571. */
  29572. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29573. /**
  29574. * Does this action manager handles actions of a given trigger
  29575. * @param trigger defines the trigger to be tested
  29576. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29577. * @return whether the trigger is handled
  29578. */
  29579. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29580. /**
  29581. * Serialize this manager to a JSON object
  29582. * @param name defines the property name to store this manager
  29583. * @returns a JSON representation of this manager
  29584. */
  29585. abstract serialize(name: string): any;
  29586. /**
  29587. * Registers an action to this action manager
  29588. * @param action defines the action to be registered
  29589. * @return the action amended (prepared) after registration
  29590. */
  29591. abstract registerAction(action: IAction): Nullable<IAction>;
  29592. /**
  29593. * Unregisters an action to this action manager
  29594. * @param action defines the action to be unregistered
  29595. * @return a boolean indicating whether the action has been unregistered
  29596. */
  29597. abstract unregisterAction(action: IAction): Boolean;
  29598. /**
  29599. * Does exist one action manager with at least one trigger
  29600. **/
  29601. static get HasTriggers(): boolean;
  29602. /**
  29603. * Does exist one action manager with at least one pick trigger
  29604. **/
  29605. static get HasPickTriggers(): boolean;
  29606. /**
  29607. * Does exist one action manager that handles actions of a given trigger
  29608. * @param trigger defines the trigger to be tested
  29609. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29610. **/
  29611. static HasSpecificTrigger(trigger: number): boolean;
  29612. }
  29613. }
  29614. declare module "babylonjs/node" {
  29615. import { Scene } from "babylonjs/scene";
  29616. import { Nullable } from "babylonjs/types";
  29617. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29618. import { Engine } from "babylonjs/Engines/engine";
  29619. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29620. import { Observable } from "babylonjs/Misc/observable";
  29621. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29622. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29623. import { Animatable } from "babylonjs/Animations/animatable";
  29624. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29625. import { Animation } from "babylonjs/Animations/animation";
  29626. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29628. /**
  29629. * Defines how a node can be built from a string name.
  29630. */
  29631. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29632. /**
  29633. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29634. */
  29635. export class Node implements IBehaviorAware<Node> {
  29636. /** @hidden */
  29637. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29638. private static _NodeConstructors;
  29639. /**
  29640. * Add a new node constructor
  29641. * @param type defines the type name of the node to construct
  29642. * @param constructorFunc defines the constructor function
  29643. */
  29644. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29645. /**
  29646. * Returns a node constructor based on type name
  29647. * @param type defines the type name
  29648. * @param name defines the new node name
  29649. * @param scene defines the hosting scene
  29650. * @param options defines optional options to transmit to constructors
  29651. * @returns the new constructor or null
  29652. */
  29653. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29654. /**
  29655. * Gets or sets the name of the node
  29656. */
  29657. name: string;
  29658. /**
  29659. * Gets or sets the id of the node
  29660. */
  29661. id: string;
  29662. /**
  29663. * Gets or sets the unique id of the node
  29664. */
  29665. uniqueId: number;
  29666. /**
  29667. * Gets or sets a string used to store user defined state for the node
  29668. */
  29669. state: string;
  29670. /**
  29671. * Gets or sets an object used to store user defined information for the node
  29672. */
  29673. metadata: any;
  29674. /**
  29675. * For internal use only. Please do not use.
  29676. */
  29677. reservedDataStore: any;
  29678. /**
  29679. * List of inspectable custom properties (used by the Inspector)
  29680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29681. */
  29682. inspectableCustomProperties: IInspectable[];
  29683. private _doNotSerialize;
  29684. /**
  29685. * Gets or sets a boolean used to define if the node must be serialized
  29686. */
  29687. get doNotSerialize(): boolean;
  29688. set doNotSerialize(value: boolean);
  29689. /** @hidden */
  29690. _isDisposed: boolean;
  29691. /**
  29692. * Gets a list of Animations associated with the node
  29693. */
  29694. animations: import("babylonjs/Animations/animation").Animation[];
  29695. protected _ranges: {
  29696. [name: string]: Nullable<AnimationRange>;
  29697. };
  29698. /**
  29699. * Callback raised when the node is ready to be used
  29700. */
  29701. onReady: Nullable<(node: Node) => void>;
  29702. private _isEnabled;
  29703. private _isParentEnabled;
  29704. private _isReady;
  29705. /** @hidden */
  29706. _currentRenderId: number;
  29707. private _parentUpdateId;
  29708. /** @hidden */
  29709. _childUpdateId: number;
  29710. /** @hidden */
  29711. _waitingParentId: Nullable<string>;
  29712. /** @hidden */
  29713. _scene: Scene;
  29714. /** @hidden */
  29715. _cache: any;
  29716. private _parentNode;
  29717. private _children;
  29718. /** @hidden */
  29719. _worldMatrix: Matrix;
  29720. /** @hidden */
  29721. _worldMatrixDeterminant: number;
  29722. /** @hidden */
  29723. _worldMatrixDeterminantIsDirty: boolean;
  29724. /** @hidden */
  29725. private _sceneRootNodesIndex;
  29726. /**
  29727. * Gets a boolean indicating if the node has been disposed
  29728. * @returns true if the node was disposed
  29729. */
  29730. isDisposed(): boolean;
  29731. /**
  29732. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29733. * @see https://doc.babylonjs.com/how_to/parenting
  29734. */
  29735. set parent(parent: Nullable<Node>);
  29736. get parent(): Nullable<Node>;
  29737. /** @hidden */
  29738. _addToSceneRootNodes(): void;
  29739. /** @hidden */
  29740. _removeFromSceneRootNodes(): void;
  29741. private _animationPropertiesOverride;
  29742. /**
  29743. * Gets or sets the animation properties override
  29744. */
  29745. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29746. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29747. /**
  29748. * Gets a string idenfifying the name of the class
  29749. * @returns "Node" string
  29750. */
  29751. getClassName(): string;
  29752. /** @hidden */
  29753. readonly _isNode: boolean;
  29754. /**
  29755. * An event triggered when the mesh is disposed
  29756. */
  29757. onDisposeObservable: Observable<Node>;
  29758. private _onDisposeObserver;
  29759. /**
  29760. * Sets a callback that will be raised when the node will be disposed
  29761. */
  29762. set onDispose(callback: () => void);
  29763. /**
  29764. * Creates a new Node
  29765. * @param name the name and id to be given to this node
  29766. * @param scene the scene this node will be added to
  29767. */
  29768. constructor(name: string, scene?: Nullable<Scene>);
  29769. /**
  29770. * Gets the scene of the node
  29771. * @returns a scene
  29772. */
  29773. getScene(): Scene;
  29774. /**
  29775. * Gets the engine of the node
  29776. * @returns a Engine
  29777. */
  29778. getEngine(): Engine;
  29779. private _behaviors;
  29780. /**
  29781. * Attach a behavior to the node
  29782. * @see http://doc.babylonjs.com/features/behaviour
  29783. * @param behavior defines the behavior to attach
  29784. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29785. * @returns the current Node
  29786. */
  29787. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29788. /**
  29789. * Remove an attached behavior
  29790. * @see http://doc.babylonjs.com/features/behaviour
  29791. * @param behavior defines the behavior to attach
  29792. * @returns the current Node
  29793. */
  29794. removeBehavior(behavior: Behavior<Node>): Node;
  29795. /**
  29796. * Gets the list of attached behaviors
  29797. * @see http://doc.babylonjs.com/features/behaviour
  29798. */
  29799. get behaviors(): Behavior<Node>[];
  29800. /**
  29801. * Gets an attached behavior by name
  29802. * @param name defines the name of the behavior to look for
  29803. * @see http://doc.babylonjs.com/features/behaviour
  29804. * @returns null if behavior was not found else the requested behavior
  29805. */
  29806. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29807. /**
  29808. * Returns the latest update of the World matrix
  29809. * @returns a Matrix
  29810. */
  29811. getWorldMatrix(): Matrix;
  29812. /** @hidden */
  29813. _getWorldMatrixDeterminant(): number;
  29814. /**
  29815. * Returns directly the latest state of the mesh World matrix.
  29816. * A Matrix is returned.
  29817. */
  29818. get worldMatrixFromCache(): Matrix;
  29819. /** @hidden */
  29820. _initCache(): void;
  29821. /** @hidden */
  29822. updateCache(force?: boolean): void;
  29823. /** @hidden */
  29824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29825. /** @hidden */
  29826. _updateCache(ignoreParentClass?: boolean): void;
  29827. /** @hidden */
  29828. _isSynchronized(): boolean;
  29829. /** @hidden */
  29830. _markSyncedWithParent(): void;
  29831. /** @hidden */
  29832. isSynchronizedWithParent(): boolean;
  29833. /** @hidden */
  29834. isSynchronized(): boolean;
  29835. /**
  29836. * Is this node ready to be used/rendered
  29837. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29838. * @return true if the node is ready
  29839. */
  29840. isReady(completeCheck?: boolean): boolean;
  29841. /**
  29842. * Is this node enabled?
  29843. * 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
  29844. * @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
  29845. * @return whether this node (and its parent) is enabled
  29846. */
  29847. isEnabled(checkAncestors?: boolean): boolean;
  29848. /** @hidden */
  29849. protected _syncParentEnabledState(): void;
  29850. /**
  29851. * Set the enabled state of this node
  29852. * @param value defines the new enabled state
  29853. */
  29854. setEnabled(value: boolean): void;
  29855. /**
  29856. * Is this node a descendant of the given node?
  29857. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29858. * @param ancestor defines the parent node to inspect
  29859. * @returns a boolean indicating if this node is a descendant of the given node
  29860. */
  29861. isDescendantOf(ancestor: Node): boolean;
  29862. /** @hidden */
  29863. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29864. /**
  29865. * Will return all nodes that have this node as ascendant
  29866. * @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
  29867. * @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
  29868. * @return all children nodes of all types
  29869. */
  29870. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29871. /**
  29872. * Get all child-meshes of this node
  29873. * @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)
  29874. * @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
  29875. * @returns an array of AbstractMesh
  29876. */
  29877. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29878. /**
  29879. * Get all direct children of this node
  29880. * @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
  29881. * @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)
  29882. * @returns an array of Node
  29883. */
  29884. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29885. /** @hidden */
  29886. _setReady(state: boolean): void;
  29887. /**
  29888. * Get an animation by name
  29889. * @param name defines the name of the animation to look for
  29890. * @returns null if not found else the requested animation
  29891. */
  29892. getAnimationByName(name: string): Nullable<Animation>;
  29893. /**
  29894. * Creates an animation range for this node
  29895. * @param name defines the name of the range
  29896. * @param from defines the starting key
  29897. * @param to defines the end key
  29898. */
  29899. createAnimationRange(name: string, from: number, to: number): void;
  29900. /**
  29901. * Delete a specific animation range
  29902. * @param name defines the name of the range to delete
  29903. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29904. */
  29905. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29906. /**
  29907. * Get an animation range by name
  29908. * @param name defines the name of the animation range to look for
  29909. * @returns null if not found else the requested animation range
  29910. */
  29911. getAnimationRange(name: string): Nullable<AnimationRange>;
  29912. /**
  29913. * Gets the list of all animation ranges defined on this node
  29914. * @returns an array
  29915. */
  29916. getAnimationRanges(): Nullable<AnimationRange>[];
  29917. /**
  29918. * Will start the animation sequence
  29919. * @param name defines the range frames for animation sequence
  29920. * @param loop defines if the animation should loop (false by default)
  29921. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29922. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29923. * @returns the object created for this animation. If range does not exist, it will return null
  29924. */
  29925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29926. /**
  29927. * Serialize animation ranges into a JSON compatible object
  29928. * @returns serialization object
  29929. */
  29930. serializeAnimationRanges(): any;
  29931. /**
  29932. * Computes the world matrix of the node
  29933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29934. * @returns the world matrix
  29935. */
  29936. computeWorldMatrix(force?: boolean): Matrix;
  29937. /**
  29938. * Releases resources associated with this node.
  29939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29941. */
  29942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29943. /**
  29944. * Parse animation range data from a serialization object and store them into a given node
  29945. * @param node defines where to store the animation ranges
  29946. * @param parsedNode defines the serialization object to read data from
  29947. * @param scene defines the hosting scene
  29948. */
  29949. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29950. /**
  29951. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29952. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29953. * @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
  29954. * @returns the new bounding vectors
  29955. */
  29956. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29957. min: Vector3;
  29958. max: Vector3;
  29959. };
  29960. }
  29961. }
  29962. declare module "babylonjs/Animations/animation" {
  29963. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29964. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29965. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29966. import { Nullable } from "babylonjs/types";
  29967. import { Scene } from "babylonjs/scene";
  29968. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29970. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29971. import { Node } from "babylonjs/node";
  29972. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29973. import { Size } from "babylonjs/Maths/math.size";
  29974. import { Animatable } from "babylonjs/Animations/animatable";
  29975. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29976. /**
  29977. * @hidden
  29978. */
  29979. export class _IAnimationState {
  29980. key: number;
  29981. repeatCount: number;
  29982. workValue?: any;
  29983. loopMode?: number;
  29984. offsetValue?: any;
  29985. highLimitValue?: any;
  29986. }
  29987. /**
  29988. * Class used to store any kind of animation
  29989. */
  29990. export class Animation {
  29991. /**Name of the animation */
  29992. name: string;
  29993. /**Property to animate */
  29994. targetProperty: string;
  29995. /**The frames per second of the animation */
  29996. framePerSecond: number;
  29997. /**The data type of the animation */
  29998. dataType: number;
  29999. /**The loop mode of the animation */
  30000. loopMode?: number | undefined;
  30001. /**Specifies if blending should be enabled */
  30002. enableBlending?: boolean | undefined;
  30003. /**
  30004. * Use matrix interpolation instead of using direct key value when animating matrices
  30005. */
  30006. static AllowMatricesInterpolation: boolean;
  30007. /**
  30008. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30009. */
  30010. static AllowMatrixDecomposeForInterpolation: boolean;
  30011. /**
  30012. * Stores the key frames of the animation
  30013. */
  30014. private _keys;
  30015. /**
  30016. * Stores the easing function of the animation
  30017. */
  30018. private _easingFunction;
  30019. /**
  30020. * @hidden Internal use only
  30021. */
  30022. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30023. /**
  30024. * The set of event that will be linked to this animation
  30025. */
  30026. private _events;
  30027. /**
  30028. * Stores an array of target property paths
  30029. */
  30030. targetPropertyPath: string[];
  30031. /**
  30032. * Stores the blending speed of the animation
  30033. */
  30034. blendingSpeed: number;
  30035. /**
  30036. * Stores the animation ranges for the animation
  30037. */
  30038. private _ranges;
  30039. /**
  30040. * @hidden Internal use
  30041. */
  30042. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30043. /**
  30044. * Sets up an animation
  30045. * @param property The property to animate
  30046. * @param animationType The animation type to apply
  30047. * @param framePerSecond The frames per second of the animation
  30048. * @param easingFunction The easing function used in the animation
  30049. * @returns The created animation
  30050. */
  30051. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30052. /**
  30053. * Create and start an animation on a node
  30054. * @param name defines the name of the global animation that will be run on all nodes
  30055. * @param node defines the root node where the animation will take place
  30056. * @param targetProperty defines property to animate
  30057. * @param framePerSecond defines the number of frame per second yo use
  30058. * @param totalFrame defines the number of frames in total
  30059. * @param from defines the initial value
  30060. * @param to defines the final value
  30061. * @param loopMode defines which loop mode you want to use (off by default)
  30062. * @param easingFunction defines the easing function to use (linear by default)
  30063. * @param onAnimationEnd defines the callback to call when animation end
  30064. * @returns the animatable created for this animation
  30065. */
  30066. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30067. /**
  30068. * Create and start an animation on a node and its descendants
  30069. * @param name defines the name of the global animation that will be run on all nodes
  30070. * @param node defines the root node where the animation will take place
  30071. * @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
  30072. * @param targetProperty defines property to animate
  30073. * @param framePerSecond defines the number of frame per second to use
  30074. * @param totalFrame defines the number of frames in total
  30075. * @param from defines the initial value
  30076. * @param to defines the final value
  30077. * @param loopMode defines which loop mode you want to use (off by default)
  30078. * @param easingFunction defines the easing function to use (linear by default)
  30079. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30080. * @returns the list of animatables created for all nodes
  30081. * @example https://www.babylonjs-playground.com/#MH0VLI
  30082. */
  30083. 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[]>;
  30084. /**
  30085. * Creates a new animation, merges it with the existing animations and starts it
  30086. * @param name Name of the animation
  30087. * @param node Node which contains the scene that begins the animations
  30088. * @param targetProperty Specifies which property to animate
  30089. * @param framePerSecond The frames per second of the animation
  30090. * @param totalFrame The total number of frames
  30091. * @param from The frame at the beginning of the animation
  30092. * @param to The frame at the end of the animation
  30093. * @param loopMode Specifies the loop mode of the animation
  30094. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30095. * @param onAnimationEnd Callback to run once the animation is complete
  30096. * @returns Nullable animation
  30097. */
  30098. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30099. /**
  30100. * Transition property of an host to the target Value
  30101. * @param property The property to transition
  30102. * @param targetValue The target Value of the property
  30103. * @param host The object where the property to animate belongs
  30104. * @param scene Scene used to run the animation
  30105. * @param frameRate Framerate (in frame/s) to use
  30106. * @param transition The transition type we want to use
  30107. * @param duration The duration of the animation, in milliseconds
  30108. * @param onAnimationEnd Callback trigger at the end of the animation
  30109. * @returns Nullable animation
  30110. */
  30111. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30112. /**
  30113. * Return the array of runtime animations currently using this animation
  30114. */
  30115. get runtimeAnimations(): RuntimeAnimation[];
  30116. /**
  30117. * Specifies if any of the runtime animations are currently running
  30118. */
  30119. get hasRunningRuntimeAnimations(): boolean;
  30120. /**
  30121. * Initializes the animation
  30122. * @param name Name of the animation
  30123. * @param targetProperty Property to animate
  30124. * @param framePerSecond The frames per second of the animation
  30125. * @param dataType The data type of the animation
  30126. * @param loopMode The loop mode of the animation
  30127. * @param enableBlending Specifies if blending should be enabled
  30128. */
  30129. constructor(
  30130. /**Name of the animation */
  30131. name: string,
  30132. /**Property to animate */
  30133. targetProperty: string,
  30134. /**The frames per second of the animation */
  30135. framePerSecond: number,
  30136. /**The data type of the animation */
  30137. dataType: number,
  30138. /**The loop mode of the animation */
  30139. loopMode?: number | undefined,
  30140. /**Specifies if blending should be enabled */
  30141. enableBlending?: boolean | undefined);
  30142. /**
  30143. * Converts the animation to a string
  30144. * @param fullDetails support for multiple levels of logging within scene loading
  30145. * @returns String form of the animation
  30146. */
  30147. toString(fullDetails?: boolean): string;
  30148. /**
  30149. * Add an event to this animation
  30150. * @param event Event to add
  30151. */
  30152. addEvent(event: AnimationEvent): void;
  30153. /**
  30154. * Remove all events found at the given frame
  30155. * @param frame The frame to remove events from
  30156. */
  30157. removeEvents(frame: number): void;
  30158. /**
  30159. * Retrieves all the events from the animation
  30160. * @returns Events from the animation
  30161. */
  30162. getEvents(): AnimationEvent[];
  30163. /**
  30164. * Creates an animation range
  30165. * @param name Name of the animation range
  30166. * @param from Starting frame of the animation range
  30167. * @param to Ending frame of the animation
  30168. */
  30169. createRange(name: string, from: number, to: number): void;
  30170. /**
  30171. * Deletes an animation range by name
  30172. * @param name Name of the animation range to delete
  30173. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30174. */
  30175. deleteRange(name: string, deleteFrames?: boolean): void;
  30176. /**
  30177. * Gets the animation range by name, or null if not defined
  30178. * @param name Name of the animation range
  30179. * @returns Nullable animation range
  30180. */
  30181. getRange(name: string): Nullable<AnimationRange>;
  30182. /**
  30183. * Gets the key frames from the animation
  30184. * @returns The key frames of the animation
  30185. */
  30186. getKeys(): Array<IAnimationKey>;
  30187. /**
  30188. * Gets the highest frame rate of the animation
  30189. * @returns Highest frame rate of the animation
  30190. */
  30191. getHighestFrame(): number;
  30192. /**
  30193. * Gets the easing function of the animation
  30194. * @returns Easing function of the animation
  30195. */
  30196. getEasingFunction(): IEasingFunction;
  30197. /**
  30198. * Sets the easing function of the animation
  30199. * @param easingFunction A custom mathematical formula for animation
  30200. */
  30201. setEasingFunction(easingFunction: EasingFunction): void;
  30202. /**
  30203. * Interpolates a scalar linearly
  30204. * @param startValue Start value of the animation curve
  30205. * @param endValue End value of the animation curve
  30206. * @param gradient Scalar amount to interpolate
  30207. * @returns Interpolated scalar value
  30208. */
  30209. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30210. /**
  30211. * Interpolates a scalar cubically
  30212. * @param startValue Start value of the animation curve
  30213. * @param outTangent End tangent of the animation
  30214. * @param endValue End value of the animation curve
  30215. * @param inTangent Start tangent of the animation curve
  30216. * @param gradient Scalar amount to interpolate
  30217. * @returns Interpolated scalar value
  30218. */
  30219. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30220. /**
  30221. * Interpolates a quaternion using a spherical linear interpolation
  30222. * @param startValue Start value of the animation curve
  30223. * @param endValue End value of the animation curve
  30224. * @param gradient Scalar amount to interpolate
  30225. * @returns Interpolated quaternion value
  30226. */
  30227. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30228. /**
  30229. * Interpolates a quaternion cubically
  30230. * @param startValue Start value of the animation curve
  30231. * @param outTangent End tangent of the animation curve
  30232. * @param endValue End value of the animation curve
  30233. * @param inTangent Start tangent of the animation curve
  30234. * @param gradient Scalar amount to interpolate
  30235. * @returns Interpolated quaternion value
  30236. */
  30237. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30238. /**
  30239. * Interpolates a Vector3 linearl
  30240. * @param startValue Start value of the animation curve
  30241. * @param endValue End value of the animation curve
  30242. * @param gradient Scalar amount to interpolate
  30243. * @returns Interpolated scalar value
  30244. */
  30245. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30246. /**
  30247. * Interpolates a Vector3 cubically
  30248. * @param startValue Start value of the animation curve
  30249. * @param outTangent End tangent of the animation
  30250. * @param endValue End value of the animation curve
  30251. * @param inTangent Start tangent of the animation curve
  30252. * @param gradient Scalar amount to interpolate
  30253. * @returns InterpolatedVector3 value
  30254. */
  30255. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30256. /**
  30257. * Interpolates a Vector2 linearly
  30258. * @param startValue Start value of the animation curve
  30259. * @param endValue End value of the animation curve
  30260. * @param gradient Scalar amount to interpolate
  30261. * @returns Interpolated Vector2 value
  30262. */
  30263. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30264. /**
  30265. * Interpolates a Vector2 cubically
  30266. * @param startValue Start value of the animation curve
  30267. * @param outTangent End tangent of the animation
  30268. * @param endValue End value of the animation curve
  30269. * @param inTangent Start tangent of the animation curve
  30270. * @param gradient Scalar amount to interpolate
  30271. * @returns Interpolated Vector2 value
  30272. */
  30273. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30274. /**
  30275. * Interpolates a size linearly
  30276. * @param startValue Start value of the animation curve
  30277. * @param endValue End value of the animation curve
  30278. * @param gradient Scalar amount to interpolate
  30279. * @returns Interpolated Size value
  30280. */
  30281. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30282. /**
  30283. * Interpolates a Color3 linearly
  30284. * @param startValue Start value of the animation curve
  30285. * @param endValue End value of the animation curve
  30286. * @param gradient Scalar amount to interpolate
  30287. * @returns Interpolated Color3 value
  30288. */
  30289. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30290. /**
  30291. * Interpolates a Color4 linearly
  30292. * @param startValue Start value of the animation curve
  30293. * @param endValue End value of the animation curve
  30294. * @param gradient Scalar amount to interpolate
  30295. * @returns Interpolated Color3 value
  30296. */
  30297. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30298. /**
  30299. * @hidden Internal use only
  30300. */
  30301. _getKeyValue(value: any): any;
  30302. /**
  30303. * @hidden Internal use only
  30304. */
  30305. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30306. /**
  30307. * Defines the function to use to interpolate matrices
  30308. * @param startValue defines the start matrix
  30309. * @param endValue defines the end matrix
  30310. * @param gradient defines the gradient between both matrices
  30311. * @param result defines an optional target matrix where to store the interpolation
  30312. * @returns the interpolated matrix
  30313. */
  30314. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30315. /**
  30316. * Makes a copy of the animation
  30317. * @returns Cloned animation
  30318. */
  30319. clone(): Animation;
  30320. /**
  30321. * Sets the key frames of the animation
  30322. * @param values The animation key frames to set
  30323. */
  30324. setKeys(values: Array<IAnimationKey>): void;
  30325. /**
  30326. * Serializes the animation to an object
  30327. * @returns Serialized object
  30328. */
  30329. serialize(): any;
  30330. /**
  30331. * Float animation type
  30332. */
  30333. static readonly ANIMATIONTYPE_FLOAT: number;
  30334. /**
  30335. * Vector3 animation type
  30336. */
  30337. static readonly ANIMATIONTYPE_VECTOR3: number;
  30338. /**
  30339. * Quaternion animation type
  30340. */
  30341. static readonly ANIMATIONTYPE_QUATERNION: number;
  30342. /**
  30343. * Matrix animation type
  30344. */
  30345. static readonly ANIMATIONTYPE_MATRIX: number;
  30346. /**
  30347. * Color3 animation type
  30348. */
  30349. static readonly ANIMATIONTYPE_COLOR3: number;
  30350. /**
  30351. * Color3 animation type
  30352. */
  30353. static readonly ANIMATIONTYPE_COLOR4: number;
  30354. /**
  30355. * Vector2 animation type
  30356. */
  30357. static readonly ANIMATIONTYPE_VECTOR2: number;
  30358. /**
  30359. * Size animation type
  30360. */
  30361. static readonly ANIMATIONTYPE_SIZE: number;
  30362. /**
  30363. * Relative Loop Mode
  30364. */
  30365. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30366. /**
  30367. * Cycle Loop Mode
  30368. */
  30369. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30370. /**
  30371. * Constant Loop Mode
  30372. */
  30373. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30374. /** @hidden */
  30375. static _UniversalLerp(left: any, right: any, amount: number): any;
  30376. /**
  30377. * Parses an animation object and creates an animation
  30378. * @param parsedAnimation Parsed animation object
  30379. * @returns Animation object
  30380. */
  30381. static Parse(parsedAnimation: any): Animation;
  30382. /**
  30383. * Appends the serialized animations from the source animations
  30384. * @param source Source containing the animations
  30385. * @param destination Target to store the animations
  30386. */
  30387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30388. }
  30389. }
  30390. declare module "babylonjs/Animations/animatable.interface" {
  30391. import { Nullable } from "babylonjs/types";
  30392. import { Animation } from "babylonjs/Animations/animation";
  30393. /**
  30394. * Interface containing an array of animations
  30395. */
  30396. export interface IAnimatable {
  30397. /**
  30398. * Array of animations
  30399. */
  30400. animations: Nullable<Array<Animation>>;
  30401. }
  30402. }
  30403. declare module "babylonjs/Misc/decorators" {
  30404. import { Nullable } from "babylonjs/types";
  30405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30406. import { Scene } from "babylonjs/scene";
  30407. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30408. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. /**
  30421. * Decorator used to define property that can be serialized as reference to a camera
  30422. * @param sourceName defines the name of the property to decorate
  30423. */
  30424. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30425. /**
  30426. * Class used to help serialization objects
  30427. */
  30428. export class SerializationHelper {
  30429. /** @hidden */
  30430. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30431. /** @hidden */
  30432. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30433. /** @hidden */
  30434. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30435. /** @hidden */
  30436. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30437. /**
  30438. * Appends the serialized animations from the source animations
  30439. * @param source Source containing the animations
  30440. * @param destination Target to store the animations
  30441. */
  30442. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30443. /**
  30444. * Static function used to serialized a specific entity
  30445. * @param entity defines the entity to serialize
  30446. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30447. * @returns a JSON compatible object representing the serialization of the entity
  30448. */
  30449. static Serialize<T>(entity: T, serializationObject?: any): any;
  30450. /**
  30451. * Creates a new entity from a serialization data object
  30452. * @param creationFunction defines a function used to instanciated the new entity
  30453. * @param source defines the source serialization data
  30454. * @param scene defines the hosting scene
  30455. * @param rootUrl defines the root url for resources
  30456. * @returns a new entity
  30457. */
  30458. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30459. /**
  30460. * Clones an object
  30461. * @param creationFunction defines the function used to instanciate the new object
  30462. * @param source defines the source object
  30463. * @returns the cloned object
  30464. */
  30465. static Clone<T>(creationFunction: () => T, source: T): T;
  30466. /**
  30467. * Instanciates a new object based on a source one (some data will be shared between both object)
  30468. * @param creationFunction defines the function used to instanciate the new object
  30469. * @param source defines the source object
  30470. * @returns the new object
  30471. */
  30472. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30473. }
  30474. }
  30475. declare module "babylonjs/Misc/guid" {
  30476. /**
  30477. * Class used to manipulate GUIDs
  30478. */
  30479. export class GUID {
  30480. /**
  30481. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30482. * Be aware Math.random() could cause collisions, but:
  30483. * "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"
  30484. * @returns a pseudo random id
  30485. */
  30486. static RandomId(): string;
  30487. }
  30488. }
  30489. declare module "babylonjs/Materials/Textures/baseTexture" {
  30490. import { Observable } from "babylonjs/Misc/observable";
  30491. import { Nullable } from "babylonjs/types";
  30492. import { Scene } from "babylonjs/scene";
  30493. import { Matrix } from "babylonjs/Maths/math.vector";
  30494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30495. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30496. import { ISize } from "babylonjs/Maths/math.size";
  30497. import "babylonjs/Misc/fileTools";
  30498. /**
  30499. * Base class of all the textures in babylon.
  30500. * It groups all the common properties the materials, post process, lights... might need
  30501. * in order to make a correct use of the texture.
  30502. */
  30503. export class BaseTexture implements IAnimatable {
  30504. /**
  30505. * Default anisotropic filtering level for the application.
  30506. * It is set to 4 as a good tradeoff between perf and quality.
  30507. */
  30508. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30509. /**
  30510. * Gets or sets the unique id of the texture
  30511. */
  30512. uniqueId: number;
  30513. /**
  30514. * Define the name of the texture.
  30515. */
  30516. name: string;
  30517. /**
  30518. * Gets or sets an object used to store user defined information.
  30519. */
  30520. metadata: any;
  30521. /**
  30522. * For internal use only. Please do not use.
  30523. */
  30524. reservedDataStore: any;
  30525. private _hasAlpha;
  30526. /**
  30527. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30528. */
  30529. set hasAlpha(value: boolean);
  30530. get hasAlpha(): boolean;
  30531. /**
  30532. * Defines if the alpha value should be determined via the rgb values.
  30533. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30534. */
  30535. getAlphaFromRGB: boolean;
  30536. /**
  30537. * Intensity or strength of the texture.
  30538. * It is commonly used by materials to fine tune the intensity of the texture
  30539. */
  30540. level: number;
  30541. /**
  30542. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30543. * This is part of the texture as textures usually maps to one uv set.
  30544. */
  30545. coordinatesIndex: number;
  30546. private _coordinatesMode;
  30547. /**
  30548. * How a texture is mapped.
  30549. *
  30550. * | Value | Type | Description |
  30551. * | ----- | ----------------------------------- | ----------- |
  30552. * | 0 | EXPLICIT_MODE | |
  30553. * | 1 | SPHERICAL_MODE | |
  30554. * | 2 | PLANAR_MODE | |
  30555. * | 3 | CUBIC_MODE | |
  30556. * | 4 | PROJECTION_MODE | |
  30557. * | 5 | SKYBOX_MODE | |
  30558. * | 6 | INVCUBIC_MODE | |
  30559. * | 7 | EQUIRECTANGULAR_MODE | |
  30560. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30561. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30562. */
  30563. set coordinatesMode(value: number);
  30564. get coordinatesMode(): number;
  30565. /**
  30566. * | Value | Type | Description |
  30567. * | ----- | ------------------ | ----------- |
  30568. * | 0 | CLAMP_ADDRESSMODE | |
  30569. * | 1 | WRAP_ADDRESSMODE | |
  30570. * | 2 | MIRROR_ADDRESSMODE | |
  30571. */
  30572. wrapU: number;
  30573. /**
  30574. * | Value | Type | Description |
  30575. * | ----- | ------------------ | ----------- |
  30576. * | 0 | CLAMP_ADDRESSMODE | |
  30577. * | 1 | WRAP_ADDRESSMODE | |
  30578. * | 2 | MIRROR_ADDRESSMODE | |
  30579. */
  30580. wrapV: number;
  30581. /**
  30582. * | Value | Type | Description |
  30583. * | ----- | ------------------ | ----------- |
  30584. * | 0 | CLAMP_ADDRESSMODE | |
  30585. * | 1 | WRAP_ADDRESSMODE | |
  30586. * | 2 | MIRROR_ADDRESSMODE | |
  30587. */
  30588. wrapR: number;
  30589. /**
  30590. * With compliant hardware and browser (supporting anisotropic filtering)
  30591. * this defines the level of anisotropic filtering in the texture.
  30592. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30593. */
  30594. anisotropicFilteringLevel: number;
  30595. /**
  30596. * Define if the texture is a cube texture or if false a 2d texture.
  30597. */
  30598. get isCube(): boolean;
  30599. set isCube(value: boolean);
  30600. /**
  30601. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30602. */
  30603. get is3D(): boolean;
  30604. set is3D(value: boolean);
  30605. /**
  30606. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30607. */
  30608. get is2DArray(): boolean;
  30609. set is2DArray(value: boolean);
  30610. /**
  30611. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30612. * HDR texture are usually stored in linear space.
  30613. * This only impacts the PBR and Background materials
  30614. */
  30615. gammaSpace: boolean;
  30616. /**
  30617. * Gets or sets whether or not the texture contains RGBD data.
  30618. */
  30619. get isRGBD(): boolean;
  30620. set isRGBD(value: boolean);
  30621. /**
  30622. * Is Z inverted in the texture (useful in a cube texture).
  30623. */
  30624. invertZ: boolean;
  30625. /**
  30626. * Are mip maps generated for this texture or not.
  30627. */
  30628. get noMipmap(): boolean;
  30629. /**
  30630. * @hidden
  30631. */
  30632. lodLevelInAlpha: boolean;
  30633. /**
  30634. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30635. */
  30636. get lodGenerationOffset(): number;
  30637. set lodGenerationOffset(value: number);
  30638. /**
  30639. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30640. */
  30641. get lodGenerationScale(): number;
  30642. set lodGenerationScale(value: number);
  30643. /**
  30644. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30645. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30646. * average roughness values.
  30647. */
  30648. get linearSpecularLOD(): boolean;
  30649. set linearSpecularLOD(value: boolean);
  30650. /**
  30651. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30652. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30653. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30654. */
  30655. get irradianceTexture(): Nullable<BaseTexture>;
  30656. set irradianceTexture(value: Nullable<BaseTexture>);
  30657. /**
  30658. * Define if the texture is a render target.
  30659. */
  30660. isRenderTarget: boolean;
  30661. /**
  30662. * Define the unique id of the texture in the scene.
  30663. */
  30664. get uid(): string;
  30665. /**
  30666. * Return a string representation of the texture.
  30667. * @returns the texture as a string
  30668. */
  30669. toString(): string;
  30670. /**
  30671. * Get the class name of the texture.
  30672. * @returns "BaseTexture"
  30673. */
  30674. getClassName(): string;
  30675. /**
  30676. * Define the list of animation attached to the texture.
  30677. */
  30678. animations: import("babylonjs/Animations/animation").Animation[];
  30679. /**
  30680. * An event triggered when the texture is disposed.
  30681. */
  30682. onDisposeObservable: Observable<BaseTexture>;
  30683. private _onDisposeObserver;
  30684. /**
  30685. * Callback triggered when the texture has been disposed.
  30686. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30687. */
  30688. set onDispose(callback: () => void);
  30689. /**
  30690. * Define the current state of the loading sequence when in delayed load mode.
  30691. */
  30692. delayLoadState: number;
  30693. private _scene;
  30694. /** @hidden */
  30695. _texture: Nullable<InternalTexture>;
  30696. private _uid;
  30697. /**
  30698. * Define if the texture is preventinga material to render or not.
  30699. * If not and the texture is not ready, the engine will use a default black texture instead.
  30700. */
  30701. get isBlocking(): boolean;
  30702. /**
  30703. * Instantiates a new BaseTexture.
  30704. * Base class of all the textures in babylon.
  30705. * It groups all the common properties the materials, post process, lights... might need
  30706. * in order to make a correct use of the texture.
  30707. * @param scene Define the scene the texture blongs to
  30708. */
  30709. constructor(scene: Nullable<Scene>);
  30710. /**
  30711. * Get the scene the texture belongs to.
  30712. * @returns the scene or null if undefined
  30713. */
  30714. getScene(): Nullable<Scene>;
  30715. /**
  30716. * Get the texture transform matrix used to offset tile the texture for istance.
  30717. * @returns the transformation matrix
  30718. */
  30719. getTextureMatrix(): Matrix;
  30720. /**
  30721. * Get the texture reflection matrix used to rotate/transform the reflection.
  30722. * @returns the reflection matrix
  30723. */
  30724. getReflectionTextureMatrix(): Matrix;
  30725. /**
  30726. * Get the underlying lower level texture from Babylon.
  30727. * @returns the insternal texture
  30728. */
  30729. getInternalTexture(): Nullable<InternalTexture>;
  30730. /**
  30731. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30732. * @returns true if ready or not blocking
  30733. */
  30734. isReadyOrNotBlocking(): boolean;
  30735. /**
  30736. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30737. * @returns true if fully ready
  30738. */
  30739. isReady(): boolean;
  30740. private _cachedSize;
  30741. /**
  30742. * Get the size of the texture.
  30743. * @returns the texture size.
  30744. */
  30745. getSize(): ISize;
  30746. /**
  30747. * Get the base size of the texture.
  30748. * It can be different from the size if the texture has been resized for POT for instance
  30749. * @returns the base size
  30750. */
  30751. getBaseSize(): ISize;
  30752. /**
  30753. * Update the sampling mode of the texture.
  30754. * Default is Trilinear mode.
  30755. *
  30756. * | Value | Type | Description |
  30757. * | ----- | ------------------ | ----------- |
  30758. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30759. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30760. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30761. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30762. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30763. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30764. * | 7 | NEAREST_LINEAR | |
  30765. * | 8 | NEAREST_NEAREST | |
  30766. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30767. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30768. * | 11 | LINEAR_LINEAR | |
  30769. * | 12 | LINEAR_NEAREST | |
  30770. *
  30771. * > _mag_: magnification filter (close to the viewer)
  30772. * > _min_: minification filter (far from the viewer)
  30773. * > _mip_: filter used between mip map levels
  30774. *@param samplingMode Define the new sampling mode of the texture
  30775. */
  30776. updateSamplingMode(samplingMode: number): void;
  30777. /**
  30778. * Scales the texture if is `canRescale()`
  30779. * @param ratio the resize factor we want to use to rescale
  30780. */
  30781. scale(ratio: number): void;
  30782. /**
  30783. * Get if the texture can rescale.
  30784. */
  30785. get canRescale(): boolean;
  30786. /** @hidden */
  30787. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30788. /** @hidden */
  30789. _rebuild(): void;
  30790. /**
  30791. * Triggers the load sequence in delayed load mode.
  30792. */
  30793. delayLoad(): void;
  30794. /**
  30795. * Clones the texture.
  30796. * @returns the cloned texture
  30797. */
  30798. clone(): Nullable<BaseTexture>;
  30799. /**
  30800. * Get the texture underlying type (INT, FLOAT...)
  30801. */
  30802. get textureType(): number;
  30803. /**
  30804. * Get the texture underlying format (RGB, RGBA...)
  30805. */
  30806. get textureFormat(): number;
  30807. /**
  30808. * Indicates that textures need to be re-calculated for all materials
  30809. */
  30810. protected _markAllSubMeshesAsTexturesDirty(): void;
  30811. /**
  30812. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30813. * This will returns an RGBA array buffer containing either in values (0-255) or
  30814. * float values (0-1) depending of the underlying buffer type.
  30815. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30816. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30817. * @param buffer defines a user defined buffer to fill with data (can be null)
  30818. * @returns The Array buffer containing the pixels data.
  30819. */
  30820. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30821. /**
  30822. * Release and destroy the underlying lower level texture aka internalTexture.
  30823. */
  30824. releaseInternalTexture(): void;
  30825. /** @hidden */
  30826. get _lodTextureHigh(): Nullable<BaseTexture>;
  30827. /** @hidden */
  30828. get _lodTextureMid(): Nullable<BaseTexture>;
  30829. /** @hidden */
  30830. get _lodTextureLow(): Nullable<BaseTexture>;
  30831. /**
  30832. * Dispose the texture and release its associated resources.
  30833. */
  30834. dispose(): void;
  30835. /**
  30836. * Serialize the texture into a JSON representation that can be parsed later on.
  30837. * @returns the JSON representation of the texture
  30838. */
  30839. serialize(): any;
  30840. /**
  30841. * Helper function to be called back once a list of texture contains only ready textures.
  30842. * @param textures Define the list of textures to wait for
  30843. * @param callback Define the callback triggered once the entire list will be ready
  30844. */
  30845. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30846. }
  30847. }
  30848. declare module "babylonjs/Materials/effect" {
  30849. import { Observable } from "babylonjs/Misc/observable";
  30850. import { Nullable } from "babylonjs/types";
  30851. import { IDisposable } from "babylonjs/scene";
  30852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30854. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30855. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30856. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30857. import { Engine } from "babylonjs/Engines/engine";
  30858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30861. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30862. /**
  30863. * Options to be used when creating an effect.
  30864. */
  30865. export interface IEffectCreationOptions {
  30866. /**
  30867. * Atrributes that will be used in the shader.
  30868. */
  30869. attributes: string[];
  30870. /**
  30871. * Uniform varible names that will be set in the shader.
  30872. */
  30873. uniformsNames: string[];
  30874. /**
  30875. * Uniform buffer variable names that will be set in the shader.
  30876. */
  30877. uniformBuffersNames: string[];
  30878. /**
  30879. * Sampler texture variable names that will be set in the shader.
  30880. */
  30881. samplers: string[];
  30882. /**
  30883. * Define statements that will be set in the shader.
  30884. */
  30885. defines: any;
  30886. /**
  30887. * Possible fallbacks for this effect to improve performance when needed.
  30888. */
  30889. fallbacks: Nullable<IEffectFallbacks>;
  30890. /**
  30891. * Callback that will be called when the shader is compiled.
  30892. */
  30893. onCompiled: Nullable<(effect: Effect) => void>;
  30894. /**
  30895. * Callback that will be called if an error occurs during shader compilation.
  30896. */
  30897. onError: Nullable<(effect: Effect, errors: string) => void>;
  30898. /**
  30899. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30900. */
  30901. indexParameters?: any;
  30902. /**
  30903. * Max number of lights that can be used in the shader.
  30904. */
  30905. maxSimultaneousLights?: number;
  30906. /**
  30907. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30908. */
  30909. transformFeedbackVaryings?: Nullable<string[]>;
  30910. }
  30911. /**
  30912. * Effect containing vertex and fragment shader that can be executed on an object.
  30913. */
  30914. export class Effect implements IDisposable {
  30915. /**
  30916. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30917. */
  30918. static ShadersRepository: string;
  30919. /**
  30920. * Name of the effect.
  30921. */
  30922. name: any;
  30923. /**
  30924. * String container all the define statements that should be set on the shader.
  30925. */
  30926. defines: string;
  30927. /**
  30928. * Callback that will be called when the shader is compiled.
  30929. */
  30930. onCompiled: Nullable<(effect: Effect) => void>;
  30931. /**
  30932. * Callback that will be called if an error occurs during shader compilation.
  30933. */
  30934. onError: Nullable<(effect: Effect, errors: string) => void>;
  30935. /**
  30936. * Callback that will be called when effect is bound.
  30937. */
  30938. onBind: Nullable<(effect: Effect) => void>;
  30939. /**
  30940. * Unique ID of the effect.
  30941. */
  30942. uniqueId: number;
  30943. /**
  30944. * Observable that will be called when the shader is compiled.
  30945. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30946. */
  30947. onCompileObservable: Observable<Effect>;
  30948. /**
  30949. * Observable that will be called if an error occurs during shader compilation.
  30950. */
  30951. onErrorObservable: Observable<Effect>;
  30952. /** @hidden */
  30953. _onBindObservable: Nullable<Observable<Effect>>;
  30954. /**
  30955. * @hidden
  30956. * Specifies if the effect was previously ready
  30957. */
  30958. _wasPreviouslyReady: boolean;
  30959. /**
  30960. * Observable that will be called when effect is bound.
  30961. */
  30962. get onBindObservable(): Observable<Effect>;
  30963. /** @hidden */
  30964. _bonesComputationForcedToCPU: boolean;
  30965. private static _uniqueIdSeed;
  30966. private _engine;
  30967. private _uniformBuffersNames;
  30968. private _uniformsNames;
  30969. private _samplerList;
  30970. private _samplers;
  30971. private _isReady;
  30972. private _compilationError;
  30973. private _allFallbacksProcessed;
  30974. private _attributesNames;
  30975. private _attributes;
  30976. private _attributeLocationByName;
  30977. private _uniforms;
  30978. /**
  30979. * Key for the effect.
  30980. * @hidden
  30981. */
  30982. _key: string;
  30983. private _indexParameters;
  30984. private _fallbacks;
  30985. private _vertexSourceCode;
  30986. private _fragmentSourceCode;
  30987. private _vertexSourceCodeOverride;
  30988. private _fragmentSourceCodeOverride;
  30989. private _transformFeedbackVaryings;
  30990. /**
  30991. * Compiled shader to webGL program.
  30992. * @hidden
  30993. */
  30994. _pipelineContext: Nullable<IPipelineContext>;
  30995. private _valueCache;
  30996. private static _baseCache;
  30997. /**
  30998. * Instantiates an effect.
  30999. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31000. * @param baseName Name of the effect.
  31001. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31002. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31003. * @param samplers List of sampler variables that will be passed to the shader.
  31004. * @param engine Engine to be used to render the effect
  31005. * @param defines Define statements to be added to the shader.
  31006. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31007. * @param onCompiled Callback that will be called when the shader is compiled.
  31008. * @param onError Callback that will be called if an error occurs during shader compilation.
  31009. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31010. */
  31011. 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);
  31012. private _useFinalCode;
  31013. /**
  31014. * Unique key for this effect
  31015. */
  31016. get key(): string;
  31017. /**
  31018. * If the effect has been compiled and prepared.
  31019. * @returns if the effect is compiled and prepared.
  31020. */
  31021. isReady(): boolean;
  31022. private _isReadyInternal;
  31023. /**
  31024. * The engine the effect was initialized with.
  31025. * @returns the engine.
  31026. */
  31027. getEngine(): Engine;
  31028. /**
  31029. * The pipeline context for this effect
  31030. * @returns the associated pipeline context
  31031. */
  31032. getPipelineContext(): Nullable<IPipelineContext>;
  31033. /**
  31034. * The set of names of attribute variables for the shader.
  31035. * @returns An array of attribute names.
  31036. */
  31037. getAttributesNames(): string[];
  31038. /**
  31039. * Returns the attribute at the given index.
  31040. * @param index The index of the attribute.
  31041. * @returns The location of the attribute.
  31042. */
  31043. getAttributeLocation(index: number): number;
  31044. /**
  31045. * Returns the attribute based on the name of the variable.
  31046. * @param name of the attribute to look up.
  31047. * @returns the attribute location.
  31048. */
  31049. getAttributeLocationByName(name: string): number;
  31050. /**
  31051. * The number of attributes.
  31052. * @returns the numnber of attributes.
  31053. */
  31054. getAttributesCount(): number;
  31055. /**
  31056. * Gets the index of a uniform variable.
  31057. * @param uniformName of the uniform to look up.
  31058. * @returns the index.
  31059. */
  31060. getUniformIndex(uniformName: string): number;
  31061. /**
  31062. * Returns the attribute based on the name of the variable.
  31063. * @param uniformName of the uniform to look up.
  31064. * @returns the location of the uniform.
  31065. */
  31066. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31067. /**
  31068. * Returns an array of sampler variable names
  31069. * @returns The array of sampler variable neames.
  31070. */
  31071. getSamplers(): string[];
  31072. /**
  31073. * The error from the last compilation.
  31074. * @returns the error string.
  31075. */
  31076. getCompilationError(): string;
  31077. /**
  31078. * Gets a boolean indicating that all fallbacks were used during compilation
  31079. * @returns true if all fallbacks were used
  31080. */
  31081. allFallbacksProcessed(): boolean;
  31082. /**
  31083. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31084. * @param func The callback to be used.
  31085. */
  31086. executeWhenCompiled(func: (effect: Effect) => void): void;
  31087. private _checkIsReady;
  31088. private _loadShader;
  31089. /**
  31090. * Recompiles the webGL program
  31091. * @param vertexSourceCode The source code for the vertex shader.
  31092. * @param fragmentSourceCode The source code for the fragment shader.
  31093. * @param onCompiled Callback called when completed.
  31094. * @param onError Callback called on error.
  31095. * @hidden
  31096. */
  31097. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31098. /**
  31099. * Prepares the effect
  31100. * @hidden
  31101. */
  31102. _prepareEffect(): void;
  31103. private _processCompilationErrors;
  31104. /**
  31105. * Checks if the effect is supported. (Must be called after compilation)
  31106. */
  31107. get isSupported(): boolean;
  31108. /**
  31109. * Binds a texture to the engine to be used as output of the shader.
  31110. * @param channel Name of the output variable.
  31111. * @param texture Texture to bind.
  31112. * @hidden
  31113. */
  31114. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31115. /**
  31116. * Sets a texture on the engine to be used in the shader.
  31117. * @param channel Name of the sampler variable.
  31118. * @param texture Texture to set.
  31119. */
  31120. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31121. /**
  31122. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31123. * @param channel Name of the sampler variable.
  31124. * @param texture Texture to set.
  31125. */
  31126. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31127. /**
  31128. * Sets an array of textures on the engine to be used in the shader.
  31129. * @param channel Name of the variable.
  31130. * @param textures Textures to set.
  31131. */
  31132. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31133. /**
  31134. * 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)
  31135. * @param channel Name of the sampler variable.
  31136. * @param postProcess Post process to get the input texture from.
  31137. */
  31138. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31139. /**
  31140. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31141. * 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)
  31142. * @param channel Name of the sampler variable.
  31143. * @param postProcess Post process to get the output texture from.
  31144. */
  31145. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31146. /** @hidden */
  31147. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31148. /** @hidden */
  31149. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31150. /** @hidden */
  31151. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31152. /** @hidden */
  31153. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31154. /**
  31155. * Binds a buffer to a uniform.
  31156. * @param buffer Buffer to bind.
  31157. * @param name Name of the uniform variable to bind to.
  31158. */
  31159. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31160. /**
  31161. * Binds block to a uniform.
  31162. * @param blockName Name of the block to bind.
  31163. * @param index Index to bind.
  31164. */
  31165. bindUniformBlock(blockName: string, index: number): void;
  31166. /**
  31167. * Sets an interger value on a uniform variable.
  31168. * @param uniformName Name of the variable.
  31169. * @param value Value to be set.
  31170. * @returns this effect.
  31171. */
  31172. setInt(uniformName: string, value: number): Effect;
  31173. /**
  31174. * Sets an int array on a uniform variable.
  31175. * @param uniformName Name of the variable.
  31176. * @param array array to be set.
  31177. * @returns this effect.
  31178. */
  31179. setIntArray(uniformName: string, array: Int32Array): Effect;
  31180. /**
  31181. * 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)
  31182. * @param uniformName Name of the variable.
  31183. * @param array array to be set.
  31184. * @returns this effect.
  31185. */
  31186. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31187. /**
  31188. * 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)
  31189. * @param uniformName Name of the variable.
  31190. * @param array array to be set.
  31191. * @returns this effect.
  31192. */
  31193. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31194. /**
  31195. * 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)
  31196. * @param uniformName Name of the variable.
  31197. * @param array array to be set.
  31198. * @returns this effect.
  31199. */
  31200. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31201. /**
  31202. * Sets an float array on a uniform variable.
  31203. * @param uniformName Name of the variable.
  31204. * @param array array to be set.
  31205. * @returns this effect.
  31206. */
  31207. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31208. /**
  31209. * 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)
  31210. * @param uniformName Name of the variable.
  31211. * @param array array to be set.
  31212. * @returns this effect.
  31213. */
  31214. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31215. /**
  31216. * 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)
  31217. * @param uniformName Name of the variable.
  31218. * @param array array to be set.
  31219. * @returns this effect.
  31220. */
  31221. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31222. /**
  31223. * 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)
  31224. * @param uniformName Name of the variable.
  31225. * @param array array to be set.
  31226. * @returns this effect.
  31227. */
  31228. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31229. /**
  31230. * Sets an array on a uniform variable.
  31231. * @param uniformName Name of the variable.
  31232. * @param array array to be set.
  31233. * @returns this effect.
  31234. */
  31235. setArray(uniformName: string, array: number[]): Effect;
  31236. /**
  31237. * 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)
  31238. * @param uniformName Name of the variable.
  31239. * @param array array to be set.
  31240. * @returns this effect.
  31241. */
  31242. setArray2(uniformName: string, array: number[]): Effect;
  31243. /**
  31244. * 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)
  31245. * @param uniformName Name of the variable.
  31246. * @param array array to be set.
  31247. * @returns this effect.
  31248. */
  31249. setArray3(uniformName: string, array: number[]): Effect;
  31250. /**
  31251. * 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)
  31252. * @param uniformName Name of the variable.
  31253. * @param array array to be set.
  31254. * @returns this effect.
  31255. */
  31256. setArray4(uniformName: string, array: number[]): Effect;
  31257. /**
  31258. * Sets matrices on a uniform variable.
  31259. * @param uniformName Name of the variable.
  31260. * @param matrices matrices to be set.
  31261. * @returns this effect.
  31262. */
  31263. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31264. /**
  31265. * Sets matrix on a uniform variable.
  31266. * @param uniformName Name of the variable.
  31267. * @param matrix matrix to be set.
  31268. * @returns this effect.
  31269. */
  31270. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31271. /**
  31272. * 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)
  31273. * @param uniformName Name of the variable.
  31274. * @param matrix matrix to be set.
  31275. * @returns this effect.
  31276. */
  31277. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31278. /**
  31279. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31280. * @param uniformName Name of the variable.
  31281. * @param matrix matrix to be set.
  31282. * @returns this effect.
  31283. */
  31284. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31285. /**
  31286. * Sets a float on a uniform variable.
  31287. * @param uniformName Name of the variable.
  31288. * @param value value to be set.
  31289. * @returns this effect.
  31290. */
  31291. setFloat(uniformName: string, value: number): Effect;
  31292. /**
  31293. * Sets a boolean on a uniform variable.
  31294. * @param uniformName Name of the variable.
  31295. * @param bool value to be set.
  31296. * @returns this effect.
  31297. */
  31298. setBool(uniformName: string, bool: boolean): Effect;
  31299. /**
  31300. * Sets a Vector2 on a uniform variable.
  31301. * @param uniformName Name of the variable.
  31302. * @param vector2 vector2 to be set.
  31303. * @returns this effect.
  31304. */
  31305. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31306. /**
  31307. * Sets a float2 on a uniform variable.
  31308. * @param uniformName Name of the variable.
  31309. * @param x First float in float2.
  31310. * @param y Second float in float2.
  31311. * @returns this effect.
  31312. */
  31313. setFloat2(uniformName: string, x: number, y: number): Effect;
  31314. /**
  31315. * Sets a Vector3 on a uniform variable.
  31316. * @param uniformName Name of the variable.
  31317. * @param vector3 Value to be set.
  31318. * @returns this effect.
  31319. */
  31320. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31321. /**
  31322. * Sets a float3 on a uniform variable.
  31323. * @param uniformName Name of the variable.
  31324. * @param x First float in float3.
  31325. * @param y Second float in float3.
  31326. * @param z Third float in float3.
  31327. * @returns this effect.
  31328. */
  31329. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31330. /**
  31331. * Sets a Vector4 on a uniform variable.
  31332. * @param uniformName Name of the variable.
  31333. * @param vector4 Value to be set.
  31334. * @returns this effect.
  31335. */
  31336. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31337. /**
  31338. * Sets a float4 on a uniform variable.
  31339. * @param uniformName Name of the variable.
  31340. * @param x First float in float4.
  31341. * @param y Second float in float4.
  31342. * @param z Third float in float4.
  31343. * @param w Fourth float in float4.
  31344. * @returns this effect.
  31345. */
  31346. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31347. /**
  31348. * Sets a Color3 on a uniform variable.
  31349. * @param uniformName Name of the variable.
  31350. * @param color3 Value to be set.
  31351. * @returns this effect.
  31352. */
  31353. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31354. /**
  31355. * Sets a Color4 on a uniform variable.
  31356. * @param uniformName Name of the variable.
  31357. * @param color3 Value to be set.
  31358. * @param alpha Alpha value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31362. /**
  31363. * Sets a Color4 on a uniform variable
  31364. * @param uniformName defines the name of the variable
  31365. * @param color4 defines the value to be set
  31366. * @returns this effect.
  31367. */
  31368. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31369. /** Release all associated resources */
  31370. dispose(): void;
  31371. /**
  31372. * This function will add a new shader to the shader store
  31373. * @param name the name of the shader
  31374. * @param pixelShader optional pixel shader content
  31375. * @param vertexShader optional vertex shader content
  31376. */
  31377. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31378. /**
  31379. * Store of each shader (The can be looked up using effect.key)
  31380. */
  31381. static ShadersStore: {
  31382. [key: string]: string;
  31383. };
  31384. /**
  31385. * Store of each included file for a shader (The can be looked up using effect.key)
  31386. */
  31387. static IncludesShadersStore: {
  31388. [key: string]: string;
  31389. };
  31390. /**
  31391. * Resets the cache of effects.
  31392. */
  31393. static ResetCache(): void;
  31394. }
  31395. }
  31396. declare module "babylonjs/Engines/engineCapabilities" {
  31397. /**
  31398. * Interface used to describe the capabilities of the engine relatively to the current browser
  31399. */
  31400. export interface EngineCapabilities {
  31401. /** Maximum textures units per fragment shader */
  31402. maxTexturesImageUnits: number;
  31403. /** Maximum texture units per vertex shader */
  31404. maxVertexTextureImageUnits: number;
  31405. /** Maximum textures units in the entire pipeline */
  31406. maxCombinedTexturesImageUnits: number;
  31407. /** Maximum texture size */
  31408. maxTextureSize: number;
  31409. /** Maximum texture samples */
  31410. maxSamples?: number;
  31411. /** Maximum cube texture size */
  31412. maxCubemapTextureSize: number;
  31413. /** Maximum render texture size */
  31414. maxRenderTextureSize: number;
  31415. /** Maximum number of vertex attributes */
  31416. maxVertexAttribs: number;
  31417. /** Maximum number of varyings */
  31418. maxVaryingVectors: number;
  31419. /** Maximum number of uniforms per vertex shader */
  31420. maxVertexUniformVectors: number;
  31421. /** Maximum number of uniforms per fragment shader */
  31422. maxFragmentUniformVectors: number;
  31423. /** Defines if standard derivates (dx/dy) are supported */
  31424. standardDerivatives: boolean;
  31425. /** Defines if s3tc texture compression is supported */
  31426. s3tc?: WEBGL_compressed_texture_s3tc;
  31427. /** Defines if pvrtc texture compression is supported */
  31428. pvrtc: any;
  31429. /** Defines if etc1 texture compression is supported */
  31430. etc1: any;
  31431. /** Defines if etc2 texture compression is supported */
  31432. etc2: any;
  31433. /** Defines if astc texture compression is supported */
  31434. astc: any;
  31435. /** Defines if float textures are supported */
  31436. textureFloat: boolean;
  31437. /** Defines if vertex array objects are supported */
  31438. vertexArrayObject: boolean;
  31439. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31440. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31441. /** Gets the maximum level of anisotropy supported */
  31442. maxAnisotropy: number;
  31443. /** Defines if instancing is supported */
  31444. instancedArrays: boolean;
  31445. /** Defines if 32 bits indices are supported */
  31446. uintIndices: boolean;
  31447. /** Defines if high precision shaders are supported */
  31448. highPrecisionShaderSupported: boolean;
  31449. /** Defines if depth reading in the fragment shader is supported */
  31450. fragmentDepthSupported: boolean;
  31451. /** Defines if float texture linear filtering is supported*/
  31452. textureFloatLinearFiltering: boolean;
  31453. /** Defines if rendering to float textures is supported */
  31454. textureFloatRender: boolean;
  31455. /** Defines if half float textures are supported*/
  31456. textureHalfFloat: boolean;
  31457. /** Defines if half float texture linear filtering is supported*/
  31458. textureHalfFloatLinearFiltering: boolean;
  31459. /** Defines if rendering to half float textures is supported */
  31460. textureHalfFloatRender: boolean;
  31461. /** Defines if textureLOD shader command is supported */
  31462. textureLOD: boolean;
  31463. /** Defines if draw buffers extension is supported */
  31464. drawBuffersExtension: boolean;
  31465. /** Defines if depth textures are supported */
  31466. depthTextureExtension: boolean;
  31467. /** Defines if float color buffer are supported */
  31468. colorBufferFloat: boolean;
  31469. /** Gets disjoint timer query extension (null if not supported) */
  31470. timerQuery?: EXT_disjoint_timer_query;
  31471. /** Defines if timestamp can be used with timer query */
  31472. canUseTimestampForTimerQuery: boolean;
  31473. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31474. multiview?: any;
  31475. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31476. oculusMultiview?: any;
  31477. /** Function used to let the system compiles shaders in background */
  31478. parallelShaderCompile?: {
  31479. COMPLETION_STATUS_KHR: number;
  31480. };
  31481. /** Max number of texture samples for MSAA */
  31482. maxMSAASamples: number;
  31483. /** Defines if the blend min max extension is supported */
  31484. blendMinMax: boolean;
  31485. }
  31486. }
  31487. declare module "babylonjs/States/depthCullingState" {
  31488. import { Nullable } from "babylonjs/types";
  31489. /**
  31490. * @hidden
  31491. **/
  31492. export class DepthCullingState {
  31493. private _isDepthTestDirty;
  31494. private _isDepthMaskDirty;
  31495. private _isDepthFuncDirty;
  31496. private _isCullFaceDirty;
  31497. private _isCullDirty;
  31498. private _isZOffsetDirty;
  31499. private _isFrontFaceDirty;
  31500. private _depthTest;
  31501. private _depthMask;
  31502. private _depthFunc;
  31503. private _cull;
  31504. private _cullFace;
  31505. private _zOffset;
  31506. private _frontFace;
  31507. /**
  31508. * Initializes the state.
  31509. */
  31510. constructor();
  31511. get isDirty(): boolean;
  31512. get zOffset(): number;
  31513. set zOffset(value: number);
  31514. get cullFace(): Nullable<number>;
  31515. set cullFace(value: Nullable<number>);
  31516. get cull(): Nullable<boolean>;
  31517. set cull(value: Nullable<boolean>);
  31518. get depthFunc(): Nullable<number>;
  31519. set depthFunc(value: Nullable<number>);
  31520. get depthMask(): boolean;
  31521. set depthMask(value: boolean);
  31522. get depthTest(): boolean;
  31523. set depthTest(value: boolean);
  31524. get frontFace(): Nullable<number>;
  31525. set frontFace(value: Nullable<number>);
  31526. reset(): void;
  31527. apply(gl: WebGLRenderingContext): void;
  31528. }
  31529. }
  31530. declare module "babylonjs/States/stencilState" {
  31531. /**
  31532. * @hidden
  31533. **/
  31534. export class StencilState {
  31535. /** 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 */
  31536. static readonly ALWAYS: number;
  31537. /** Passed to stencilOperation to specify that stencil value must be kept */
  31538. static readonly KEEP: number;
  31539. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31540. static readonly REPLACE: number;
  31541. private _isStencilTestDirty;
  31542. private _isStencilMaskDirty;
  31543. private _isStencilFuncDirty;
  31544. private _isStencilOpDirty;
  31545. private _stencilTest;
  31546. private _stencilMask;
  31547. private _stencilFunc;
  31548. private _stencilFuncRef;
  31549. private _stencilFuncMask;
  31550. private _stencilOpStencilFail;
  31551. private _stencilOpDepthFail;
  31552. private _stencilOpStencilDepthPass;
  31553. get isDirty(): boolean;
  31554. get stencilFunc(): number;
  31555. set stencilFunc(value: number);
  31556. get stencilFuncRef(): number;
  31557. set stencilFuncRef(value: number);
  31558. get stencilFuncMask(): number;
  31559. set stencilFuncMask(value: number);
  31560. get stencilOpStencilFail(): number;
  31561. set stencilOpStencilFail(value: number);
  31562. get stencilOpDepthFail(): number;
  31563. set stencilOpDepthFail(value: number);
  31564. get stencilOpStencilDepthPass(): number;
  31565. set stencilOpStencilDepthPass(value: number);
  31566. get stencilMask(): number;
  31567. set stencilMask(value: number);
  31568. get stencilTest(): boolean;
  31569. set stencilTest(value: boolean);
  31570. constructor();
  31571. reset(): void;
  31572. apply(gl: WebGLRenderingContext): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/States/alphaCullingState" {
  31576. /**
  31577. * @hidden
  31578. **/
  31579. export class AlphaState {
  31580. private _isAlphaBlendDirty;
  31581. private _isBlendFunctionParametersDirty;
  31582. private _isBlendEquationParametersDirty;
  31583. private _isBlendConstantsDirty;
  31584. private _alphaBlend;
  31585. private _blendFunctionParameters;
  31586. private _blendEquationParameters;
  31587. private _blendConstants;
  31588. /**
  31589. * Initializes the state.
  31590. */
  31591. constructor();
  31592. get isDirty(): boolean;
  31593. get alphaBlend(): boolean;
  31594. set alphaBlend(value: boolean);
  31595. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31596. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31597. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31598. reset(): void;
  31599. apply(gl: WebGLRenderingContext): void;
  31600. }
  31601. }
  31602. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31603. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31604. /** @hidden */
  31605. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31606. attributeProcessor(attribute: string): string;
  31607. varyingProcessor(varying: string, isFragment: boolean): string;
  31608. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31609. }
  31610. }
  31611. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31612. /**
  31613. * Interface for attribute information associated with buffer instanciation
  31614. */
  31615. export interface InstancingAttributeInfo {
  31616. /**
  31617. * Name of the GLSL attribute
  31618. * if attribute index is not specified, this is used to retrieve the index from the effect
  31619. */
  31620. attributeName: string;
  31621. /**
  31622. * Index/offset of the attribute in the vertex shader
  31623. * if not specified, this will be computes from the name.
  31624. */
  31625. index?: number;
  31626. /**
  31627. * size of the attribute, 1, 2, 3 or 4
  31628. */
  31629. attributeSize: number;
  31630. /**
  31631. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31632. */
  31633. offset: number;
  31634. /**
  31635. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31636. * default to 1
  31637. */
  31638. divisor?: number;
  31639. /**
  31640. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31641. * default is FLOAT
  31642. */
  31643. attributeType?: number;
  31644. /**
  31645. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31646. */
  31647. normalized?: boolean;
  31648. }
  31649. }
  31650. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31652. import { Nullable } from "babylonjs/types";
  31653. module "babylonjs/Engines/thinEngine" {
  31654. interface ThinEngine {
  31655. /**
  31656. * Update a video texture
  31657. * @param texture defines the texture to update
  31658. * @param video defines the video element to use
  31659. * @param invertY defines if data must be stored with Y axis inverted
  31660. */
  31661. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31662. }
  31663. }
  31664. }
  31665. declare module "babylonjs/Materials/Textures/videoTexture" {
  31666. import { Observable } from "babylonjs/Misc/observable";
  31667. import { Nullable } from "babylonjs/types";
  31668. import { Scene } from "babylonjs/scene";
  31669. import { Texture } from "babylonjs/Materials/Textures/texture";
  31670. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31671. /**
  31672. * Settings for finer control over video usage
  31673. */
  31674. export interface VideoTextureSettings {
  31675. /**
  31676. * Applies `autoplay` to video, if specified
  31677. */
  31678. autoPlay?: boolean;
  31679. /**
  31680. * Applies `loop` to video, if specified
  31681. */
  31682. loop?: boolean;
  31683. /**
  31684. * Automatically updates internal texture from video at every frame in the render loop
  31685. */
  31686. autoUpdateTexture: boolean;
  31687. /**
  31688. * Image src displayed during the video loading or until the user interacts with the video.
  31689. */
  31690. poster?: string;
  31691. }
  31692. /**
  31693. * If you want to display a video in your scene, this is the special texture for that.
  31694. * This special texture works similar to other textures, with the exception of a few parameters.
  31695. * @see https://doc.babylonjs.com/how_to/video_texture
  31696. */
  31697. export class VideoTexture extends Texture {
  31698. /**
  31699. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31700. */
  31701. readonly autoUpdateTexture: boolean;
  31702. /**
  31703. * The video instance used by the texture internally
  31704. */
  31705. readonly video: HTMLVideoElement;
  31706. private _onUserActionRequestedObservable;
  31707. /**
  31708. * Event triggerd when a dom action is required by the user to play the video.
  31709. * This happens due to recent changes in browser policies preventing video to auto start.
  31710. */
  31711. get onUserActionRequestedObservable(): Observable<Texture>;
  31712. private _generateMipMaps;
  31713. private _engine;
  31714. private _stillImageCaptured;
  31715. private _displayingPosterTexture;
  31716. private _settings;
  31717. private _createInternalTextureOnEvent;
  31718. private _frameId;
  31719. private _currentSrc;
  31720. /**
  31721. * Creates a video texture.
  31722. * If you want to display a video in your scene, this is the special texture for that.
  31723. * This special texture works similar to other textures, with the exception of a few parameters.
  31724. * @see https://doc.babylonjs.com/how_to/video_texture
  31725. * @param name optional name, will detect from video source, if not defined
  31726. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31727. * @param scene is obviously the current scene.
  31728. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31729. * @param invertY is false by default but can be used to invert video on Y axis
  31730. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31731. * @param settings allows finer control over video usage
  31732. */
  31733. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31734. private _getName;
  31735. private _getVideo;
  31736. private _createInternalTexture;
  31737. private reset;
  31738. /**
  31739. * @hidden Internal method to initiate `update`.
  31740. */
  31741. _rebuild(): void;
  31742. /**
  31743. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31744. */
  31745. update(): void;
  31746. /**
  31747. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31748. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31749. */
  31750. updateTexture(isVisible: boolean): void;
  31751. protected _updateInternalTexture: () => void;
  31752. /**
  31753. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31754. * @param url New url.
  31755. */
  31756. updateURL(url: string): void;
  31757. /**
  31758. * Clones the texture.
  31759. * @returns the cloned texture
  31760. */
  31761. clone(): VideoTexture;
  31762. /**
  31763. * Dispose the texture and release its associated resources.
  31764. */
  31765. dispose(): void;
  31766. /**
  31767. * Creates a video texture straight from a stream.
  31768. * @param scene Define the scene the texture should be created in
  31769. * @param stream Define the stream the texture should be created from
  31770. * @returns The created video texture as a promise
  31771. */
  31772. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31773. /**
  31774. * Creates a video texture straight from your WebCam video feed.
  31775. * @param scene Define the scene the texture should be created in
  31776. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31777. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31778. * @returns The created video texture as a promise
  31779. */
  31780. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31781. minWidth: number;
  31782. maxWidth: number;
  31783. minHeight: number;
  31784. maxHeight: number;
  31785. deviceId: string;
  31786. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31787. /**
  31788. * Creates a video texture straight from your WebCam video feed.
  31789. * @param scene Define the scene the texture should be created in
  31790. * @param onReady Define a callback to triggered once the texture will be ready
  31791. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31792. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31793. */
  31794. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31795. minWidth: number;
  31796. maxWidth: number;
  31797. minHeight: number;
  31798. maxHeight: number;
  31799. deviceId: string;
  31800. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31801. }
  31802. }
  31803. declare module "babylonjs/Engines/thinEngine" {
  31804. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31805. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31806. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31807. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31808. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31809. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31810. import { Observable } from "babylonjs/Misc/observable";
  31811. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31812. import { StencilState } from "babylonjs/States/stencilState";
  31813. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31815. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31816. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31817. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31818. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31819. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31820. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31821. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31823. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31824. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31825. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31826. import { WebRequest } from "babylonjs/Misc/webRequest";
  31827. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31828. /**
  31829. * Defines the interface used by objects working like Scene
  31830. * @hidden
  31831. */
  31832. interface ISceneLike {
  31833. _addPendingData(data: any): void;
  31834. _removePendingData(data: any): void;
  31835. offlineProvider: IOfflineProvider;
  31836. }
  31837. /** Interface defining initialization parameters for Engine class */
  31838. export interface EngineOptions extends WebGLContextAttributes {
  31839. /**
  31840. * Defines if the engine should no exceed a specified device ratio
  31841. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31842. */
  31843. limitDeviceRatio?: number;
  31844. /**
  31845. * Defines if webvr should be enabled automatically
  31846. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31847. */
  31848. autoEnableWebVR?: boolean;
  31849. /**
  31850. * Defines if webgl2 should be turned off even if supported
  31851. * @see http://doc.babylonjs.com/features/webgl2
  31852. */
  31853. disableWebGL2Support?: boolean;
  31854. /**
  31855. * Defines if webaudio should be initialized as well
  31856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31857. */
  31858. audioEngine?: boolean;
  31859. /**
  31860. * Defines if animations should run using a deterministic lock step
  31861. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31862. */
  31863. deterministicLockstep?: boolean;
  31864. /** Defines the maximum steps to use with deterministic lock step mode */
  31865. lockstepMaxSteps?: number;
  31866. /** Defines the seconds between each deterministic lock step */
  31867. timeStep?: number;
  31868. /**
  31869. * Defines that engine should ignore context lost events
  31870. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31871. */
  31872. doNotHandleContextLost?: boolean;
  31873. /**
  31874. * Defines that engine should ignore modifying touch action attribute and style
  31875. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31876. */
  31877. doNotHandleTouchAction?: boolean;
  31878. /**
  31879. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31880. */
  31881. useHighPrecisionFloats?: boolean;
  31882. }
  31883. /**
  31884. * The base engine class (root of all engines)
  31885. */
  31886. export class ThinEngine {
  31887. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31888. static ExceptionList: ({
  31889. key: string;
  31890. capture: string;
  31891. captureConstraint: number;
  31892. targets: string[];
  31893. } | {
  31894. key: string;
  31895. capture: null;
  31896. captureConstraint: null;
  31897. targets: string[];
  31898. })[];
  31899. /** @hidden */
  31900. static _TextureLoaders: IInternalTextureLoader[];
  31901. /**
  31902. * Returns the current npm package of the sdk
  31903. */
  31904. static get NpmPackage(): string;
  31905. /**
  31906. * Returns the current version of the framework
  31907. */
  31908. static get Version(): string;
  31909. /**
  31910. * Returns a string describing the current engine
  31911. */
  31912. get description(): string;
  31913. /**
  31914. * Gets or sets the epsilon value used by collision engine
  31915. */
  31916. static CollisionsEpsilon: number;
  31917. /**
  31918. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31919. */
  31920. static get ShadersRepository(): string;
  31921. static set ShadersRepository(value: string);
  31922. /**
  31923. * Gets or sets the textures that the engine should not attempt to load as compressed
  31924. */
  31925. protected _excludedCompressedTextures: string[];
  31926. /**
  31927. * Filters the compressed texture formats to only include
  31928. * files that are not included in the skippable list
  31929. *
  31930. * @param url the current extension
  31931. * @param textureFormatInUse the current compressed texture format
  31932. * @returns "format" string
  31933. */
  31934. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31935. /** @hidden */
  31936. _shaderProcessor: IShaderProcessor;
  31937. /**
  31938. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31939. */
  31940. forcePOTTextures: boolean;
  31941. /**
  31942. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31943. */
  31944. isFullscreen: boolean;
  31945. /**
  31946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31947. */
  31948. cullBackFaces: boolean;
  31949. /**
  31950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31951. */
  31952. renderEvenInBackground: boolean;
  31953. /**
  31954. * Gets or sets a boolean indicating that cache can be kept between frames
  31955. */
  31956. preventCacheWipeBetweenFrames: boolean;
  31957. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31958. validateShaderPrograms: boolean;
  31959. /**
  31960. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31961. * This can provide greater z depth for distant objects.
  31962. */
  31963. useReverseDepthBuffer: boolean;
  31964. /**
  31965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31966. */
  31967. disableUniformBuffers: boolean;
  31968. /** @hidden */
  31969. _uniformBuffers: UniformBuffer[];
  31970. /**
  31971. * Gets a boolean indicating that the engine supports uniform buffers
  31972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31973. */
  31974. get supportsUniformBuffers(): boolean;
  31975. /** @hidden */
  31976. _gl: WebGLRenderingContext;
  31977. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31978. protected _windowIsBackground: boolean;
  31979. protected _webGLVersion: number;
  31980. protected _creationOptions: EngineOptions;
  31981. protected _highPrecisionShadersAllowed: boolean;
  31982. /** @hidden */
  31983. get _shouldUseHighPrecisionShader(): boolean;
  31984. /**
  31985. * Gets a boolean indicating that only power of 2 textures are supported
  31986. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31987. */
  31988. get needPOTTextures(): boolean;
  31989. /** @hidden */
  31990. _badOS: boolean;
  31991. /** @hidden */
  31992. _badDesktopOS: boolean;
  31993. private _hardwareScalingLevel;
  31994. /** @hidden */
  31995. _caps: EngineCapabilities;
  31996. private _isStencilEnable;
  31997. private _glVersion;
  31998. private _glRenderer;
  31999. private _glVendor;
  32000. /** @hidden */
  32001. _videoTextureSupported: boolean;
  32002. protected _renderingQueueLaunched: boolean;
  32003. protected _activeRenderLoops: (() => void)[];
  32004. /**
  32005. * Observable signaled when a context lost event is raised
  32006. */
  32007. onContextLostObservable: Observable<ThinEngine>;
  32008. /**
  32009. * Observable signaled when a context restored event is raised
  32010. */
  32011. onContextRestoredObservable: Observable<ThinEngine>;
  32012. private _onContextLost;
  32013. private _onContextRestored;
  32014. protected _contextWasLost: boolean;
  32015. /** @hidden */
  32016. _doNotHandleContextLost: boolean;
  32017. /**
  32018. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32020. */
  32021. get doNotHandleContextLost(): boolean;
  32022. set doNotHandleContextLost(value: boolean);
  32023. /**
  32024. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32025. */
  32026. disableVertexArrayObjects: boolean;
  32027. /** @hidden */
  32028. protected _colorWrite: boolean;
  32029. /** @hidden */
  32030. protected _colorWriteChanged: boolean;
  32031. /** @hidden */
  32032. protected _depthCullingState: DepthCullingState;
  32033. /** @hidden */
  32034. protected _stencilState: StencilState;
  32035. /** @hidden */
  32036. _alphaState: AlphaState;
  32037. /** @hidden */
  32038. _alphaMode: number;
  32039. /** @hidden */
  32040. _alphaEquation: number;
  32041. /** @hidden */
  32042. _internalTexturesCache: InternalTexture[];
  32043. /** @hidden */
  32044. protected _activeChannel: number;
  32045. private _currentTextureChannel;
  32046. /** @hidden */
  32047. protected _boundTexturesCache: {
  32048. [key: string]: Nullable<InternalTexture>;
  32049. };
  32050. /** @hidden */
  32051. protected _currentEffect: Nullable<Effect>;
  32052. /** @hidden */
  32053. protected _currentProgram: Nullable<WebGLProgram>;
  32054. private _compiledEffects;
  32055. private _vertexAttribArraysEnabled;
  32056. /** @hidden */
  32057. protected _cachedViewport: Nullable<IViewportLike>;
  32058. private _cachedVertexArrayObject;
  32059. /** @hidden */
  32060. protected _cachedVertexBuffers: any;
  32061. /** @hidden */
  32062. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32063. /** @hidden */
  32064. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32065. /** @hidden */
  32066. _currentRenderTarget: Nullable<InternalTexture>;
  32067. private _uintIndicesCurrentlySet;
  32068. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32069. /** @hidden */
  32070. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32071. private _currentBufferPointers;
  32072. private _currentInstanceLocations;
  32073. private _currentInstanceBuffers;
  32074. private _textureUnits;
  32075. /** @hidden */
  32076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32077. /** @hidden */
  32078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32079. /** @hidden */
  32080. _boundRenderFunction: any;
  32081. private _vaoRecordInProgress;
  32082. private _mustWipeVertexAttributes;
  32083. private _emptyTexture;
  32084. private _emptyCubeTexture;
  32085. private _emptyTexture3D;
  32086. private _emptyTexture2DArray;
  32087. /** @hidden */
  32088. _frameHandler: number;
  32089. private _nextFreeTextureSlots;
  32090. private _maxSimultaneousTextures;
  32091. private _activeRequests;
  32092. protected _texturesSupported: string[];
  32093. /** @hidden */
  32094. _textureFormatInUse: Nullable<string>;
  32095. protected get _supportsHardwareTextureRescaling(): boolean;
  32096. /**
  32097. * Gets the list of texture formats supported
  32098. */
  32099. get texturesSupported(): Array<string>;
  32100. /**
  32101. * Gets the list of texture formats in use
  32102. */
  32103. get textureFormatInUse(): Nullable<string>;
  32104. /**
  32105. * Gets the current viewport
  32106. */
  32107. get currentViewport(): Nullable<IViewportLike>;
  32108. /**
  32109. * Gets the default empty texture
  32110. */
  32111. get emptyTexture(): InternalTexture;
  32112. /**
  32113. * Gets the default empty 3D texture
  32114. */
  32115. get emptyTexture3D(): InternalTexture;
  32116. /**
  32117. * Gets the default empty 2D array texture
  32118. */
  32119. get emptyTexture2DArray(): InternalTexture;
  32120. /**
  32121. * Gets the default empty cube texture
  32122. */
  32123. get emptyCubeTexture(): InternalTexture;
  32124. /**
  32125. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32126. */
  32127. readonly premultipliedAlpha: boolean;
  32128. /**
  32129. * Observable event triggered before each texture is initialized
  32130. */
  32131. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32132. /**
  32133. * Creates a new engine
  32134. * @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
  32135. * @param antialias defines enable antialiasing (default: false)
  32136. * @param options defines further options to be sent to the getContext() function
  32137. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32138. */
  32139. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32140. private _rebuildInternalTextures;
  32141. private _rebuildEffects;
  32142. /**
  32143. * Gets a boolean indicating if all created effects are ready
  32144. * @returns true if all effects are ready
  32145. */
  32146. areAllEffectsReady(): boolean;
  32147. protected _rebuildBuffers(): void;
  32148. private _initGLContext;
  32149. /**
  32150. * Gets version of the current webGL context
  32151. */
  32152. get webGLVersion(): number;
  32153. /**
  32154. * Gets a string idenfifying the name of the class
  32155. * @returns "Engine" string
  32156. */
  32157. getClassName(): string;
  32158. /**
  32159. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32160. */
  32161. get isStencilEnable(): boolean;
  32162. /** @hidden */
  32163. _prepareWorkingCanvas(): void;
  32164. /**
  32165. * Reset the texture cache to empty state
  32166. */
  32167. resetTextureCache(): void;
  32168. /**
  32169. * Gets an object containing information about the current webGL context
  32170. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32171. */
  32172. getGlInfo(): {
  32173. vendor: string;
  32174. renderer: string;
  32175. version: string;
  32176. };
  32177. /**
  32178. * Defines the hardware scaling level.
  32179. * By default the hardware scaling level is computed from the window device ratio.
  32180. * 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.
  32181. * @param level defines the level to use
  32182. */
  32183. setHardwareScalingLevel(level: number): void;
  32184. /**
  32185. * Gets the current hardware scaling level.
  32186. * By default the hardware scaling level is computed from the window device ratio.
  32187. * 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.
  32188. * @returns a number indicating the current hardware scaling level
  32189. */
  32190. getHardwareScalingLevel(): number;
  32191. /**
  32192. * Gets the list of loaded textures
  32193. * @returns an array containing all loaded textures
  32194. */
  32195. getLoadedTexturesCache(): InternalTexture[];
  32196. /**
  32197. * Gets the object containing all engine capabilities
  32198. * @returns the EngineCapabilities object
  32199. */
  32200. getCaps(): EngineCapabilities;
  32201. /**
  32202. * stop executing a render loop function and remove it from the execution array
  32203. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32204. */
  32205. stopRenderLoop(renderFunction?: () => void): void;
  32206. /** @hidden */
  32207. _renderLoop(): void;
  32208. /**
  32209. * Gets the HTML canvas attached with the current webGL context
  32210. * @returns a HTML canvas
  32211. */
  32212. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32213. /**
  32214. * Gets host window
  32215. * @returns the host window object
  32216. */
  32217. getHostWindow(): Nullable<Window>;
  32218. /**
  32219. * Gets the current render width
  32220. * @param useScreen defines if screen size must be used (or the current render target if any)
  32221. * @returns a number defining the current render width
  32222. */
  32223. getRenderWidth(useScreen?: boolean): number;
  32224. /**
  32225. * Gets the current render height
  32226. * @param useScreen defines if screen size must be used (or the current render target if any)
  32227. * @returns a number defining the current render height
  32228. */
  32229. getRenderHeight(useScreen?: boolean): number;
  32230. /**
  32231. * Can be used to override the current requestAnimationFrame requester.
  32232. * @hidden
  32233. */
  32234. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32235. /**
  32236. * Register and execute a render loop. The engine can have more than one render function
  32237. * @param renderFunction defines the function to continuously execute
  32238. */
  32239. runRenderLoop(renderFunction: () => void): void;
  32240. /**
  32241. * Clear the current render buffer or the current render target (if any is set up)
  32242. * @param color defines the color to use
  32243. * @param backBuffer defines if the back buffer must be cleared
  32244. * @param depth defines if the depth buffer must be cleared
  32245. * @param stencil defines if the stencil buffer must be cleared
  32246. */
  32247. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32248. private _viewportCached;
  32249. /** @hidden */
  32250. _viewport(x: number, y: number, width: number, height: number): void;
  32251. /**
  32252. * Set the WebGL's viewport
  32253. * @param viewport defines the viewport element to be used
  32254. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32255. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32256. */
  32257. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32258. /**
  32259. * Begin a new frame
  32260. */
  32261. beginFrame(): void;
  32262. /**
  32263. * Enf the current frame
  32264. */
  32265. endFrame(): void;
  32266. /**
  32267. * Resize the view according to the canvas' size
  32268. */
  32269. resize(): void;
  32270. /**
  32271. * Force a specific size of the canvas
  32272. * @param width defines the new canvas' width
  32273. * @param height defines the new canvas' height
  32274. */
  32275. setSize(width: number, height: number): void;
  32276. /**
  32277. * Binds the frame buffer to the specified texture.
  32278. * @param texture The texture to render to or null for the default canvas
  32279. * @param faceIndex The face of the texture to render to in case of cube texture
  32280. * @param requiredWidth The width of the target to render to
  32281. * @param requiredHeight The height of the target to render to
  32282. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32283. * @param lodLevel defines the lod level to bind to the frame buffer
  32284. * @param layer defines the 2d array index to bind to frame buffer to
  32285. */
  32286. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32287. /** @hidden */
  32288. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32289. /**
  32290. * Unbind the current render target texture from the webGL context
  32291. * @param texture defines the render target texture to unbind
  32292. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32293. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32294. */
  32295. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32296. /**
  32297. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32298. */
  32299. flushFramebuffer(): void;
  32300. /**
  32301. * Unbind the current render target and bind the default framebuffer
  32302. */
  32303. restoreDefaultFramebuffer(): void;
  32304. /** @hidden */
  32305. protected _resetVertexBufferBinding(): void;
  32306. /**
  32307. * Creates a vertex buffer
  32308. * @param data the data for the vertex buffer
  32309. * @returns the new WebGL static buffer
  32310. */
  32311. createVertexBuffer(data: DataArray): DataBuffer;
  32312. private _createVertexBuffer;
  32313. /**
  32314. * Creates a dynamic vertex buffer
  32315. * @param data the data for the dynamic vertex buffer
  32316. * @returns the new WebGL dynamic buffer
  32317. */
  32318. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32319. protected _resetIndexBufferBinding(): void;
  32320. /**
  32321. * Creates a new index buffer
  32322. * @param indices defines the content of the index buffer
  32323. * @param updatable defines if the index buffer must be updatable
  32324. * @returns a new webGL buffer
  32325. */
  32326. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32327. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32328. /**
  32329. * Bind a webGL buffer to the webGL context
  32330. * @param buffer defines the buffer to bind
  32331. */
  32332. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32333. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32334. private bindBuffer;
  32335. /**
  32336. * update the bound buffer with the given data
  32337. * @param data defines the data to update
  32338. */
  32339. updateArrayBuffer(data: Float32Array): void;
  32340. private _vertexAttribPointer;
  32341. /** @hidden */
  32342. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32343. private _bindVertexBuffersAttributes;
  32344. /**
  32345. * Records a vertex array object
  32346. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32347. * @param vertexBuffers defines the list of vertex buffers to store
  32348. * @param indexBuffer defines the index buffer to store
  32349. * @param effect defines the effect to store
  32350. * @returns the new vertex array object
  32351. */
  32352. recordVertexArrayObject(vertexBuffers: {
  32353. [key: string]: VertexBuffer;
  32354. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32355. /**
  32356. * Bind a specific vertex array object
  32357. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32358. * @param vertexArrayObject defines the vertex array object to bind
  32359. * @param indexBuffer defines the index buffer to bind
  32360. */
  32361. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32362. /**
  32363. * Bind webGl buffers directly to the webGL context
  32364. * @param vertexBuffer defines the vertex buffer to bind
  32365. * @param indexBuffer defines the index buffer to bind
  32366. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32367. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32368. * @param effect defines the effect associated with the vertex buffer
  32369. */
  32370. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32371. private _unbindVertexArrayObject;
  32372. /**
  32373. * Bind a list of vertex buffers to the webGL context
  32374. * @param vertexBuffers defines the list of vertex buffers to bind
  32375. * @param indexBuffer defines the index buffer to bind
  32376. * @param effect defines the effect associated with the vertex buffers
  32377. */
  32378. bindBuffers(vertexBuffers: {
  32379. [key: string]: Nullable<VertexBuffer>;
  32380. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32381. /**
  32382. * Unbind all instance attributes
  32383. */
  32384. unbindInstanceAttributes(): void;
  32385. /**
  32386. * Release and free the memory of a vertex array object
  32387. * @param vao defines the vertex array object to delete
  32388. */
  32389. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32390. /** @hidden */
  32391. _releaseBuffer(buffer: DataBuffer): boolean;
  32392. protected _deleteBuffer(buffer: DataBuffer): void;
  32393. /**
  32394. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32395. * @param instancesBuffer defines the webGL buffer to update and bind
  32396. * @param data defines the data to store in the buffer
  32397. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32398. */
  32399. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32400. /**
  32401. * Bind the content of a webGL buffer used with instantiation
  32402. * @param instancesBuffer defines the webGL buffer to bind
  32403. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32404. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32405. */
  32406. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32407. /**
  32408. * Disable the instance attribute corresponding to the name in parameter
  32409. * @param name defines the name of the attribute to disable
  32410. */
  32411. disableInstanceAttributeByName(name: string): void;
  32412. /**
  32413. * Disable the instance attribute corresponding to the location in parameter
  32414. * @param attributeLocation defines the attribute location of the attribute to disable
  32415. */
  32416. disableInstanceAttribute(attributeLocation: number): void;
  32417. /**
  32418. * Disable the attribute corresponding to the location in parameter
  32419. * @param attributeLocation defines the attribute location of the attribute to disable
  32420. */
  32421. disableAttributeByIndex(attributeLocation: number): void;
  32422. /**
  32423. * Send a draw order
  32424. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32425. * @param indexStart defines the starting index
  32426. * @param indexCount defines the number of index to draw
  32427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32428. */
  32429. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32430. /**
  32431. * Draw a list of points
  32432. * @param verticesStart defines the index of first vertex to draw
  32433. * @param verticesCount defines the count of vertices to draw
  32434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32435. */
  32436. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32437. /**
  32438. * Draw a list of unindexed primitives
  32439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32440. * @param verticesStart defines the index of first vertex to draw
  32441. * @param verticesCount defines the count of vertices to draw
  32442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32443. */
  32444. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32445. /**
  32446. * Draw a list of indexed primitives
  32447. * @param fillMode defines the primitive to use
  32448. * @param indexStart defines the starting index
  32449. * @param indexCount defines the number of index to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of unindexed primitives
  32455. * @param fillMode defines the primitive to use
  32456. * @param verticesStart defines the index of first vertex to draw
  32457. * @param verticesCount defines the count of vertices to draw
  32458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32459. */
  32460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32461. private _drawMode;
  32462. /** @hidden */
  32463. protected _reportDrawCall(): void;
  32464. /** @hidden */
  32465. _releaseEffect(effect: Effect): void;
  32466. /** @hidden */
  32467. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32468. /**
  32469. * Create a new effect (used to store vertex/fragment shaders)
  32470. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32471. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32472. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32473. * @param samplers defines an array of string used to represent textures
  32474. * @param defines defines the string containing the defines to use to compile the shaders
  32475. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32476. * @param onCompiled defines a function to call when the effect creation is successful
  32477. * @param onError defines a function to call when the effect creation has failed
  32478. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32479. * @returns the new Effect
  32480. */
  32481. 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;
  32482. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32483. private _compileShader;
  32484. private _compileRawShader;
  32485. /**
  32486. * Directly creates a webGL program
  32487. * @param pipelineContext defines the pipeline context to attach to
  32488. * @param vertexCode defines the vertex shader code to use
  32489. * @param fragmentCode defines the fragment shader code to use
  32490. * @param context defines the webGL context to use (if not set, the current one will be used)
  32491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32492. * @returns the new webGL program
  32493. */
  32494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32495. /**
  32496. * Creates a webGL program
  32497. * @param pipelineContext defines the pipeline context to attach to
  32498. * @param vertexCode defines the vertex shader code to use
  32499. * @param fragmentCode defines the fragment shader code to use
  32500. * @param defines defines the string containing the defines to use to compile the shaders
  32501. * @param context defines the webGL context to use (if not set, the current one will be used)
  32502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32503. * @returns the new webGL program
  32504. */
  32505. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32506. /**
  32507. * Creates a new pipeline context
  32508. * @returns the new pipeline
  32509. */
  32510. createPipelineContext(): IPipelineContext;
  32511. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32512. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32513. /** @hidden */
  32514. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32515. /** @hidden */
  32516. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32517. /** @hidden */
  32518. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32519. /**
  32520. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32521. * @param pipelineContext defines the pipeline context to use
  32522. * @param uniformsNames defines the list of uniform names
  32523. * @returns an array of webGL uniform locations
  32524. */
  32525. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32526. /**
  32527. * Gets the lsit of active attributes for a given webGL program
  32528. * @param pipelineContext defines the pipeline context to use
  32529. * @param attributesNames defines the list of attribute names to get
  32530. * @returns an array of indices indicating the offset of each attribute
  32531. */
  32532. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32533. /**
  32534. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32535. * @param effect defines the effect to activate
  32536. */
  32537. enableEffect(effect: Nullable<Effect>): void;
  32538. /**
  32539. * Set the value of an uniform to a number (int)
  32540. * @param uniform defines the webGL uniform location where to store the value
  32541. * @param value defines the int number to store
  32542. */
  32543. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32544. /**
  32545. * Set the value of an uniform to an array of int32
  32546. * @param uniform defines the webGL uniform location where to store the value
  32547. * @param array defines the array of int32 to store
  32548. */
  32549. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32550. /**
  32551. * Set the value of an uniform to an array of int32 (stored as vec2)
  32552. * @param uniform defines the webGL uniform location where to store the value
  32553. * @param array defines the array of int32 to store
  32554. */
  32555. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32556. /**
  32557. * Set the value of an uniform to an array of int32 (stored as vec3)
  32558. * @param uniform defines the webGL uniform location where to store the value
  32559. * @param array defines the array of int32 to store
  32560. */
  32561. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32562. /**
  32563. * Set the value of an uniform to an array of int32 (stored as vec4)
  32564. * @param uniform defines the webGL uniform location where to store the value
  32565. * @param array defines the array of int32 to store
  32566. */
  32567. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32568. /**
  32569. * Set the value of an uniform to an array of number
  32570. * @param uniform defines the webGL uniform location where to store the value
  32571. * @param array defines the array of number to store
  32572. */
  32573. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32574. /**
  32575. * Set the value of an uniform to an array of number (stored as vec2)
  32576. * @param uniform defines the webGL uniform location where to store the value
  32577. * @param array defines the array of number to store
  32578. */
  32579. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32580. /**
  32581. * Set the value of an uniform to an array of number (stored as vec3)
  32582. * @param uniform defines the webGL uniform location where to store the value
  32583. * @param array defines the array of number to store
  32584. */
  32585. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32586. /**
  32587. * Set the value of an uniform to an array of number (stored as vec4)
  32588. * @param uniform defines the webGL uniform location where to store the value
  32589. * @param array defines the array of number to store
  32590. */
  32591. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32592. /**
  32593. * Set the value of an uniform to an array of float32 (stored as matrices)
  32594. * @param uniform defines the webGL uniform location where to store the value
  32595. * @param matrices defines the array of float32 to store
  32596. */
  32597. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32598. /**
  32599. * Set the value of an uniform to a matrix (3x3)
  32600. * @param uniform defines the webGL uniform location where to store the value
  32601. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32602. */
  32603. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32604. /**
  32605. * Set the value of an uniform to a matrix (2x2)
  32606. * @param uniform defines the webGL uniform location where to store the value
  32607. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32608. */
  32609. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32610. /**
  32611. * Set the value of an uniform to a number (float)
  32612. * @param uniform defines the webGL uniform location where to store the value
  32613. * @param value defines the float number to store
  32614. */
  32615. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32616. /**
  32617. * Set the value of an uniform to a vec2
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param x defines the 1st component of the value
  32620. * @param y defines the 2nd component of the value
  32621. */
  32622. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32623. /**
  32624. * Set the value of an uniform to a vec3
  32625. * @param uniform defines the webGL uniform location where to store the value
  32626. * @param x defines the 1st component of the value
  32627. * @param y defines the 2nd component of the value
  32628. * @param z defines the 3rd component of the value
  32629. */
  32630. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32631. /**
  32632. * Set the value of an uniform to a vec4
  32633. * @param uniform defines the webGL uniform location where to store the value
  32634. * @param x defines the 1st component of the value
  32635. * @param y defines the 2nd component of the value
  32636. * @param z defines the 3rd component of the value
  32637. * @param w defines the 4th component of the value
  32638. */
  32639. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32640. /**
  32641. * Apply all cached states (depth, culling, stencil and alpha)
  32642. */
  32643. applyStates(): void;
  32644. /**
  32645. * Enable or disable color writing
  32646. * @param enable defines the state to set
  32647. */
  32648. setColorWrite(enable: boolean): void;
  32649. /**
  32650. * Gets a boolean indicating if color writing is enabled
  32651. * @returns the current color writing state
  32652. */
  32653. getColorWrite(): boolean;
  32654. /**
  32655. * Gets the depth culling state manager
  32656. */
  32657. get depthCullingState(): DepthCullingState;
  32658. /**
  32659. * Gets the alpha state manager
  32660. */
  32661. get alphaState(): AlphaState;
  32662. /**
  32663. * Gets the stencil state manager
  32664. */
  32665. get stencilState(): StencilState;
  32666. /**
  32667. * Clears the list of texture accessible through engine.
  32668. * This can help preventing texture load conflict due to name collision.
  32669. */
  32670. clearInternalTexturesCache(): void;
  32671. /**
  32672. * Force the entire cache to be cleared
  32673. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32674. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32675. */
  32676. wipeCaches(bruteForce?: boolean): void;
  32677. /** @hidden */
  32678. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32679. min: number;
  32680. mag: number;
  32681. };
  32682. /** @hidden */
  32683. _createTexture(): WebGLTexture;
  32684. /**
  32685. * Usually called from Texture.ts.
  32686. * Passed information to create a WebGLTexture
  32687. * @param urlArg defines a value which contains one of the following:
  32688. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32689. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32690. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32691. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32692. * @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)
  32693. * @param scene needed for loading to the correct scene
  32694. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32695. * @param onLoad optional callback to be called upon successful completion
  32696. * @param onError optional callback to be called upon failure
  32697. * @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
  32698. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32699. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32700. * @param forcedExtension defines the extension to use to pick the right loader
  32701. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32702. * @param mimeType defines an optional mime type
  32703. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32704. */
  32705. 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;
  32706. /**
  32707. * Loads an image as an HTMLImageElement.
  32708. * @param input url string, ArrayBuffer, or Blob to load
  32709. * @param onLoad callback called when the image successfully loads
  32710. * @param onError callback called when the image fails to load
  32711. * @param offlineProvider offline provider for caching
  32712. * @param mimeType optional mime type
  32713. * @returns the HTMLImageElement of the loaded image
  32714. * @hidden
  32715. */
  32716. 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>;
  32717. /**
  32718. * @hidden
  32719. */
  32720. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32721. /**
  32722. * Creates a raw texture
  32723. * @param data defines the data to store in the texture
  32724. * @param width defines the width of the texture
  32725. * @param height defines the height of the texture
  32726. * @param format defines the format of the data
  32727. * @param generateMipMaps defines if the engine should generate the mip levels
  32728. * @param invertY defines if data must be stored with Y axis inverted
  32729. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32730. * @param compression defines the compression used (null by default)
  32731. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32732. * @returns the raw texture inside an InternalTexture
  32733. */
  32734. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32735. /**
  32736. * Creates a new raw cube texture
  32737. * @param data defines the array of data to use to create each face
  32738. * @param size defines the size of the textures
  32739. * @param format defines the format of the data
  32740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32741. * @param generateMipMaps defines if the engine should generate the mip levels
  32742. * @param invertY defines if data must be stored with Y axis inverted
  32743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32744. * @param compression defines the compression used (null by default)
  32745. * @returns the cube texture as an InternalTexture
  32746. */
  32747. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32748. /**
  32749. * Creates a new raw 3D texture
  32750. * @param data defines the data used to create the texture
  32751. * @param width defines the width of the texture
  32752. * @param height defines the height of the texture
  32753. * @param depth defines the depth of the texture
  32754. * @param format defines the format of the texture
  32755. * @param generateMipMaps defines if the engine must generate mip levels
  32756. * @param invertY defines if data must be stored with Y axis inverted
  32757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32758. * @param compression defines the compressed used (can be null)
  32759. * @param textureType defines the compressed used (can be null)
  32760. * @returns a new raw 3D texture (stored in an InternalTexture)
  32761. */
  32762. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32763. /**
  32764. * Creates a new raw 2D array texture
  32765. * @param data defines the data used to create the texture
  32766. * @param width defines the width of the texture
  32767. * @param height defines the height of the texture
  32768. * @param depth defines the number of layers of the texture
  32769. * @param format defines the format of the texture
  32770. * @param generateMipMaps defines if the engine must generate mip levels
  32771. * @param invertY defines if data must be stored with Y axis inverted
  32772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32773. * @param compression defines the compressed used (can be null)
  32774. * @param textureType defines the compressed used (can be null)
  32775. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32776. */
  32777. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32778. private _unpackFlipYCached;
  32779. /**
  32780. * In case you are sharing the context with other applications, it might
  32781. * be interested to not cache the unpack flip y state to ensure a consistent
  32782. * value would be set.
  32783. */
  32784. enableUnpackFlipYCached: boolean;
  32785. /** @hidden */
  32786. _unpackFlipY(value: boolean): void;
  32787. /** @hidden */
  32788. _getUnpackAlignement(): number;
  32789. private _getTextureTarget;
  32790. /**
  32791. * Update the sampling mode of a given texture
  32792. * @param samplingMode defines the required sampling mode
  32793. * @param texture defines the texture to update
  32794. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32795. */
  32796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32797. /**
  32798. * Update the sampling mode of a given texture
  32799. * @param texture defines the texture to update
  32800. * @param wrapU defines the texture wrap mode of the u coordinates
  32801. * @param wrapV defines the texture wrap mode of the v coordinates
  32802. * @param wrapR defines the texture wrap mode of the r coordinates
  32803. */
  32804. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32805. /** @hidden */
  32806. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32807. width: number;
  32808. height: number;
  32809. layers?: number;
  32810. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32811. /** @hidden */
  32812. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32813. /** @hidden */
  32814. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32815. /**
  32816. * Update a portion of an internal texture
  32817. * @param texture defines the texture to update
  32818. * @param imageData defines the data to store into the texture
  32819. * @param xOffset defines the x coordinates of the update rectangle
  32820. * @param yOffset defines the y coordinates of the update rectangle
  32821. * @param width defines the width of the update rectangle
  32822. * @param height defines the height of the update rectangle
  32823. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32824. * @param lod defines the lod level to update (0 by default)
  32825. */
  32826. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32827. /** @hidden */
  32828. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32829. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32830. private _prepareWebGLTexture;
  32831. /** @hidden */
  32832. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32833. private _getDepthStencilBuffer;
  32834. /** @hidden */
  32835. _releaseFramebufferObjects(texture: InternalTexture): void;
  32836. /** @hidden */
  32837. _releaseTexture(texture: InternalTexture): void;
  32838. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32839. protected _setProgram(program: WebGLProgram): void;
  32840. protected _boundUniforms: {
  32841. [key: number]: WebGLUniformLocation;
  32842. };
  32843. /**
  32844. * Binds an effect to the webGL context
  32845. * @param effect defines the effect to bind
  32846. */
  32847. bindSamplers(effect: Effect): void;
  32848. private _activateCurrentTexture;
  32849. /** @hidden */
  32850. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32851. /** @hidden */
  32852. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32853. /**
  32854. * Unbind all textures from the webGL context
  32855. */
  32856. unbindAllTextures(): void;
  32857. /**
  32858. * Sets a texture to the according uniform.
  32859. * @param channel The texture channel
  32860. * @param uniform The uniform to set
  32861. * @param texture The texture to apply
  32862. */
  32863. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32864. private _bindSamplerUniformToChannel;
  32865. private _getTextureWrapMode;
  32866. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32867. /**
  32868. * Sets an array of texture to the webGL context
  32869. * @param channel defines the channel where the texture array must be set
  32870. * @param uniform defines the associated uniform location
  32871. * @param textures defines the array of textures to bind
  32872. */
  32873. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32874. /** @hidden */
  32875. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32876. private _setTextureParameterFloat;
  32877. private _setTextureParameterInteger;
  32878. /**
  32879. * Unbind all vertex attributes from the webGL context
  32880. */
  32881. unbindAllAttributes(): void;
  32882. /**
  32883. * 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
  32884. */
  32885. releaseEffects(): void;
  32886. /**
  32887. * Dispose and release all associated resources
  32888. */
  32889. dispose(): void;
  32890. /**
  32891. * Attach a new callback raised when context lost event is fired
  32892. * @param callback defines the callback to call
  32893. */
  32894. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32895. /**
  32896. * Attach a new callback raised when context restored event is fired
  32897. * @param callback defines the callback to call
  32898. */
  32899. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32900. /**
  32901. * Get the current error code of the webGL context
  32902. * @returns the error code
  32903. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32904. */
  32905. getError(): number;
  32906. private _canRenderToFloatFramebuffer;
  32907. private _canRenderToHalfFloatFramebuffer;
  32908. private _canRenderToFramebuffer;
  32909. /** @hidden */
  32910. _getWebGLTextureType(type: number): number;
  32911. /** @hidden */
  32912. _getInternalFormat(format: number): number;
  32913. /** @hidden */
  32914. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32915. /** @hidden */
  32916. _getRGBAMultiSampleBufferFormat(type: number): number;
  32917. /** @hidden */
  32918. _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;
  32919. /**
  32920. * Loads a file from a url
  32921. * @param url url to load
  32922. * @param onSuccess callback called when the file successfully loads
  32923. * @param onProgress callback called while file is loading (if the server supports this mode)
  32924. * @param offlineProvider defines the offline provider for caching
  32925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32926. * @param onError callback called when the file fails to load
  32927. * @returns a file request object
  32928. * @hidden
  32929. */
  32930. 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;
  32931. /**
  32932. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32933. * @param x defines the x coordinate of the rectangle where pixels must be read
  32934. * @param y defines the y coordinate of the rectangle where pixels must be read
  32935. * @param width defines the width of the rectangle where pixels must be read
  32936. * @param height defines the height of the rectangle where pixels must be read
  32937. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32938. * @returns a Uint8Array containing RGBA colors
  32939. */
  32940. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32941. private static _isSupported;
  32942. /**
  32943. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32944. * @returns true if the engine can be created
  32945. * @ignorenaming
  32946. */
  32947. static isSupported(): boolean;
  32948. /**
  32949. * Find the next highest power of two.
  32950. * @param x Number to start search from.
  32951. * @return Next highest power of two.
  32952. */
  32953. static CeilingPOT(x: number): number;
  32954. /**
  32955. * Find the next lowest power of two.
  32956. * @param x Number to start search from.
  32957. * @return Next lowest power of two.
  32958. */
  32959. static FloorPOT(x: number): number;
  32960. /**
  32961. * Find the nearest power of two.
  32962. * @param x Number to start search from.
  32963. * @return Next nearest power of two.
  32964. */
  32965. static NearestPOT(x: number): number;
  32966. /**
  32967. * Get the closest exponent of two
  32968. * @param value defines the value to approximate
  32969. * @param max defines the maximum value to return
  32970. * @param mode defines how to define the closest value
  32971. * @returns closest exponent of two of the given value
  32972. */
  32973. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32974. /**
  32975. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32976. * @param func - the function to be called
  32977. * @param requester - the object that will request the next frame. Falls back to window.
  32978. * @returns frame number
  32979. */
  32980. static QueueNewFrame(func: () => void, requester?: any): number;
  32981. /**
  32982. * Gets host document
  32983. * @returns the host document object
  32984. */
  32985. getHostDocument(): Nullable<Document>;
  32986. }
  32987. }
  32988. declare module "babylonjs/Maths/sphericalPolynomial" {
  32989. import { Vector3 } from "babylonjs/Maths/math.vector";
  32990. import { Color3 } from "babylonjs/Maths/math.color";
  32991. /**
  32992. * Class representing spherical harmonics coefficients to the 3rd degree
  32993. */
  32994. export class SphericalHarmonics {
  32995. /**
  32996. * Defines whether or not the harmonics have been prescaled for rendering.
  32997. */
  32998. preScaled: boolean;
  32999. /**
  33000. * The l0,0 coefficients of the spherical harmonics
  33001. */
  33002. l00: Vector3;
  33003. /**
  33004. * The l1,-1 coefficients of the spherical harmonics
  33005. */
  33006. l1_1: Vector3;
  33007. /**
  33008. * The l1,0 coefficients of the spherical harmonics
  33009. */
  33010. l10: Vector3;
  33011. /**
  33012. * The l1,1 coefficients of the spherical harmonics
  33013. */
  33014. l11: Vector3;
  33015. /**
  33016. * The l2,-2 coefficients of the spherical harmonics
  33017. */
  33018. l2_2: Vector3;
  33019. /**
  33020. * The l2,-1 coefficients of the spherical harmonics
  33021. */
  33022. l2_1: Vector3;
  33023. /**
  33024. * The l2,0 coefficients of the spherical harmonics
  33025. */
  33026. l20: Vector3;
  33027. /**
  33028. * The l2,1 coefficients of the spherical harmonics
  33029. */
  33030. l21: Vector3;
  33031. /**
  33032. * The l2,2 coefficients of the spherical harmonics
  33033. */
  33034. l22: Vector3;
  33035. /**
  33036. * Adds a light to the spherical harmonics
  33037. * @param direction the direction of the light
  33038. * @param color the color of the light
  33039. * @param deltaSolidAngle the delta solid angle of the light
  33040. */
  33041. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33042. /**
  33043. * Scales the spherical harmonics by the given amount
  33044. * @param scale the amount to scale
  33045. */
  33046. scaleInPlace(scale: number): void;
  33047. /**
  33048. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33049. *
  33050. * ```
  33051. * E_lm = A_l * L_lm
  33052. * ```
  33053. *
  33054. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33055. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33056. * the scaling factors are given in equation 9.
  33057. */
  33058. convertIncidentRadianceToIrradiance(): void;
  33059. /**
  33060. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33061. *
  33062. * ```
  33063. * L = (1/pi) * E * rho
  33064. * ```
  33065. *
  33066. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33067. */
  33068. convertIrradianceToLambertianRadiance(): void;
  33069. /**
  33070. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33071. * required operations at run time.
  33072. *
  33073. * This is simply done by scaling back the SH with Ylm constants parameter.
  33074. * The trigonometric part being applied by the shader at run time.
  33075. */
  33076. preScaleForRendering(): void;
  33077. /**
  33078. * Constructs a spherical harmonics from an array.
  33079. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33080. * @returns the spherical harmonics
  33081. */
  33082. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33083. /**
  33084. * Gets the spherical harmonics from polynomial
  33085. * @param polynomial the spherical polynomial
  33086. * @returns the spherical harmonics
  33087. */
  33088. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33089. }
  33090. /**
  33091. * Class representing spherical polynomial coefficients to the 3rd degree
  33092. */
  33093. export class SphericalPolynomial {
  33094. private _harmonics;
  33095. /**
  33096. * The spherical harmonics used to create the polynomials.
  33097. */
  33098. get preScaledHarmonics(): SphericalHarmonics;
  33099. /**
  33100. * The x coefficients of the spherical polynomial
  33101. */
  33102. x: Vector3;
  33103. /**
  33104. * The y coefficients of the spherical polynomial
  33105. */
  33106. y: Vector3;
  33107. /**
  33108. * The z coefficients of the spherical polynomial
  33109. */
  33110. z: Vector3;
  33111. /**
  33112. * The xx coefficients of the spherical polynomial
  33113. */
  33114. xx: Vector3;
  33115. /**
  33116. * The yy coefficients of the spherical polynomial
  33117. */
  33118. yy: Vector3;
  33119. /**
  33120. * The zz coefficients of the spherical polynomial
  33121. */
  33122. zz: Vector3;
  33123. /**
  33124. * The xy coefficients of the spherical polynomial
  33125. */
  33126. xy: Vector3;
  33127. /**
  33128. * The yz coefficients of the spherical polynomial
  33129. */
  33130. yz: Vector3;
  33131. /**
  33132. * The zx coefficients of the spherical polynomial
  33133. */
  33134. zx: Vector3;
  33135. /**
  33136. * Adds an ambient color to the spherical polynomial
  33137. * @param color the color to add
  33138. */
  33139. addAmbient(color: Color3): void;
  33140. /**
  33141. * Scales the spherical polynomial by the given amount
  33142. * @param scale the amount to scale
  33143. */
  33144. scaleInPlace(scale: number): void;
  33145. /**
  33146. * Gets the spherical polynomial from harmonics
  33147. * @param harmonics the spherical harmonics
  33148. * @returns the spherical polynomial
  33149. */
  33150. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33151. /**
  33152. * Constructs a spherical polynomial from an array.
  33153. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33154. * @returns the spherical polynomial
  33155. */
  33156. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33157. }
  33158. }
  33159. declare module "babylonjs/Materials/Textures/internalTexture" {
  33160. import { Observable } from "babylonjs/Misc/observable";
  33161. import { Nullable, int } from "babylonjs/types";
  33162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33164. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33165. /**
  33166. * Defines the source of the internal texture
  33167. */
  33168. export enum InternalTextureSource {
  33169. /**
  33170. * The source of the texture data is unknown
  33171. */
  33172. Unknown = 0,
  33173. /**
  33174. * Texture data comes from an URL
  33175. */
  33176. Url = 1,
  33177. /**
  33178. * Texture data is only used for temporary storage
  33179. */
  33180. Temp = 2,
  33181. /**
  33182. * Texture data comes from raw data (ArrayBuffer)
  33183. */
  33184. Raw = 3,
  33185. /**
  33186. * Texture content is dynamic (video or dynamic texture)
  33187. */
  33188. Dynamic = 4,
  33189. /**
  33190. * Texture content is generated by rendering to it
  33191. */
  33192. RenderTarget = 5,
  33193. /**
  33194. * Texture content is part of a multi render target process
  33195. */
  33196. MultiRenderTarget = 6,
  33197. /**
  33198. * Texture data comes from a cube data file
  33199. */
  33200. Cube = 7,
  33201. /**
  33202. * Texture data comes from a raw cube data
  33203. */
  33204. CubeRaw = 8,
  33205. /**
  33206. * Texture data come from a prefiltered cube data file
  33207. */
  33208. CubePrefiltered = 9,
  33209. /**
  33210. * Texture content is raw 3D data
  33211. */
  33212. Raw3D = 10,
  33213. /**
  33214. * Texture content is raw 2D array data
  33215. */
  33216. Raw2DArray = 11,
  33217. /**
  33218. * Texture content is a depth texture
  33219. */
  33220. Depth = 12,
  33221. /**
  33222. * Texture data comes from a raw cube data encoded with RGBD
  33223. */
  33224. CubeRawRGBD = 13
  33225. }
  33226. /**
  33227. * Class used to store data associated with WebGL texture data for the engine
  33228. * This class should not be used directly
  33229. */
  33230. export class InternalTexture {
  33231. /** @hidden */
  33232. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33233. /**
  33234. * Defines if the texture is ready
  33235. */
  33236. isReady: boolean;
  33237. /**
  33238. * Defines if the texture is a cube texture
  33239. */
  33240. isCube: boolean;
  33241. /**
  33242. * Defines if the texture contains 3D data
  33243. */
  33244. is3D: boolean;
  33245. /**
  33246. * Defines if the texture contains 2D array data
  33247. */
  33248. is2DArray: boolean;
  33249. /**
  33250. * Defines if the texture contains multiview data
  33251. */
  33252. isMultiview: boolean;
  33253. /**
  33254. * Gets the URL used to load this texture
  33255. */
  33256. url: string;
  33257. /**
  33258. * Gets the sampling mode of the texture
  33259. */
  33260. samplingMode: number;
  33261. /**
  33262. * Gets a boolean indicating if the texture needs mipmaps generation
  33263. */
  33264. generateMipMaps: boolean;
  33265. /**
  33266. * Gets the number of samples used by the texture (WebGL2+ only)
  33267. */
  33268. samples: number;
  33269. /**
  33270. * Gets the type of the texture (int, float...)
  33271. */
  33272. type: number;
  33273. /**
  33274. * Gets the format of the texture (RGB, RGBA...)
  33275. */
  33276. format: number;
  33277. /**
  33278. * Observable called when the texture is loaded
  33279. */
  33280. onLoadedObservable: Observable<InternalTexture>;
  33281. /**
  33282. * Gets the width of the texture
  33283. */
  33284. width: number;
  33285. /**
  33286. * Gets the height of the texture
  33287. */
  33288. height: number;
  33289. /**
  33290. * Gets the depth of the texture
  33291. */
  33292. depth: number;
  33293. /**
  33294. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33295. */
  33296. baseWidth: number;
  33297. /**
  33298. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33299. */
  33300. baseHeight: number;
  33301. /**
  33302. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33303. */
  33304. baseDepth: number;
  33305. /**
  33306. * Gets a boolean indicating if the texture is inverted on Y axis
  33307. */
  33308. invertY: boolean;
  33309. /** @hidden */
  33310. _invertVScale: boolean;
  33311. /** @hidden */
  33312. _associatedChannel: number;
  33313. /** @hidden */
  33314. _source: InternalTextureSource;
  33315. /** @hidden */
  33316. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33317. /** @hidden */
  33318. _bufferView: Nullable<ArrayBufferView>;
  33319. /** @hidden */
  33320. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33321. /** @hidden */
  33322. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33323. /** @hidden */
  33324. _size: number;
  33325. /** @hidden */
  33326. _extension: string;
  33327. /** @hidden */
  33328. _files: Nullable<string[]>;
  33329. /** @hidden */
  33330. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33331. /** @hidden */
  33332. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33333. /** @hidden */
  33334. _framebuffer: Nullable<WebGLFramebuffer>;
  33335. /** @hidden */
  33336. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33337. /** @hidden */
  33338. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33339. /** @hidden */
  33340. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33341. /** @hidden */
  33342. _attachments: Nullable<number[]>;
  33343. /** @hidden */
  33344. _cachedCoordinatesMode: Nullable<number>;
  33345. /** @hidden */
  33346. _cachedWrapU: Nullable<number>;
  33347. /** @hidden */
  33348. _cachedWrapV: Nullable<number>;
  33349. /** @hidden */
  33350. _cachedWrapR: Nullable<number>;
  33351. /** @hidden */
  33352. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33353. /** @hidden */
  33354. _isDisabled: boolean;
  33355. /** @hidden */
  33356. _compression: Nullable<string>;
  33357. /** @hidden */
  33358. _generateStencilBuffer: boolean;
  33359. /** @hidden */
  33360. _generateDepthBuffer: boolean;
  33361. /** @hidden */
  33362. _comparisonFunction: number;
  33363. /** @hidden */
  33364. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33365. /** @hidden */
  33366. _lodGenerationScale: number;
  33367. /** @hidden */
  33368. _lodGenerationOffset: number;
  33369. /** @hidden */
  33370. _depthStencilTexture: Nullable<InternalTexture>;
  33371. /** @hidden */
  33372. _colorTextureArray: Nullable<WebGLTexture>;
  33373. /** @hidden */
  33374. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33375. /** @hidden */
  33376. _lodTextureHigh: Nullable<BaseTexture>;
  33377. /** @hidden */
  33378. _lodTextureMid: Nullable<BaseTexture>;
  33379. /** @hidden */
  33380. _lodTextureLow: Nullable<BaseTexture>;
  33381. /** @hidden */
  33382. _isRGBD: boolean;
  33383. /** @hidden */
  33384. _linearSpecularLOD: boolean;
  33385. /** @hidden */
  33386. _irradianceTexture: Nullable<BaseTexture>;
  33387. /** @hidden */
  33388. _webGLTexture: Nullable<WebGLTexture>;
  33389. /** @hidden */
  33390. _references: number;
  33391. private _engine;
  33392. /**
  33393. * Gets the Engine the texture belongs to.
  33394. * @returns The babylon engine
  33395. */
  33396. getEngine(): ThinEngine;
  33397. /**
  33398. * Gets the data source type of the texture
  33399. */
  33400. get source(): InternalTextureSource;
  33401. /**
  33402. * Creates a new InternalTexture
  33403. * @param engine defines the engine to use
  33404. * @param source defines the type of data that will be used
  33405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33406. */
  33407. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33408. /**
  33409. * Increments the number of references (ie. the number of Texture that point to it)
  33410. */
  33411. incrementReferences(): void;
  33412. /**
  33413. * Change the size of the texture (not the size of the content)
  33414. * @param width defines the new width
  33415. * @param height defines the new height
  33416. * @param depth defines the new depth (1 by default)
  33417. */
  33418. updateSize(width: int, height: int, depth?: int): void;
  33419. /** @hidden */
  33420. _rebuild(): void;
  33421. /** @hidden */
  33422. _swapAndDie(target: InternalTexture): void;
  33423. /**
  33424. * Dispose the current allocated resources
  33425. */
  33426. dispose(): void;
  33427. }
  33428. }
  33429. declare module "babylonjs/Audio/analyser" {
  33430. import { Scene } from "babylonjs/scene";
  33431. /**
  33432. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33434. */
  33435. export class Analyser {
  33436. /**
  33437. * Gets or sets the smoothing
  33438. * @ignorenaming
  33439. */
  33440. SMOOTHING: number;
  33441. /**
  33442. * Gets or sets the FFT table size
  33443. * @ignorenaming
  33444. */
  33445. FFT_SIZE: number;
  33446. /**
  33447. * Gets or sets the bar graph amplitude
  33448. * @ignorenaming
  33449. */
  33450. BARGRAPHAMPLITUDE: number;
  33451. /**
  33452. * Gets or sets the position of the debug canvas
  33453. * @ignorenaming
  33454. */
  33455. DEBUGCANVASPOS: {
  33456. x: number;
  33457. y: number;
  33458. };
  33459. /**
  33460. * Gets or sets the debug canvas size
  33461. * @ignorenaming
  33462. */
  33463. DEBUGCANVASSIZE: {
  33464. width: number;
  33465. height: number;
  33466. };
  33467. private _byteFreqs;
  33468. private _byteTime;
  33469. private _floatFreqs;
  33470. private _webAudioAnalyser;
  33471. private _debugCanvas;
  33472. private _debugCanvasContext;
  33473. private _scene;
  33474. private _registerFunc;
  33475. private _audioEngine;
  33476. /**
  33477. * Creates a new analyser
  33478. * @param scene defines hosting scene
  33479. */
  33480. constructor(scene: Scene);
  33481. /**
  33482. * Get the number of data values you will have to play with for the visualization
  33483. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33484. * @returns a number
  33485. */
  33486. getFrequencyBinCount(): number;
  33487. /**
  33488. * Gets the current frequency data as a byte array
  33489. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33490. * @returns a Uint8Array
  33491. */
  33492. getByteFrequencyData(): Uint8Array;
  33493. /**
  33494. * Gets the current waveform as a byte array
  33495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33496. * @returns a Uint8Array
  33497. */
  33498. getByteTimeDomainData(): Uint8Array;
  33499. /**
  33500. * Gets the current frequency data as a float array
  33501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33502. * @returns a Float32Array
  33503. */
  33504. getFloatFrequencyData(): Float32Array;
  33505. /**
  33506. * Renders the debug canvas
  33507. */
  33508. drawDebugCanvas(): void;
  33509. /**
  33510. * Stops rendering the debug canvas and removes it
  33511. */
  33512. stopDebugCanvas(): void;
  33513. /**
  33514. * Connects two audio nodes
  33515. * @param inputAudioNode defines first node to connect
  33516. * @param outputAudioNode defines second node to connect
  33517. */
  33518. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33519. /**
  33520. * Releases all associated resources
  33521. */
  33522. dispose(): void;
  33523. }
  33524. }
  33525. declare module "babylonjs/Audio/audioEngine" {
  33526. import { IDisposable } from "babylonjs/scene";
  33527. import { Analyser } from "babylonjs/Audio/analyser";
  33528. import { Nullable } from "babylonjs/types";
  33529. import { Observable } from "babylonjs/Misc/observable";
  33530. /**
  33531. * This represents an audio engine and it is responsible
  33532. * to play, synchronize and analyse sounds throughout the application.
  33533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33534. */
  33535. export interface IAudioEngine extends IDisposable {
  33536. /**
  33537. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33538. */
  33539. readonly canUseWebAudio: boolean;
  33540. /**
  33541. * Gets the current AudioContext if available.
  33542. */
  33543. readonly audioContext: Nullable<AudioContext>;
  33544. /**
  33545. * The master gain node defines the global audio volume of your audio engine.
  33546. */
  33547. readonly masterGain: GainNode;
  33548. /**
  33549. * Gets whether or not mp3 are supported by your browser.
  33550. */
  33551. readonly isMP3supported: boolean;
  33552. /**
  33553. * Gets whether or not ogg are supported by your browser.
  33554. */
  33555. readonly isOGGsupported: boolean;
  33556. /**
  33557. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33558. * @ignoreNaming
  33559. */
  33560. WarnedWebAudioUnsupported: boolean;
  33561. /**
  33562. * Defines if the audio engine relies on a custom unlocked button.
  33563. * In this case, the embedded button will not be displayed.
  33564. */
  33565. useCustomUnlockedButton: boolean;
  33566. /**
  33567. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33568. */
  33569. readonly unlocked: boolean;
  33570. /**
  33571. * Event raised when audio has been unlocked on the browser.
  33572. */
  33573. onAudioUnlockedObservable: Observable<AudioEngine>;
  33574. /**
  33575. * Event raised when audio has been locked on the browser.
  33576. */
  33577. onAudioLockedObservable: Observable<AudioEngine>;
  33578. /**
  33579. * Flags the audio engine in Locked state.
  33580. * This happens due to new browser policies preventing audio to autoplay.
  33581. */
  33582. lock(): void;
  33583. /**
  33584. * Unlocks the audio engine once a user action has been done on the dom.
  33585. * This is helpful to resume play once browser policies have been satisfied.
  33586. */
  33587. unlock(): void;
  33588. }
  33589. /**
  33590. * This represents the default audio engine used in babylon.
  33591. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33593. */
  33594. export class AudioEngine implements IAudioEngine {
  33595. private _audioContext;
  33596. private _audioContextInitialized;
  33597. private _muteButton;
  33598. private _hostElement;
  33599. /**
  33600. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33601. */
  33602. canUseWebAudio: boolean;
  33603. /**
  33604. * The master gain node defines the global audio volume of your audio engine.
  33605. */
  33606. masterGain: GainNode;
  33607. /**
  33608. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33609. * @ignoreNaming
  33610. */
  33611. WarnedWebAudioUnsupported: boolean;
  33612. /**
  33613. * Gets whether or not mp3 are supported by your browser.
  33614. */
  33615. isMP3supported: boolean;
  33616. /**
  33617. * Gets whether or not ogg are supported by your browser.
  33618. */
  33619. isOGGsupported: boolean;
  33620. /**
  33621. * Gets whether audio has been unlocked on the device.
  33622. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33623. * a user interaction has happened.
  33624. */
  33625. unlocked: boolean;
  33626. /**
  33627. * Defines if the audio engine relies on a custom unlocked button.
  33628. * In this case, the embedded button will not be displayed.
  33629. */
  33630. useCustomUnlockedButton: boolean;
  33631. /**
  33632. * Event raised when audio has been unlocked on the browser.
  33633. */
  33634. onAudioUnlockedObservable: Observable<AudioEngine>;
  33635. /**
  33636. * Event raised when audio has been locked on the browser.
  33637. */
  33638. onAudioLockedObservable: Observable<AudioEngine>;
  33639. /**
  33640. * Gets the current AudioContext if available.
  33641. */
  33642. get audioContext(): Nullable<AudioContext>;
  33643. private _connectedAnalyser;
  33644. /**
  33645. * Instantiates a new audio engine.
  33646. *
  33647. * There should be only one per page as some browsers restrict the number
  33648. * of audio contexts you can create.
  33649. * @param hostElement defines the host element where to display the mute icon if necessary
  33650. */
  33651. constructor(hostElement?: Nullable<HTMLElement>);
  33652. /**
  33653. * Flags the audio engine in Locked state.
  33654. * This happens due to new browser policies preventing audio to autoplay.
  33655. */
  33656. lock(): void;
  33657. /**
  33658. * Unlocks the audio engine once a user action has been done on the dom.
  33659. * This is helpful to resume play once browser policies have been satisfied.
  33660. */
  33661. unlock(): void;
  33662. private _resumeAudioContext;
  33663. private _initializeAudioContext;
  33664. private _tryToRun;
  33665. private _triggerRunningState;
  33666. private _triggerSuspendedState;
  33667. private _displayMuteButton;
  33668. private _moveButtonToTopLeft;
  33669. private _onResize;
  33670. private _hideMuteButton;
  33671. /**
  33672. * Destroy and release the resources associated with the audio ccontext.
  33673. */
  33674. dispose(): void;
  33675. /**
  33676. * Gets the global volume sets on the master gain.
  33677. * @returns the global volume if set or -1 otherwise
  33678. */
  33679. getGlobalVolume(): number;
  33680. /**
  33681. * Sets the global volume of your experience (sets on the master gain).
  33682. * @param newVolume Defines the new global volume of the application
  33683. */
  33684. setGlobalVolume(newVolume: number): void;
  33685. /**
  33686. * Connect the audio engine to an audio analyser allowing some amazing
  33687. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33689. * @param analyser The analyser to connect to the engine
  33690. */
  33691. connectToAnalyser(analyser: Analyser): void;
  33692. }
  33693. }
  33694. declare module "babylonjs/Loading/loadingScreen" {
  33695. /**
  33696. * Interface used to present a loading screen while loading a scene
  33697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33698. */
  33699. export interface ILoadingScreen {
  33700. /**
  33701. * Function called to display the loading screen
  33702. */
  33703. displayLoadingUI: () => void;
  33704. /**
  33705. * Function called to hide the loading screen
  33706. */
  33707. hideLoadingUI: () => void;
  33708. /**
  33709. * Gets or sets the color to use for the background
  33710. */
  33711. loadingUIBackgroundColor: string;
  33712. /**
  33713. * Gets or sets the text to display while loading
  33714. */
  33715. loadingUIText: string;
  33716. }
  33717. /**
  33718. * Class used for the default loading screen
  33719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33720. */
  33721. export class DefaultLoadingScreen implements ILoadingScreen {
  33722. private _renderingCanvas;
  33723. private _loadingText;
  33724. private _loadingDivBackgroundColor;
  33725. private _loadingDiv;
  33726. private _loadingTextDiv;
  33727. /** Gets or sets the logo url to use for the default loading screen */
  33728. static DefaultLogoUrl: string;
  33729. /** Gets or sets the spinner url to use for the default loading screen */
  33730. static DefaultSpinnerUrl: string;
  33731. /**
  33732. * Creates a new default loading screen
  33733. * @param _renderingCanvas defines the canvas used to render the scene
  33734. * @param _loadingText defines the default text to display
  33735. * @param _loadingDivBackgroundColor defines the default background color
  33736. */
  33737. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33738. /**
  33739. * Function called to display the loading screen
  33740. */
  33741. displayLoadingUI(): void;
  33742. /**
  33743. * Function called to hide the loading screen
  33744. */
  33745. hideLoadingUI(): void;
  33746. /**
  33747. * Gets or sets the text to display while loading
  33748. */
  33749. set loadingUIText(text: string);
  33750. get loadingUIText(): string;
  33751. /**
  33752. * Gets or sets the color to use for the background
  33753. */
  33754. get loadingUIBackgroundColor(): string;
  33755. set loadingUIBackgroundColor(color: string);
  33756. private _resizeLoadingUI;
  33757. }
  33758. }
  33759. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33760. /**
  33761. * Interface for any object that can request an animation frame
  33762. */
  33763. export interface ICustomAnimationFrameRequester {
  33764. /**
  33765. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33766. */
  33767. renderFunction?: Function;
  33768. /**
  33769. * Called to request the next frame to render to
  33770. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33771. */
  33772. requestAnimationFrame: Function;
  33773. /**
  33774. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33775. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33776. */
  33777. requestID?: number;
  33778. }
  33779. }
  33780. declare module "babylonjs/Misc/performanceMonitor" {
  33781. /**
  33782. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33783. */
  33784. export class PerformanceMonitor {
  33785. private _enabled;
  33786. private _rollingFrameTime;
  33787. private _lastFrameTimeMs;
  33788. /**
  33789. * constructor
  33790. * @param frameSampleSize The number of samples required to saturate the sliding window
  33791. */
  33792. constructor(frameSampleSize?: number);
  33793. /**
  33794. * Samples current frame
  33795. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33796. */
  33797. sampleFrame(timeMs?: number): void;
  33798. /**
  33799. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33800. */
  33801. get averageFrameTime(): number;
  33802. /**
  33803. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33804. */
  33805. get averageFrameTimeVariance(): number;
  33806. /**
  33807. * Returns the frame time of the most recent frame
  33808. */
  33809. get instantaneousFrameTime(): number;
  33810. /**
  33811. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFPS(): number;
  33814. /**
  33815. * Returns the average framerate in frames per second using the most recent frame time
  33816. */
  33817. get instantaneousFPS(): number;
  33818. /**
  33819. * Returns true if enough samples have been taken to completely fill the sliding window
  33820. */
  33821. get isSaturated(): boolean;
  33822. /**
  33823. * Enables contributions to the sliding window sample set
  33824. */
  33825. enable(): void;
  33826. /**
  33827. * Disables contributions to the sliding window sample set
  33828. * Samples will not be interpolated over the disabled period
  33829. */
  33830. disable(): void;
  33831. /**
  33832. * Returns true if sampling is enabled
  33833. */
  33834. get isEnabled(): boolean;
  33835. /**
  33836. * Resets performance monitor
  33837. */
  33838. reset(): void;
  33839. }
  33840. /**
  33841. * RollingAverage
  33842. *
  33843. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33844. */
  33845. export class RollingAverage {
  33846. /**
  33847. * Current average
  33848. */
  33849. average: number;
  33850. /**
  33851. * Current variance
  33852. */
  33853. variance: number;
  33854. protected _samples: Array<number>;
  33855. protected _sampleCount: number;
  33856. protected _pos: number;
  33857. protected _m2: number;
  33858. /**
  33859. * constructor
  33860. * @param length The number of samples required to saturate the sliding window
  33861. */
  33862. constructor(length: number);
  33863. /**
  33864. * Adds a sample to the sample set
  33865. * @param v The sample value
  33866. */
  33867. add(v: number): void;
  33868. /**
  33869. * Returns previously added values or null if outside of history or outside the sliding window domain
  33870. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33871. * @return Value previously recorded with add() or null if outside of range
  33872. */
  33873. history(i: number): number;
  33874. /**
  33875. * Returns true if enough samples have been taken to completely fill the sliding window
  33876. * @return true if sample-set saturated
  33877. */
  33878. isSaturated(): boolean;
  33879. /**
  33880. * Resets the rolling average (equivalent to 0 samples taken so far)
  33881. */
  33882. reset(): void;
  33883. /**
  33884. * Wraps a value around the sample range boundaries
  33885. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33886. * @return Wrapped position in sample range
  33887. */
  33888. protected _wrapPosition(i: number): number;
  33889. }
  33890. }
  33891. declare module "babylonjs/Misc/perfCounter" {
  33892. /**
  33893. * This class is used to track a performance counter which is number based.
  33894. * The user has access to many properties which give statistics of different nature.
  33895. *
  33896. * The implementer can track two kinds of Performance Counter: time and count.
  33897. * 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.
  33898. * 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.
  33899. */
  33900. export class PerfCounter {
  33901. /**
  33902. * Gets or sets a global boolean to turn on and off all the counters
  33903. */
  33904. static Enabled: boolean;
  33905. /**
  33906. * Returns the smallest value ever
  33907. */
  33908. get min(): number;
  33909. /**
  33910. * Returns the biggest value ever
  33911. */
  33912. get max(): number;
  33913. /**
  33914. * Returns the average value since the performance counter is running
  33915. */
  33916. get average(): number;
  33917. /**
  33918. * Returns the average value of the last second the counter was monitored
  33919. */
  33920. get lastSecAverage(): number;
  33921. /**
  33922. * Returns the current value
  33923. */
  33924. get current(): number;
  33925. /**
  33926. * Gets the accumulated total
  33927. */
  33928. get total(): number;
  33929. /**
  33930. * Gets the total value count
  33931. */
  33932. get count(): number;
  33933. /**
  33934. * Creates a new counter
  33935. */
  33936. constructor();
  33937. /**
  33938. * Call this method to start monitoring a new frame.
  33939. * 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.
  33940. */
  33941. fetchNewFrame(): void;
  33942. /**
  33943. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33944. * @param newCount the count value to add to the monitored count
  33945. * @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.
  33946. */
  33947. addCount(newCount: number, fetchResult: boolean): void;
  33948. /**
  33949. * Start monitoring this performance counter
  33950. */
  33951. beginMonitoring(): void;
  33952. /**
  33953. * Compute the time lapsed since the previous beginMonitoring() call.
  33954. * @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
  33955. */
  33956. endMonitoring(newFrame?: boolean): void;
  33957. private _fetchResult;
  33958. private _startMonitoringTime;
  33959. private _min;
  33960. private _max;
  33961. private _average;
  33962. private _current;
  33963. private _totalValueCount;
  33964. private _totalAccumulated;
  33965. private _lastSecAverage;
  33966. private _lastSecAccumulated;
  33967. private _lastSecTime;
  33968. private _lastSecValueCount;
  33969. }
  33970. }
  33971. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33972. module "babylonjs/Engines/thinEngine" {
  33973. interface ThinEngine {
  33974. /**
  33975. * Sets alpha constants used by some alpha blending modes
  33976. * @param r defines the red component
  33977. * @param g defines the green component
  33978. * @param b defines the blue component
  33979. * @param a defines the alpha component
  33980. */
  33981. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33982. /**
  33983. * Sets the current alpha mode
  33984. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33985. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33987. */
  33988. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33989. /**
  33990. * Gets the current alpha mode
  33991. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33992. * @returns the current alpha mode
  33993. */
  33994. getAlphaMode(): number;
  33995. /**
  33996. * Sets the current alpha equation
  33997. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33998. */
  33999. setAlphaEquation(equation: number): void;
  34000. /**
  34001. * Gets the current alpha equation.
  34002. * @returns the current alpha equation
  34003. */
  34004. getAlphaEquation(): number;
  34005. }
  34006. }
  34007. }
  34008. declare module "babylonjs/Engines/engine" {
  34009. import { Observable } from "babylonjs/Misc/observable";
  34010. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34011. import { Scene } from "babylonjs/scene";
  34012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34013. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34014. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34015. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34016. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34017. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34018. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34019. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34020. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34022. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34024. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34025. import "babylonjs/Engines/Extensions/engine.alpha";
  34026. import { Material } from "babylonjs/Materials/material";
  34027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34028. /**
  34029. * Defines the interface used by display changed events
  34030. */
  34031. export interface IDisplayChangedEventArgs {
  34032. /** Gets the vrDisplay object (if any) */
  34033. vrDisplay: Nullable<any>;
  34034. /** Gets a boolean indicating if webVR is supported */
  34035. vrSupported: boolean;
  34036. }
  34037. /**
  34038. * Defines the interface used by objects containing a viewport (like a camera)
  34039. */
  34040. interface IViewportOwnerLike {
  34041. /**
  34042. * Gets or sets the viewport
  34043. */
  34044. viewport: IViewportLike;
  34045. }
  34046. /**
  34047. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34048. */
  34049. export class Engine extends ThinEngine {
  34050. /** Defines that alpha blending is disabled */
  34051. static readonly ALPHA_DISABLE: number;
  34052. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34053. static readonly ALPHA_ADD: number;
  34054. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34055. static readonly ALPHA_COMBINE: number;
  34056. /** Defines that alpha blending to DEST - SRC * DEST */
  34057. static readonly ALPHA_SUBTRACT: number;
  34058. /** Defines that alpha blending to SRC * DEST */
  34059. static readonly ALPHA_MULTIPLY: number;
  34060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34061. static readonly ALPHA_MAXIMIZED: number;
  34062. /** Defines that alpha blending to SRC + DEST */
  34063. static readonly ALPHA_ONEONE: number;
  34064. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34065. static readonly ALPHA_PREMULTIPLIED: number;
  34066. /**
  34067. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34068. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34069. */
  34070. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34071. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34072. static readonly ALPHA_INTERPOLATE: number;
  34073. /**
  34074. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34075. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34076. */
  34077. static readonly ALPHA_SCREENMODE: number;
  34078. /** Defines that the ressource is not delayed*/
  34079. static readonly DELAYLOADSTATE_NONE: number;
  34080. /** Defines that the ressource was successfully delay loaded */
  34081. static readonly DELAYLOADSTATE_LOADED: number;
  34082. /** Defines that the ressource is currently delay loading */
  34083. static readonly DELAYLOADSTATE_LOADING: number;
  34084. /** Defines that the ressource is delayed and has not started loading */
  34085. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34087. static readonly NEVER: number;
  34088. /** 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 */
  34089. static readonly ALWAYS: number;
  34090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34091. static readonly LESS: number;
  34092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34093. static readonly EQUAL: number;
  34094. /** 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 */
  34095. static readonly LEQUAL: number;
  34096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34097. static readonly GREATER: number;
  34098. /** 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 */
  34099. static readonly GEQUAL: number;
  34100. /** 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 */
  34101. static readonly NOTEQUAL: number;
  34102. /** Passed to stencilOperation to specify that stencil value must be kept */
  34103. static readonly KEEP: number;
  34104. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34105. static readonly REPLACE: number;
  34106. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34107. static readonly INCR: number;
  34108. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34109. static readonly DECR: number;
  34110. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34111. static readonly INVERT: number;
  34112. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34113. static readonly INCR_WRAP: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34115. static readonly DECR_WRAP: number;
  34116. /** Texture is not repeating outside of 0..1 UVs */
  34117. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34118. /** Texture is repeating outside of 0..1 UVs */
  34119. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34120. /** Texture is repeating and mirrored */
  34121. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34122. /** ALPHA */
  34123. static readonly TEXTUREFORMAT_ALPHA: number;
  34124. /** LUMINANCE */
  34125. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34126. /** LUMINANCE_ALPHA */
  34127. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34128. /** RGB */
  34129. static readonly TEXTUREFORMAT_RGB: number;
  34130. /** RGBA */
  34131. static readonly TEXTUREFORMAT_RGBA: number;
  34132. /** RED */
  34133. static readonly TEXTUREFORMAT_RED: number;
  34134. /** RED (2nd reference) */
  34135. static readonly TEXTUREFORMAT_R: number;
  34136. /** RG */
  34137. static readonly TEXTUREFORMAT_RG: number;
  34138. /** RED_INTEGER */
  34139. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34140. /** RED_INTEGER (2nd reference) */
  34141. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34142. /** RG_INTEGER */
  34143. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34144. /** RGB_INTEGER */
  34145. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34146. /** RGBA_INTEGER */
  34147. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34148. /** UNSIGNED_BYTE */
  34149. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34150. /** UNSIGNED_BYTE (2nd reference) */
  34151. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34152. /** FLOAT */
  34153. static readonly TEXTURETYPE_FLOAT: number;
  34154. /** HALF_FLOAT */
  34155. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34156. /** BYTE */
  34157. static readonly TEXTURETYPE_BYTE: number;
  34158. /** SHORT */
  34159. static readonly TEXTURETYPE_SHORT: number;
  34160. /** UNSIGNED_SHORT */
  34161. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34162. /** INT */
  34163. static readonly TEXTURETYPE_INT: number;
  34164. /** UNSIGNED_INT */
  34165. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34166. /** UNSIGNED_SHORT_4_4_4_4 */
  34167. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34168. /** UNSIGNED_SHORT_5_5_5_1 */
  34169. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34170. /** UNSIGNED_SHORT_5_6_5 */
  34171. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34172. /** UNSIGNED_INT_2_10_10_10_REV */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34174. /** UNSIGNED_INT_24_8 */
  34175. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34176. /** UNSIGNED_INT_10F_11F_11F_REV */
  34177. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34178. /** UNSIGNED_INT_5_9_9_9_REV */
  34179. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34180. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34181. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34182. /** nearest is mag = nearest and min = nearest and mip = linear */
  34183. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34185. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34186. /** Trilinear is mag = linear and min = linear and mip = linear */
  34187. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34188. /** nearest is mag = nearest and min = nearest and mip = linear */
  34189. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34191. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34192. /** Trilinear is mag = linear and min = linear and mip = linear */
  34193. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34194. /** mag = nearest and min = nearest and mip = nearest */
  34195. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34196. /** mag = nearest and min = linear and mip = nearest */
  34197. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34198. /** mag = nearest and min = linear and mip = linear */
  34199. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34200. /** mag = nearest and min = linear and mip = none */
  34201. static readonly TEXTURE_NEAREST_LINEAR: number;
  34202. /** mag = nearest and min = nearest and mip = none */
  34203. static readonly TEXTURE_NEAREST_NEAREST: number;
  34204. /** mag = linear and min = nearest and mip = nearest */
  34205. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34206. /** mag = linear and min = nearest and mip = linear */
  34207. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34208. /** mag = linear and min = linear and mip = none */
  34209. static readonly TEXTURE_LINEAR_LINEAR: number;
  34210. /** mag = linear and min = nearest and mip = none */
  34211. static readonly TEXTURE_LINEAR_NEAREST: number;
  34212. /** Explicit coordinates mode */
  34213. static readonly TEXTURE_EXPLICIT_MODE: number;
  34214. /** Spherical coordinates mode */
  34215. static readonly TEXTURE_SPHERICAL_MODE: number;
  34216. /** Planar coordinates mode */
  34217. static readonly TEXTURE_PLANAR_MODE: number;
  34218. /** Cubic coordinates mode */
  34219. static readonly TEXTURE_CUBIC_MODE: number;
  34220. /** Projection coordinates mode */
  34221. static readonly TEXTURE_PROJECTION_MODE: number;
  34222. /** Skybox coordinates mode */
  34223. static readonly TEXTURE_SKYBOX_MODE: number;
  34224. /** Inverse Cubic coordinates mode */
  34225. static readonly TEXTURE_INVCUBIC_MODE: number;
  34226. /** Equirectangular coordinates mode */
  34227. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34228. /** Equirectangular Fixed coordinates mode */
  34229. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34230. /** Equirectangular Fixed Mirrored coordinates mode */
  34231. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34232. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34233. static readonly SCALEMODE_FLOOR: number;
  34234. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34235. static readonly SCALEMODE_NEAREST: number;
  34236. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34237. static readonly SCALEMODE_CEILING: number;
  34238. /**
  34239. * Returns the current npm package of the sdk
  34240. */
  34241. static get NpmPackage(): string;
  34242. /**
  34243. * Returns the current version of the framework
  34244. */
  34245. static get Version(): string;
  34246. /** Gets the list of created engines */
  34247. static get Instances(): Engine[];
  34248. /**
  34249. * Gets the latest created engine
  34250. */
  34251. static get LastCreatedEngine(): Nullable<Engine>;
  34252. /**
  34253. * Gets the latest created scene
  34254. */
  34255. static get LastCreatedScene(): Nullable<Scene>;
  34256. /**
  34257. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34258. * @param flag defines which part of the materials must be marked as dirty
  34259. * @param predicate defines a predicate used to filter which materials should be affected
  34260. */
  34261. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34262. /**
  34263. * Method called to create the default loading screen.
  34264. * This can be overriden in your own app.
  34265. * @param canvas The rendering canvas element
  34266. * @returns The loading screen
  34267. */
  34268. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34269. /**
  34270. * Method called to create the default rescale post process on each engine.
  34271. */
  34272. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34273. /**
  34274. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34275. **/
  34276. enableOfflineSupport: boolean;
  34277. /**
  34278. * 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)
  34279. **/
  34280. disableManifestCheck: boolean;
  34281. /**
  34282. * Gets the list of created scenes
  34283. */
  34284. scenes: Scene[];
  34285. /**
  34286. * Event raised when a new scene is created
  34287. */
  34288. onNewSceneAddedObservable: Observable<Scene>;
  34289. /**
  34290. * Gets the list of created postprocesses
  34291. */
  34292. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34293. /**
  34294. * Gets a boolean indicating if the pointer is currently locked
  34295. */
  34296. isPointerLock: boolean;
  34297. /**
  34298. * Observable event triggered each time the rendering canvas is resized
  34299. */
  34300. onResizeObservable: Observable<Engine>;
  34301. /**
  34302. * Observable event triggered each time the canvas loses focus
  34303. */
  34304. onCanvasBlurObservable: Observable<Engine>;
  34305. /**
  34306. * Observable event triggered each time the canvas gains focus
  34307. */
  34308. onCanvasFocusObservable: Observable<Engine>;
  34309. /**
  34310. * Observable event triggered each time the canvas receives pointerout event
  34311. */
  34312. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34313. /**
  34314. * Observable raised when the engine begins a new frame
  34315. */
  34316. onBeginFrameObservable: Observable<Engine>;
  34317. /**
  34318. * If set, will be used to request the next animation frame for the render loop
  34319. */
  34320. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34321. /**
  34322. * Observable raised when the engine ends the current frame
  34323. */
  34324. onEndFrameObservable: Observable<Engine>;
  34325. /**
  34326. * Observable raised when the engine is about to compile a shader
  34327. */
  34328. onBeforeShaderCompilationObservable: Observable<Engine>;
  34329. /**
  34330. * Observable raised when the engine has jsut compiled a shader
  34331. */
  34332. onAfterShaderCompilationObservable: Observable<Engine>;
  34333. /**
  34334. * Gets the audio engine
  34335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34336. * @ignorenaming
  34337. */
  34338. static audioEngine: IAudioEngine;
  34339. /**
  34340. * Default AudioEngine factory responsible of creating the Audio Engine.
  34341. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34342. */
  34343. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34344. /**
  34345. * Default offline support factory responsible of creating a tool used to store data locally.
  34346. * By default, this will create a Database object if the workload has been embedded.
  34347. */
  34348. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34349. private _loadingScreen;
  34350. private _pointerLockRequested;
  34351. private _dummyFramebuffer;
  34352. private _rescalePostProcess;
  34353. private _deterministicLockstep;
  34354. private _lockstepMaxSteps;
  34355. private _timeStep;
  34356. protected get _supportsHardwareTextureRescaling(): boolean;
  34357. private _fps;
  34358. private _deltaTime;
  34359. /** @hidden */
  34360. _drawCalls: PerfCounter;
  34361. /** 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 */
  34362. canvasTabIndex: number;
  34363. /**
  34364. * Turn this value on if you want to pause FPS computation when in background
  34365. */
  34366. disablePerformanceMonitorInBackground: boolean;
  34367. private _performanceMonitor;
  34368. /**
  34369. * Gets the performance monitor attached to this engine
  34370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34371. */
  34372. get performanceMonitor(): PerformanceMonitor;
  34373. private _onFocus;
  34374. private _onBlur;
  34375. private _onCanvasPointerOut;
  34376. private _onCanvasBlur;
  34377. private _onCanvasFocus;
  34378. private _onFullscreenChange;
  34379. private _onPointerLockChange;
  34380. /**
  34381. * Gets the HTML element used to attach event listeners
  34382. * @returns a HTML element
  34383. */
  34384. getInputElement(): Nullable<HTMLElement>;
  34385. /**
  34386. * Creates a new engine
  34387. * @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
  34388. * @param antialias defines enable antialiasing (default: false)
  34389. * @param options defines further options to be sent to the getContext() function
  34390. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34391. */
  34392. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34393. /**
  34394. * Gets current aspect ratio
  34395. * @param viewportOwner defines the camera to use to get the aspect ratio
  34396. * @param useScreen defines if screen size must be used (or the current render target if any)
  34397. * @returns a number defining the aspect ratio
  34398. */
  34399. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34400. /**
  34401. * Gets current screen aspect ratio
  34402. * @returns a number defining the aspect ratio
  34403. */
  34404. getScreenAspectRatio(): number;
  34405. /**
  34406. * Gets the client rect of the HTML canvas attached with the current webGL context
  34407. * @returns a client rectanglee
  34408. */
  34409. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34410. /**
  34411. * Gets the client rect of the HTML element used for events
  34412. * @returns a client rectanglee
  34413. */
  34414. getInputElementClientRect(): Nullable<ClientRect>;
  34415. /**
  34416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34418. * @returns true if engine is in deterministic lock step mode
  34419. */
  34420. isDeterministicLockStep(): boolean;
  34421. /**
  34422. * Gets the max steps when engine is running in deterministic lock step
  34423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34424. * @returns the max steps
  34425. */
  34426. getLockstepMaxSteps(): number;
  34427. /**
  34428. * Returns the time in ms between steps when using deterministic lock step.
  34429. * @returns time step in (ms)
  34430. */
  34431. getTimeStep(): number;
  34432. /**
  34433. * Force the mipmap generation for the given render target texture
  34434. * @param texture defines the render target texture to use
  34435. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34436. */
  34437. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34438. /** States */
  34439. /**
  34440. * Set various states to the webGL context
  34441. * @param culling defines backface culling state
  34442. * @param zOffset defines the value to apply to zOffset (0 by default)
  34443. * @param force defines if states must be applied even if cache is up to date
  34444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34445. */
  34446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34447. /**
  34448. * Set the z offset to apply to current rendering
  34449. * @param value defines the offset to apply
  34450. */
  34451. setZOffset(value: number): void;
  34452. /**
  34453. * Gets the current value of the zOffset
  34454. * @returns the current zOffset state
  34455. */
  34456. getZOffset(): number;
  34457. /**
  34458. * Enable or disable depth buffering
  34459. * @param enable defines the state to set
  34460. */
  34461. setDepthBuffer(enable: boolean): void;
  34462. /**
  34463. * Gets a boolean indicating if depth writing is enabled
  34464. * @returns the current depth writing state
  34465. */
  34466. getDepthWrite(): boolean;
  34467. /**
  34468. * Enable or disable depth writing
  34469. * @param enable defines the state to set
  34470. */
  34471. setDepthWrite(enable: boolean): void;
  34472. /**
  34473. * Gets a boolean indicating if stencil buffer is enabled
  34474. * @returns the current stencil buffer state
  34475. */
  34476. getStencilBuffer(): boolean;
  34477. /**
  34478. * Enable or disable the stencil buffer
  34479. * @param enable defines if the stencil buffer must be enabled or disabled
  34480. */
  34481. setStencilBuffer(enable: boolean): void;
  34482. /**
  34483. * Gets the current stencil mask
  34484. * @returns a number defining the new stencil mask to use
  34485. */
  34486. getStencilMask(): number;
  34487. /**
  34488. * Sets the current stencil mask
  34489. * @param mask defines the new stencil mask to use
  34490. */
  34491. setStencilMask(mask: number): void;
  34492. /**
  34493. * Gets the current stencil function
  34494. * @returns a number defining the stencil function to use
  34495. */
  34496. getStencilFunction(): number;
  34497. /**
  34498. * Gets the current stencil reference value
  34499. * @returns a number defining the stencil reference value to use
  34500. */
  34501. getStencilFunctionReference(): number;
  34502. /**
  34503. * Gets the current stencil mask
  34504. * @returns a number defining the stencil mask to use
  34505. */
  34506. getStencilFunctionMask(): number;
  34507. /**
  34508. * Sets the current stencil function
  34509. * @param stencilFunc defines the new stencil function to use
  34510. */
  34511. setStencilFunction(stencilFunc: number): void;
  34512. /**
  34513. * Sets the current stencil reference
  34514. * @param reference defines the new stencil reference to use
  34515. */
  34516. setStencilFunctionReference(reference: number): void;
  34517. /**
  34518. * Sets the current stencil mask
  34519. * @param mask defines the new stencil mask to use
  34520. */
  34521. setStencilFunctionMask(mask: number): void;
  34522. /**
  34523. * Gets the current stencil operation when stencil fails
  34524. * @returns a number defining stencil operation to use when stencil fails
  34525. */
  34526. getStencilOperationFail(): number;
  34527. /**
  34528. * Gets the current stencil operation when depth fails
  34529. * @returns a number defining stencil operation to use when depth fails
  34530. */
  34531. getStencilOperationDepthFail(): number;
  34532. /**
  34533. * Gets the current stencil operation when stencil passes
  34534. * @returns a number defining stencil operation to use when stencil passes
  34535. */
  34536. getStencilOperationPass(): number;
  34537. /**
  34538. * Sets the stencil operation to use when stencil fails
  34539. * @param operation defines the stencil operation to use when stencil fails
  34540. */
  34541. setStencilOperationFail(operation: number): void;
  34542. /**
  34543. * Sets the stencil operation to use when depth fails
  34544. * @param operation defines the stencil operation to use when depth fails
  34545. */
  34546. setStencilOperationDepthFail(operation: number): void;
  34547. /**
  34548. * Sets the stencil operation to use when stencil passes
  34549. * @param operation defines the stencil operation to use when stencil passes
  34550. */
  34551. setStencilOperationPass(operation: number): void;
  34552. /**
  34553. * Sets a boolean indicating if the dithering state is enabled or disabled
  34554. * @param value defines the dithering state
  34555. */
  34556. setDitheringState(value: boolean): void;
  34557. /**
  34558. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34559. * @param value defines the rasterizer state
  34560. */
  34561. setRasterizerState(value: boolean): void;
  34562. /**
  34563. * Gets the current depth function
  34564. * @returns a number defining the depth function
  34565. */
  34566. getDepthFunction(): Nullable<number>;
  34567. /**
  34568. * Sets the current depth function
  34569. * @param depthFunc defines the function to use
  34570. */
  34571. setDepthFunction(depthFunc: number): void;
  34572. /**
  34573. * Sets the current depth function to GREATER
  34574. */
  34575. setDepthFunctionToGreater(): void;
  34576. /**
  34577. * Sets the current depth function to GEQUAL
  34578. */
  34579. setDepthFunctionToGreaterOrEqual(): void;
  34580. /**
  34581. * Sets the current depth function to LESS
  34582. */
  34583. setDepthFunctionToLess(): void;
  34584. /**
  34585. * Sets the current depth function to LEQUAL
  34586. */
  34587. setDepthFunctionToLessOrEqual(): void;
  34588. private _cachedStencilBuffer;
  34589. private _cachedStencilFunction;
  34590. private _cachedStencilMask;
  34591. private _cachedStencilOperationPass;
  34592. private _cachedStencilOperationFail;
  34593. private _cachedStencilOperationDepthFail;
  34594. private _cachedStencilReference;
  34595. /**
  34596. * Caches the the state of the stencil buffer
  34597. */
  34598. cacheStencilState(): void;
  34599. /**
  34600. * Restores the state of the stencil buffer
  34601. */
  34602. restoreStencilState(): void;
  34603. /**
  34604. * Directly set the WebGL Viewport
  34605. * @param x defines the x coordinate of the viewport (in screen space)
  34606. * @param y defines the y coordinate of the viewport (in screen space)
  34607. * @param width defines the width of the viewport (in screen space)
  34608. * @param height defines the height of the viewport (in screen space)
  34609. * @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
  34610. */
  34611. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34612. /**
  34613. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34614. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34615. * @param y defines the y-coordinate of the corner of the clear rectangle
  34616. * @param width defines the width of the clear rectangle
  34617. * @param height defines the height of the clear rectangle
  34618. * @param clearColor defines the clear color
  34619. */
  34620. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34621. /**
  34622. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34623. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34624. * @param y defines the y-coordinate of the corner of the clear rectangle
  34625. * @param width defines the width of the clear rectangle
  34626. * @param height defines the height of the clear rectangle
  34627. */
  34628. enableScissor(x: number, y: number, width: number, height: number): void;
  34629. /**
  34630. * Disable previously set scissor test rectangle
  34631. */
  34632. disableScissor(): void;
  34633. protected _reportDrawCall(): void;
  34634. /**
  34635. * Initializes a webVR display and starts listening to display change events
  34636. * The onVRDisplayChangedObservable will be notified upon these changes
  34637. * @returns The onVRDisplayChangedObservable
  34638. */
  34639. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34640. /** @hidden */
  34641. _prepareVRComponent(): void;
  34642. /** @hidden */
  34643. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34644. /** @hidden */
  34645. _submitVRFrame(): void;
  34646. /**
  34647. * Call this function to leave webVR mode
  34648. * Will do nothing if webVR is not supported or if there is no webVR device
  34649. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34650. */
  34651. disableVR(): void;
  34652. /**
  34653. * Gets a boolean indicating that the system is in VR mode and is presenting
  34654. * @returns true if VR mode is engaged
  34655. */
  34656. isVRPresenting(): boolean;
  34657. /** @hidden */
  34658. _requestVRFrame(): void;
  34659. /** @hidden */
  34660. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34661. /**
  34662. * Gets the source code of the vertex shader associated with a specific webGL program
  34663. * @param program defines the program to use
  34664. * @returns a string containing the source code of the vertex shader associated with the program
  34665. */
  34666. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34667. /**
  34668. * Gets the source code of the fragment shader associated with a specific webGL program
  34669. * @param program defines the program to use
  34670. * @returns a string containing the source code of the fragment shader associated with the program
  34671. */
  34672. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34673. /**
  34674. * Sets a depth stencil texture from a render target to the according uniform.
  34675. * @param channel The texture channel
  34676. * @param uniform The uniform to set
  34677. * @param texture The render target texture containing the depth stencil texture to apply
  34678. */
  34679. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34680. /**
  34681. * Sets a texture to the webGL context from a postprocess
  34682. * @param channel defines the channel to use
  34683. * @param postProcess defines the source postprocess
  34684. */
  34685. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34686. /**
  34687. * Binds the output of the passed in post process to the texture channel specified
  34688. * @param channel The channel the texture should be bound to
  34689. * @param postProcess The post process which's output should be bound
  34690. */
  34691. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34692. /** @hidden */
  34693. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34694. protected _rebuildBuffers(): void;
  34695. /** @hidden */
  34696. _renderFrame(): void;
  34697. _renderLoop(): void;
  34698. /** @hidden */
  34699. _renderViews(): boolean;
  34700. /**
  34701. * Toggle full screen mode
  34702. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34703. */
  34704. switchFullscreen(requestPointerLock: boolean): void;
  34705. /**
  34706. * Enters full screen mode
  34707. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34708. */
  34709. enterFullscreen(requestPointerLock: boolean): void;
  34710. /**
  34711. * Exits full screen mode
  34712. */
  34713. exitFullscreen(): void;
  34714. /**
  34715. * Enters Pointerlock mode
  34716. */
  34717. enterPointerlock(): void;
  34718. /**
  34719. * Exits Pointerlock mode
  34720. */
  34721. exitPointerlock(): void;
  34722. /**
  34723. * Begin a new frame
  34724. */
  34725. beginFrame(): void;
  34726. /**
  34727. * Enf the current frame
  34728. */
  34729. endFrame(): void;
  34730. resize(): void;
  34731. /**
  34732. * Set the compressed texture format to use, based on the formats you have, and the formats
  34733. * supported by the hardware / browser.
  34734. *
  34735. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34736. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34737. * to API arguments needed to compressed textures. This puts the burden on the container
  34738. * generator to house the arcane code for determining these for current & future formats.
  34739. *
  34740. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34741. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34742. *
  34743. * Note: The result of this call is not taken into account when a texture is base64.
  34744. *
  34745. * @param formatsAvailable defines the list of those format families you have created
  34746. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34747. *
  34748. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34749. * @returns The extension selected.
  34750. */
  34751. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34752. /**
  34753. * Set the compressed texture extensions or file names to skip.
  34754. *
  34755. * @param skippedFiles defines the list of those texture files you want to skip
  34756. * Example: [".dds", ".env", "myfile.png"]
  34757. */
  34758. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34759. /**
  34760. * Force a specific size of the canvas
  34761. * @param width defines the new canvas' width
  34762. * @param height defines the new canvas' height
  34763. */
  34764. setSize(width: number, height: number): void;
  34765. /**
  34766. * Updates a dynamic vertex buffer.
  34767. * @param vertexBuffer the vertex buffer to update
  34768. * @param data the data used to update the vertex buffer
  34769. * @param byteOffset the byte offset of the data
  34770. * @param byteLength the byte length of the data
  34771. */
  34772. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34775. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34776. _releaseTexture(texture: InternalTexture): void;
  34777. /**
  34778. * @hidden
  34779. * Rescales a texture
  34780. * @param source input texutre
  34781. * @param destination destination texture
  34782. * @param scene scene to use to render the resize
  34783. * @param internalFormat format to use when resizing
  34784. * @param onComplete callback to be called when resize has completed
  34785. */
  34786. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34787. /**
  34788. * Gets the current framerate
  34789. * @returns a number representing the framerate
  34790. */
  34791. getFps(): number;
  34792. /**
  34793. * Gets the time spent between current and previous frame
  34794. * @returns a number representing the delta time in ms
  34795. */
  34796. getDeltaTime(): number;
  34797. private _measureFps;
  34798. /** @hidden */
  34799. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34800. /**
  34801. * Update a dynamic index buffer
  34802. * @param indexBuffer defines the target index buffer
  34803. * @param indices defines the data to update
  34804. * @param offset defines the offset in the target index buffer where update should start
  34805. */
  34806. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34807. /**
  34808. * Updates the sample count of a render target texture
  34809. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34810. * @param texture defines the texture to update
  34811. * @param samples defines the sample count to set
  34812. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34813. */
  34814. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34815. /**
  34816. * Updates a depth texture Comparison Mode and Function.
  34817. * If the comparison Function is equal to 0, the mode will be set to none.
  34818. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34819. * @param texture The texture to set the comparison function for
  34820. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34821. */
  34822. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34823. /**
  34824. * Creates a webGL buffer to use with instanciation
  34825. * @param capacity defines the size of the buffer
  34826. * @returns the webGL buffer
  34827. */
  34828. createInstancesBuffer(capacity: number): DataBuffer;
  34829. /**
  34830. * Delete a webGL buffer used with instanciation
  34831. * @param buffer defines the webGL buffer to delete
  34832. */
  34833. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34834. /** @hidden */
  34835. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34836. dispose(): void;
  34837. private _disableTouchAction;
  34838. /**
  34839. * Display the loading screen
  34840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34841. */
  34842. displayLoadingUI(): void;
  34843. /**
  34844. * Hide the loading screen
  34845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34846. */
  34847. hideLoadingUI(): void;
  34848. /**
  34849. * Gets the current loading screen object
  34850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34851. */
  34852. get loadingScreen(): ILoadingScreen;
  34853. /**
  34854. * Sets the current loading screen object
  34855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34856. */
  34857. set loadingScreen(loadingScreen: ILoadingScreen);
  34858. /**
  34859. * Sets the current loading screen text
  34860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34861. */
  34862. set loadingUIText(text: string);
  34863. /**
  34864. * Sets the current loading screen background color
  34865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34866. */
  34867. set loadingUIBackgroundColor(color: string);
  34868. /** Pointerlock and fullscreen */
  34869. /**
  34870. * Ask the browser to promote the current element to pointerlock mode
  34871. * @param element defines the DOM element to promote
  34872. */
  34873. static _RequestPointerlock(element: HTMLElement): void;
  34874. /**
  34875. * Asks the browser to exit pointerlock mode
  34876. */
  34877. static _ExitPointerlock(): void;
  34878. /**
  34879. * Ask the browser to promote the current element to fullscreen rendering mode
  34880. * @param element defines the DOM element to promote
  34881. */
  34882. static _RequestFullscreen(element: HTMLElement): void;
  34883. /**
  34884. * Asks the browser to exit fullscreen mode
  34885. */
  34886. static _ExitFullscreen(): void;
  34887. }
  34888. }
  34889. declare module "babylonjs/Engines/engineStore" {
  34890. import { Nullable } from "babylonjs/types";
  34891. import { Engine } from "babylonjs/Engines/engine";
  34892. import { Scene } from "babylonjs/scene";
  34893. /**
  34894. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34895. * during the life time of the application.
  34896. */
  34897. export class EngineStore {
  34898. /** Gets the list of created engines */
  34899. static Instances: import("babylonjs/Engines/engine").Engine[];
  34900. /** @hidden */
  34901. static _LastCreatedScene: Nullable<Scene>;
  34902. /**
  34903. * Gets the latest created engine
  34904. */
  34905. static get LastCreatedEngine(): Nullable<Engine>;
  34906. /**
  34907. * Gets the latest created scene
  34908. */
  34909. static get LastCreatedScene(): Nullable<Scene>;
  34910. /**
  34911. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34912. * @ignorenaming
  34913. */
  34914. static UseFallbackTexture: boolean;
  34915. /**
  34916. * Texture content used if a texture cannot loaded
  34917. * @ignorenaming
  34918. */
  34919. static FallbackTexture: string;
  34920. }
  34921. }
  34922. declare module "babylonjs/Misc/promise" {
  34923. /**
  34924. * Helper class that provides a small promise polyfill
  34925. */
  34926. export class PromisePolyfill {
  34927. /**
  34928. * Static function used to check if the polyfill is required
  34929. * If this is the case then the function will inject the polyfill to window.Promise
  34930. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34931. */
  34932. static Apply(force?: boolean): void;
  34933. }
  34934. }
  34935. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34936. /**
  34937. * Interface for screenshot methods with describe argument called `size` as object with options
  34938. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34939. */
  34940. export interface IScreenshotSize {
  34941. /**
  34942. * number in pixels for canvas height
  34943. */
  34944. height?: number;
  34945. /**
  34946. * multiplier allowing render at a higher or lower resolution
  34947. * If value is defined then height and width will be ignored and taken from camera
  34948. */
  34949. precision?: number;
  34950. /**
  34951. * number in pixels for canvas width
  34952. */
  34953. width?: number;
  34954. }
  34955. }
  34956. declare module "babylonjs/Misc/tools" {
  34957. import { Nullable, float } from "babylonjs/types";
  34958. import { DomManagement } from "babylonjs/Misc/domManagement";
  34959. import { WebRequest } from "babylonjs/Misc/webRequest";
  34960. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34961. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34962. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34963. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34964. import { Camera } from "babylonjs/Cameras/camera";
  34965. import { Engine } from "babylonjs/Engines/engine";
  34966. interface IColor4Like {
  34967. r: float;
  34968. g: float;
  34969. b: float;
  34970. a: float;
  34971. }
  34972. /**
  34973. * Class containing a set of static utilities functions
  34974. */
  34975. export class Tools {
  34976. /**
  34977. * Gets or sets the base URL to use to load assets
  34978. */
  34979. static get BaseUrl(): string;
  34980. static set BaseUrl(value: string);
  34981. /**
  34982. * Enable/Disable Custom HTTP Request Headers globally.
  34983. * default = false
  34984. * @see CustomRequestHeaders
  34985. */
  34986. static UseCustomRequestHeaders: boolean;
  34987. /**
  34988. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34989. * i.e. when loading files, where the server/service expects an Authorization header
  34990. */
  34991. static CustomRequestHeaders: {
  34992. [key: string]: string;
  34993. };
  34994. /**
  34995. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34996. */
  34997. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34998. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34999. /**
  35000. * Default behaviour for cors in the application.
  35001. * It can be a string if the expected behavior is identical in the entire app.
  35002. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35003. */
  35004. static CorsBehavior: string | ((url: string | string[]) => string);
  35005. /**
  35006. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35007. * @ignorenaming
  35008. */
  35009. static get UseFallbackTexture(): boolean;
  35010. static set UseFallbackTexture(value: boolean);
  35011. /**
  35012. * Use this object to register external classes like custom textures or material
  35013. * to allow the laoders to instantiate them
  35014. */
  35015. static get RegisteredExternalClasses(): {
  35016. [key: string]: Object;
  35017. };
  35018. static set RegisteredExternalClasses(classes: {
  35019. [key: string]: Object;
  35020. });
  35021. /**
  35022. * Texture content used if a texture cannot loaded
  35023. * @ignorenaming
  35024. */
  35025. static get fallbackTexture(): string;
  35026. static set fallbackTexture(value: string);
  35027. /**
  35028. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35029. * @param u defines the coordinate on X axis
  35030. * @param v defines the coordinate on Y axis
  35031. * @param width defines the width of the source data
  35032. * @param height defines the height of the source data
  35033. * @param pixels defines the source byte array
  35034. * @param color defines the output color
  35035. */
  35036. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35037. /**
  35038. * Interpolates between a and b via alpha
  35039. * @param a The lower value (returned when alpha = 0)
  35040. * @param b The upper value (returned when alpha = 1)
  35041. * @param alpha The interpolation-factor
  35042. * @return The mixed value
  35043. */
  35044. static Mix(a: number, b: number, alpha: number): number;
  35045. /**
  35046. * Tries to instantiate a new object from a given class name
  35047. * @param className defines the class name to instantiate
  35048. * @returns the new object or null if the system was not able to do the instantiation
  35049. */
  35050. static Instantiate(className: string): any;
  35051. /**
  35052. * Provides a slice function that will work even on IE
  35053. * @param data defines the array to slice
  35054. * @param start defines the start of the data (optional)
  35055. * @param end defines the end of the data (optional)
  35056. * @returns the new sliced array
  35057. */
  35058. static Slice<T>(data: T, start?: number, end?: number): T;
  35059. /**
  35060. * Polyfill for setImmediate
  35061. * @param action defines the action to execute after the current execution block
  35062. */
  35063. static SetImmediate(action: () => void): void;
  35064. /**
  35065. * Function indicating if a number is an exponent of 2
  35066. * @param value defines the value to test
  35067. * @returns true if the value is an exponent of 2
  35068. */
  35069. static IsExponentOfTwo(value: number): boolean;
  35070. private static _tmpFloatArray;
  35071. /**
  35072. * Returns the nearest 32-bit single precision float representation of a Number
  35073. * @param value A Number. If the parameter is of a different type, it will get converted
  35074. * to a number or to NaN if it cannot be converted
  35075. * @returns number
  35076. */
  35077. static FloatRound(value: number): number;
  35078. /**
  35079. * Extracts the filename from a path
  35080. * @param path defines the path to use
  35081. * @returns the filename
  35082. */
  35083. static GetFilename(path: string): string;
  35084. /**
  35085. * Extracts the "folder" part of a path (everything before the filename).
  35086. * @param uri The URI to extract the info from
  35087. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35088. * @returns The "folder" part of the path
  35089. */
  35090. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35091. /**
  35092. * Extracts text content from a DOM element hierarchy
  35093. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35094. */
  35095. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35096. /**
  35097. * Convert an angle in radians to degrees
  35098. * @param angle defines the angle to convert
  35099. * @returns the angle in degrees
  35100. */
  35101. static ToDegrees(angle: number): number;
  35102. /**
  35103. * Convert an angle in degrees to radians
  35104. * @param angle defines the angle to convert
  35105. * @returns the angle in radians
  35106. */
  35107. static ToRadians(angle: number): number;
  35108. /**
  35109. * Returns an array if obj is not an array
  35110. * @param obj defines the object to evaluate as an array
  35111. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35112. * @returns either obj directly if obj is an array or a new array containing obj
  35113. */
  35114. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35115. /**
  35116. * Gets the pointer prefix to use
  35117. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35118. */
  35119. static GetPointerPrefix(): string;
  35120. /**
  35121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35122. * @param url define the url we are trying
  35123. * @param element define the dom element where to configure the cors policy
  35124. */
  35125. static SetCorsBehavior(url: string | string[], element: {
  35126. crossOrigin: string | null;
  35127. }): void;
  35128. /**
  35129. * Removes unwanted characters from an url
  35130. * @param url defines the url to clean
  35131. * @returns the cleaned url
  35132. */
  35133. static CleanUrl(url: string): string;
  35134. /**
  35135. * Gets or sets a function used to pre-process url before using them to load assets
  35136. */
  35137. static get PreprocessUrl(): (url: string) => string;
  35138. static set PreprocessUrl(processor: (url: string) => string);
  35139. /**
  35140. * Loads an image as an HTMLImageElement.
  35141. * @param input url string, ArrayBuffer, or Blob to load
  35142. * @param onLoad callback called when the image successfully loads
  35143. * @param onError callback called when the image fails to load
  35144. * @param offlineProvider offline provider for caching
  35145. * @param mimeType optional mime type
  35146. * @returns the HTMLImageElement of the loaded image
  35147. */
  35148. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35149. /**
  35150. * Loads a file from a url
  35151. * @param url url string, ArrayBuffer, or Blob to load
  35152. * @param onSuccess callback called when the file successfully loads
  35153. * @param onProgress callback called while file is loading (if the server supports this mode)
  35154. * @param offlineProvider defines the offline provider for caching
  35155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35156. * @param onError callback called when the file fails to load
  35157. * @returns a file request object
  35158. */
  35159. 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;
  35160. /**
  35161. * Loads a file from a url
  35162. * @param url the file url to load
  35163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35164. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35165. */
  35166. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35167. /**
  35168. * Load a script (identified by an url). When the url returns, the
  35169. * content of this file is added into a new script element, attached to the DOM (body element)
  35170. * @param scriptUrl defines the url of the script to laod
  35171. * @param onSuccess defines the callback called when the script is loaded
  35172. * @param onError defines the callback to call if an error occurs
  35173. * @param scriptId defines the id of the script element
  35174. */
  35175. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35176. /**
  35177. * Load an asynchronous script (identified by an url). When the url returns, the
  35178. * content of this file is added into a new script element, attached to the DOM (body element)
  35179. * @param scriptUrl defines the url of the script to laod
  35180. * @param scriptId defines the id of the script element
  35181. * @returns a promise request object
  35182. */
  35183. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35184. /**
  35185. * Loads a file from a blob
  35186. * @param fileToLoad defines the blob to use
  35187. * @param callback defines the callback to call when data is loaded
  35188. * @param progressCallback defines the callback to call during loading process
  35189. * @returns a file request object
  35190. */
  35191. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35192. /**
  35193. * Reads a file from a File object
  35194. * @param file defines the file to load
  35195. * @param onSuccess defines the callback to call when data is loaded
  35196. * @param onProgress defines the callback to call during loading process
  35197. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35198. * @param onError defines the callback to call when an error occurs
  35199. * @returns a file request object
  35200. */
  35201. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35202. /**
  35203. * Creates a data url from a given string content
  35204. * @param content defines the content to convert
  35205. * @returns the new data url link
  35206. */
  35207. static FileAsURL(content: string): string;
  35208. /**
  35209. * Format the given number to a specific decimal format
  35210. * @param value defines the number to format
  35211. * @param decimals defines the number of decimals to use
  35212. * @returns the formatted string
  35213. */
  35214. static Format(value: number, decimals?: number): string;
  35215. /**
  35216. * Tries to copy an object by duplicating every property
  35217. * @param source defines the source object
  35218. * @param destination defines the target object
  35219. * @param doNotCopyList defines a list of properties to avoid
  35220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35221. */
  35222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35223. /**
  35224. * Gets a boolean indicating if the given object has no own property
  35225. * @param obj defines the object to test
  35226. * @returns true if object has no own property
  35227. */
  35228. static IsEmpty(obj: any): boolean;
  35229. /**
  35230. * Function used to register events at window level
  35231. * @param windowElement defines the Window object to use
  35232. * @param events defines the events to register
  35233. */
  35234. static RegisterTopRootEvents(windowElement: Window, events: {
  35235. name: string;
  35236. handler: Nullable<(e: FocusEvent) => any>;
  35237. }[]): void;
  35238. /**
  35239. * Function used to unregister events from window level
  35240. * @param windowElement defines the Window object to use
  35241. * @param events defines the events to unregister
  35242. */
  35243. static UnregisterTopRootEvents(windowElement: Window, events: {
  35244. name: string;
  35245. handler: Nullable<(e: FocusEvent) => any>;
  35246. }[]): void;
  35247. /**
  35248. * @ignore
  35249. */
  35250. static _ScreenshotCanvas: HTMLCanvasElement;
  35251. /**
  35252. * Dumps the current bound framebuffer
  35253. * @param width defines the rendering width
  35254. * @param height defines the rendering height
  35255. * @param engine defines the hosting engine
  35256. * @param successCallback defines the callback triggered once the data are available
  35257. * @param mimeType defines the mime type of the result
  35258. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35259. */
  35260. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35261. /**
  35262. * Converts the canvas data to blob.
  35263. * This acts as a polyfill for browsers not supporting the to blob function.
  35264. * @param canvas Defines the canvas to extract the data from
  35265. * @param successCallback Defines the callback triggered once the data are available
  35266. * @param mimeType Defines the mime type of the result
  35267. */
  35268. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35269. /**
  35270. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35271. * @param successCallback defines the callback triggered once the data are available
  35272. * @param mimeType defines the mime type of the result
  35273. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35274. */
  35275. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35276. /**
  35277. * Downloads a blob in the browser
  35278. * @param blob defines the blob to download
  35279. * @param fileName defines the name of the downloaded file
  35280. */
  35281. static Download(blob: Blob, fileName: string): void;
  35282. /**
  35283. * Captures a screenshot of the current rendering
  35284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35285. * @param engine defines the rendering engine
  35286. * @param camera defines the source camera
  35287. * @param size This parameter can be set to a single number or to an object with the
  35288. * following (optional) properties: precision, width, height. If a single number is passed,
  35289. * it will be used for both width and height. If an object is passed, the screenshot size
  35290. * will be derived from the parameters. The precision property is a multiplier allowing
  35291. * rendering at a higher or lower resolution
  35292. * @param successCallback defines the callback receives a single parameter which contains the
  35293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35294. * src parameter of an <img> to display it
  35295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35296. * Check your browser for supported MIME types
  35297. */
  35298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35299. /**
  35300. * Captures a screenshot of the current rendering
  35301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35302. * @param engine defines the rendering engine
  35303. * @param camera defines the source camera
  35304. * @param size This parameter can be set to a single number or to an object with the
  35305. * following (optional) properties: precision, width, height. If a single number is passed,
  35306. * it will be used for both width and height. If an object is passed, the screenshot size
  35307. * will be derived from the parameters. The precision property is a multiplier allowing
  35308. * rendering at a higher or lower resolution
  35309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35310. * Check your browser for supported MIME types
  35311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35312. * to the src parameter of an <img> to display it
  35313. */
  35314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35315. /**
  35316. * Generates an image screenshot from the specified camera.
  35317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35318. * @param engine The engine to use for rendering
  35319. * @param camera The camera to use for rendering
  35320. * @param size This parameter can be set to a single number or to an object with the
  35321. * following (optional) properties: precision, width, height. If a single number is passed,
  35322. * it will be used for both width and height. If an object is passed, the screenshot size
  35323. * will be derived from the parameters. The precision property is a multiplier allowing
  35324. * rendering at a higher or lower resolution
  35325. * @param successCallback The callback receives a single parameter which contains the
  35326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35327. * src parameter of an <img> to display it
  35328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35329. * Check your browser for supported MIME types
  35330. * @param samples Texture samples (default: 1)
  35331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35332. * @param fileName A name for for the downloaded file.
  35333. */
  35334. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35335. /**
  35336. * Generates an image screenshot from the specified camera.
  35337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35338. * @param engine The engine to use for rendering
  35339. * @param camera The camera to use for rendering
  35340. * @param size This parameter can be set to a single number or to an object with the
  35341. * following (optional) properties: precision, width, height. If a single number is passed,
  35342. * it will be used for both width and height. If an object is passed, the screenshot size
  35343. * will be derived from the parameters. The precision property is a multiplier allowing
  35344. * rendering at a higher or lower resolution
  35345. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35346. * Check your browser for supported MIME types
  35347. * @param samples Texture samples (default: 1)
  35348. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35349. * @param fileName A name for for the downloaded file.
  35350. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35351. * to the src parameter of an <img> to display it
  35352. */
  35353. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35354. /**
  35355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35356. * Be aware Math.random() could cause collisions, but:
  35357. * "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"
  35358. * @returns a pseudo random id
  35359. */
  35360. static RandomId(): string;
  35361. /**
  35362. * Test if the given uri is a base64 string
  35363. * @param uri The uri to test
  35364. * @return True if the uri is a base64 string or false otherwise
  35365. */
  35366. static IsBase64(uri: string): boolean;
  35367. /**
  35368. * Decode the given base64 uri.
  35369. * @param uri The uri to decode
  35370. * @return The decoded base64 data.
  35371. */
  35372. static DecodeBase64(uri: string): ArrayBuffer;
  35373. /**
  35374. * Gets the absolute url.
  35375. * @param url the input url
  35376. * @return the absolute url
  35377. */
  35378. static GetAbsoluteUrl(url: string): string;
  35379. /**
  35380. * No log
  35381. */
  35382. static readonly NoneLogLevel: number;
  35383. /**
  35384. * Only message logs
  35385. */
  35386. static readonly MessageLogLevel: number;
  35387. /**
  35388. * Only warning logs
  35389. */
  35390. static readonly WarningLogLevel: number;
  35391. /**
  35392. * Only error logs
  35393. */
  35394. static readonly ErrorLogLevel: number;
  35395. /**
  35396. * All logs
  35397. */
  35398. static readonly AllLogLevel: number;
  35399. /**
  35400. * Gets a value indicating the number of loading errors
  35401. * @ignorenaming
  35402. */
  35403. static get errorsCount(): number;
  35404. /**
  35405. * Callback called when a new log is added
  35406. */
  35407. static OnNewCacheEntry: (entry: string) => void;
  35408. /**
  35409. * Log a message to the console
  35410. * @param message defines the message to log
  35411. */
  35412. static Log(message: string): void;
  35413. /**
  35414. * Write a warning message to the console
  35415. * @param message defines the message to log
  35416. */
  35417. static Warn(message: string): void;
  35418. /**
  35419. * Write an error message to the console
  35420. * @param message defines the message to log
  35421. */
  35422. static Error(message: string): void;
  35423. /**
  35424. * Gets current log cache (list of logs)
  35425. */
  35426. static get LogCache(): string;
  35427. /**
  35428. * Clears the log cache
  35429. */
  35430. static ClearLogCache(): void;
  35431. /**
  35432. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35433. */
  35434. static set LogLevels(level: number);
  35435. /**
  35436. * Checks if the window object exists
  35437. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35438. */
  35439. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35440. /**
  35441. * No performance log
  35442. */
  35443. static readonly PerformanceNoneLogLevel: number;
  35444. /**
  35445. * Use user marks to log performance
  35446. */
  35447. static readonly PerformanceUserMarkLogLevel: number;
  35448. /**
  35449. * Log performance to the console
  35450. */
  35451. static readonly PerformanceConsoleLogLevel: number;
  35452. private static _performance;
  35453. /**
  35454. * Sets the current performance log level
  35455. */
  35456. static set PerformanceLogLevel(level: number);
  35457. private static _StartPerformanceCounterDisabled;
  35458. private static _EndPerformanceCounterDisabled;
  35459. private static _StartUserMark;
  35460. private static _EndUserMark;
  35461. private static _StartPerformanceConsole;
  35462. private static _EndPerformanceConsole;
  35463. /**
  35464. * Starts a performance counter
  35465. */
  35466. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35467. /**
  35468. * Ends a specific performance coutner
  35469. */
  35470. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35471. /**
  35472. * Gets either window.performance.now() if supported or Date.now() else
  35473. */
  35474. static get Now(): number;
  35475. /**
  35476. * This method will return the name of the class used to create the instance of the given object.
  35477. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35478. * @param object the object to get the class name from
  35479. * @param isType defines if the object is actually a type
  35480. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35481. */
  35482. static GetClassName(object: any, isType?: boolean): string;
  35483. /**
  35484. * Gets the first element of an array satisfying a given predicate
  35485. * @param array defines the array to browse
  35486. * @param predicate defines the predicate to use
  35487. * @returns null if not found or the element
  35488. */
  35489. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35490. /**
  35491. * This method will return the name of the full name of the class, including its owning module (if any).
  35492. * 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).
  35493. * @param object the object to get the class name from
  35494. * @param isType defines if the object is actually a type
  35495. * @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.
  35496. * @ignorenaming
  35497. */
  35498. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35499. /**
  35500. * Returns a promise that resolves after the given amount of time.
  35501. * @param delay Number of milliseconds to delay
  35502. * @returns Promise that resolves after the given amount of time
  35503. */
  35504. static DelayAsync(delay: number): Promise<void>;
  35505. /**
  35506. * Utility function to detect if the current user agent is Safari
  35507. * @returns whether or not the current user agent is safari
  35508. */
  35509. static IsSafari(): boolean;
  35510. }
  35511. /**
  35512. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35513. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35514. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35515. * @param name The name of the class, case should be preserved
  35516. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35517. */
  35518. export function className(name: string, module?: string): (target: Object) => void;
  35519. /**
  35520. * An implementation of a loop for asynchronous functions.
  35521. */
  35522. export class AsyncLoop {
  35523. /**
  35524. * Defines the number of iterations for the loop
  35525. */
  35526. iterations: number;
  35527. /**
  35528. * Defines the current index of the loop.
  35529. */
  35530. index: number;
  35531. private _done;
  35532. private _fn;
  35533. private _successCallback;
  35534. /**
  35535. * Constructor.
  35536. * @param iterations the number of iterations.
  35537. * @param func the function to run each iteration
  35538. * @param successCallback the callback that will be called upon succesful execution
  35539. * @param offset starting offset.
  35540. */
  35541. constructor(
  35542. /**
  35543. * Defines the number of iterations for the loop
  35544. */
  35545. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35546. /**
  35547. * Execute the next iteration. Must be called after the last iteration was finished.
  35548. */
  35549. executeNext(): void;
  35550. /**
  35551. * Break the loop and run the success callback.
  35552. */
  35553. breakLoop(): void;
  35554. /**
  35555. * Create and run an async loop.
  35556. * @param iterations the number of iterations.
  35557. * @param fn the function to run each iteration
  35558. * @param successCallback the callback that will be called upon succesful execution
  35559. * @param offset starting offset.
  35560. * @returns the created async loop object
  35561. */
  35562. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35563. /**
  35564. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35565. * @param iterations total number of iterations
  35566. * @param syncedIterations number of synchronous iterations in each async iteration.
  35567. * @param fn the function to call each iteration.
  35568. * @param callback a success call back that will be called when iterating stops.
  35569. * @param breakFunction a break condition (optional)
  35570. * @param timeout timeout settings for the setTimeout function. default - 0.
  35571. * @returns the created async loop object
  35572. */
  35573. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35574. }
  35575. }
  35576. declare module "babylonjs/Misc/stringDictionary" {
  35577. import { Nullable } from "babylonjs/types";
  35578. /**
  35579. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35580. * The underlying implementation relies on an associative array to ensure the best performances.
  35581. * The value can be anything including 'null' but except 'undefined'
  35582. */
  35583. export class StringDictionary<T> {
  35584. /**
  35585. * This will clear this dictionary and copy the content from the 'source' one.
  35586. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35587. * @param source the dictionary to take the content from and copy to this dictionary
  35588. */
  35589. copyFrom(source: StringDictionary<T>): void;
  35590. /**
  35591. * Get a value based from its key
  35592. * @param key the given key to get the matching value from
  35593. * @return the value if found, otherwise undefined is returned
  35594. */
  35595. get(key: string): T | undefined;
  35596. /**
  35597. * Get a value from its key or add it if it doesn't exist.
  35598. * This method will ensure you that a given key/data will be present in the dictionary.
  35599. * @param key the given key to get the matching value from
  35600. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35601. * The factory will only be invoked if there's no data for the given key.
  35602. * @return the value corresponding to the key.
  35603. */
  35604. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35605. /**
  35606. * Get a value from its key if present in the dictionary otherwise add it
  35607. * @param key the key to get the value from
  35608. * @param val if there's no such key/value pair in the dictionary add it with this value
  35609. * @return the value corresponding to the key
  35610. */
  35611. getOrAdd(key: string, val: T): T;
  35612. /**
  35613. * Check if there's a given key in the dictionary
  35614. * @param key the key to check for
  35615. * @return true if the key is present, false otherwise
  35616. */
  35617. contains(key: string): boolean;
  35618. /**
  35619. * Add a new key and its corresponding value
  35620. * @param key the key to add
  35621. * @param value the value corresponding to the key
  35622. * @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
  35623. */
  35624. add(key: string, value: T): boolean;
  35625. /**
  35626. * Update a specific value associated to a key
  35627. * @param key defines the key to use
  35628. * @param value defines the value to store
  35629. * @returns true if the value was updated (or false if the key was not found)
  35630. */
  35631. set(key: string, value: T): boolean;
  35632. /**
  35633. * Get the element of the given key and remove it from the dictionary
  35634. * @param key defines the key to search
  35635. * @returns the value associated with the key or null if not found
  35636. */
  35637. getAndRemove(key: string): Nullable<T>;
  35638. /**
  35639. * Remove a key/value from the dictionary.
  35640. * @param key the key to remove
  35641. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35642. */
  35643. remove(key: string): boolean;
  35644. /**
  35645. * Clear the whole content of the dictionary
  35646. */
  35647. clear(): void;
  35648. /**
  35649. * Gets the current count
  35650. */
  35651. get count(): number;
  35652. /**
  35653. * Execute a callback on each key/val of the dictionary.
  35654. * Note that you can remove any element in this dictionary in the callback implementation
  35655. * @param callback the callback to execute on a given key/value pair
  35656. */
  35657. forEach(callback: (key: string, val: T) => void): void;
  35658. /**
  35659. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35660. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35661. * Note that you can remove any element in this dictionary in the callback implementation
  35662. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35663. * @returns the first item
  35664. */
  35665. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35666. private _count;
  35667. private _data;
  35668. }
  35669. }
  35670. declare module "babylonjs/Collisions/collisionCoordinator" {
  35671. import { Nullable } from "babylonjs/types";
  35672. import { Scene } from "babylonjs/scene";
  35673. import { Vector3 } from "babylonjs/Maths/math.vector";
  35674. import { Collider } from "babylonjs/Collisions/collider";
  35675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35676. /** @hidden */
  35677. export interface ICollisionCoordinator {
  35678. createCollider(): Collider;
  35679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35680. init(scene: Scene): void;
  35681. }
  35682. /** @hidden */
  35683. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35684. private _scene;
  35685. private _scaledPosition;
  35686. private _scaledVelocity;
  35687. private _finalPosition;
  35688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35689. createCollider(): Collider;
  35690. init(scene: Scene): void;
  35691. private _collideWithWorld;
  35692. }
  35693. }
  35694. declare module "babylonjs/Inputs/scene.inputManager" {
  35695. import { Nullable } from "babylonjs/types";
  35696. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35697. import { Vector2 } from "babylonjs/Maths/math.vector";
  35698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35699. import { Scene } from "babylonjs/scene";
  35700. /**
  35701. * Class used to manage all inputs for the scene.
  35702. */
  35703. export class InputManager {
  35704. /** The distance in pixel that you have to move to prevent some events */
  35705. static DragMovementThreshold: number;
  35706. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35707. static LongPressDelay: number;
  35708. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35709. static DoubleClickDelay: number;
  35710. /** If you need to check double click without raising a single click at first click, enable this flag */
  35711. static ExclusiveDoubleClickMode: boolean;
  35712. private _wheelEventName;
  35713. private _onPointerMove;
  35714. private _onPointerDown;
  35715. private _onPointerUp;
  35716. private _initClickEvent;
  35717. private _initActionManager;
  35718. private _delayedSimpleClick;
  35719. private _delayedSimpleClickTimeout;
  35720. private _previousDelayedSimpleClickTimeout;
  35721. private _meshPickProceed;
  35722. private _previousButtonPressed;
  35723. private _currentPickResult;
  35724. private _previousPickResult;
  35725. private _totalPointersPressed;
  35726. private _doubleClickOccured;
  35727. private _pointerOverMesh;
  35728. private _pickedDownMesh;
  35729. private _pickedUpMesh;
  35730. private _pointerX;
  35731. private _pointerY;
  35732. private _unTranslatedPointerX;
  35733. private _unTranslatedPointerY;
  35734. private _startingPointerPosition;
  35735. private _previousStartingPointerPosition;
  35736. private _startingPointerTime;
  35737. private _previousStartingPointerTime;
  35738. private _pointerCaptures;
  35739. private _onKeyDown;
  35740. private _onKeyUp;
  35741. private _onCanvasFocusObserver;
  35742. private _onCanvasBlurObserver;
  35743. private _scene;
  35744. /**
  35745. * Creates a new InputManager
  35746. * @param scene defines the hosting scene
  35747. */
  35748. constructor(scene: Scene);
  35749. /**
  35750. * Gets the mesh that is currently under the pointer
  35751. */
  35752. get meshUnderPointer(): Nullable<AbstractMesh>;
  35753. /**
  35754. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35755. */
  35756. get unTranslatedPointer(): Vector2;
  35757. /**
  35758. * Gets or sets the current on-screen X position of the pointer
  35759. */
  35760. get pointerX(): number;
  35761. set pointerX(value: number);
  35762. /**
  35763. * Gets or sets the current on-screen Y position of the pointer
  35764. */
  35765. get pointerY(): number;
  35766. set pointerY(value: number);
  35767. private _updatePointerPosition;
  35768. private _processPointerMove;
  35769. private _setRayOnPointerInfo;
  35770. private _checkPrePointerObservable;
  35771. /**
  35772. * Use this method to simulate a pointer move on a mesh
  35773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35776. */
  35777. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35778. /**
  35779. * Use this method to simulate a pointer down on a mesh
  35780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35783. */
  35784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35785. private _processPointerDown;
  35786. /** @hidden */
  35787. _isPointerSwiping(): boolean;
  35788. /**
  35789. * Use this method to simulate a pointer up on a mesh
  35790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35793. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35794. */
  35795. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35796. private _processPointerUp;
  35797. /**
  35798. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35799. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35800. * @returns true if the pointer was captured
  35801. */
  35802. isPointerCaptured(pointerId?: number): boolean;
  35803. /**
  35804. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35805. * @param attachUp defines if you want to attach events to pointerup
  35806. * @param attachDown defines if you want to attach events to pointerdown
  35807. * @param attachMove defines if you want to attach events to pointermove
  35808. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35809. */
  35810. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35811. /**
  35812. * Detaches all event handlers
  35813. */
  35814. detachControl(): void;
  35815. /**
  35816. * Force the value of meshUnderPointer
  35817. * @param mesh defines the mesh to use
  35818. */
  35819. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35820. /**
  35821. * Gets the mesh under the pointer
  35822. * @returns a Mesh or null if no mesh is under the pointer
  35823. */
  35824. getPointerOverMesh(): Nullable<AbstractMesh>;
  35825. }
  35826. }
  35827. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35828. /**
  35829. * Helper class used to generate session unique ID
  35830. */
  35831. export class UniqueIdGenerator {
  35832. private static _UniqueIdCounter;
  35833. /**
  35834. * Gets an unique (relatively to the current scene) Id
  35835. */
  35836. static get UniqueId(): number;
  35837. }
  35838. }
  35839. declare module "babylonjs/Animations/animationGroup" {
  35840. import { Animatable } from "babylonjs/Animations/animatable";
  35841. import { Animation } from "babylonjs/Animations/animation";
  35842. import { Scene, IDisposable } from "babylonjs/scene";
  35843. import { Observable } from "babylonjs/Misc/observable";
  35844. import { Nullable } from "babylonjs/types";
  35845. import "babylonjs/Animations/animatable";
  35846. /**
  35847. * This class defines the direct association between an animation and a target
  35848. */
  35849. export class TargetedAnimation {
  35850. /**
  35851. * Animation to perform
  35852. */
  35853. animation: Animation;
  35854. /**
  35855. * Target to animate
  35856. */
  35857. target: any;
  35858. /**
  35859. * Serialize the object
  35860. * @returns the JSON object representing the current entity
  35861. */
  35862. serialize(): any;
  35863. }
  35864. /**
  35865. * Use this class to create coordinated animations on multiple targets
  35866. */
  35867. export class AnimationGroup implements IDisposable {
  35868. /** The name of the animation group */
  35869. name: string;
  35870. private _scene;
  35871. private _targetedAnimations;
  35872. private _animatables;
  35873. private _from;
  35874. private _to;
  35875. private _isStarted;
  35876. private _isPaused;
  35877. private _speedRatio;
  35878. private _loopAnimation;
  35879. /**
  35880. * Gets or sets the unique id of the node
  35881. */
  35882. uniqueId: number;
  35883. /**
  35884. * This observable will notify when one animation have ended
  35885. */
  35886. onAnimationEndObservable: Observable<TargetedAnimation>;
  35887. /**
  35888. * Observer raised when one animation loops
  35889. */
  35890. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35891. /**
  35892. * Observer raised when all animations have looped
  35893. */
  35894. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35895. /**
  35896. * This observable will notify when all animations have ended.
  35897. */
  35898. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35899. /**
  35900. * This observable will notify when all animations have paused.
  35901. */
  35902. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35903. /**
  35904. * This observable will notify when all animations are playing.
  35905. */
  35906. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35907. /**
  35908. * Gets the first frame
  35909. */
  35910. get from(): number;
  35911. /**
  35912. * Gets the last frame
  35913. */
  35914. get to(): number;
  35915. /**
  35916. * Define if the animations are started
  35917. */
  35918. get isStarted(): boolean;
  35919. /**
  35920. * Gets a value indicating that the current group is playing
  35921. */
  35922. get isPlaying(): boolean;
  35923. /**
  35924. * Gets or sets the speed ratio to use for all animations
  35925. */
  35926. get speedRatio(): number;
  35927. /**
  35928. * Gets or sets the speed ratio to use for all animations
  35929. */
  35930. set speedRatio(value: number);
  35931. /**
  35932. * Gets or sets if all animations should loop or not
  35933. */
  35934. get loopAnimation(): boolean;
  35935. set loopAnimation(value: boolean);
  35936. /**
  35937. * Gets the targeted animations for this animation group
  35938. */
  35939. get targetedAnimations(): Array<TargetedAnimation>;
  35940. /**
  35941. * returning the list of animatables controlled by this animation group.
  35942. */
  35943. get animatables(): Array<Animatable>;
  35944. /**
  35945. * Instantiates a new Animation Group.
  35946. * This helps managing several animations at once.
  35947. * @see http://doc.babylonjs.com/how_to/group
  35948. * @param name Defines the name of the group
  35949. * @param scene Defines the scene the group belongs to
  35950. */
  35951. constructor(
  35952. /** The name of the animation group */
  35953. name: string, scene?: Nullable<Scene>);
  35954. /**
  35955. * Add an animation (with its target) in the group
  35956. * @param animation defines the animation we want to add
  35957. * @param target defines the target of the animation
  35958. * @returns the TargetedAnimation object
  35959. */
  35960. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35961. /**
  35962. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35963. * It can add constant keys at begin or end
  35964. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35965. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35966. * @returns the animation group
  35967. */
  35968. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35969. private _animationLoopCount;
  35970. private _animationLoopFlags;
  35971. private _processLoop;
  35972. /**
  35973. * Start all animations on given targets
  35974. * @param loop defines if animations must loop
  35975. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35976. * @param from defines the from key (optional)
  35977. * @param to defines the to key (optional)
  35978. * @returns the current animation group
  35979. */
  35980. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35981. /**
  35982. * Pause all animations
  35983. * @returns the animation group
  35984. */
  35985. pause(): AnimationGroup;
  35986. /**
  35987. * Play all animations to initial state
  35988. * This function will start() the animations if they were not started or will restart() them if they were paused
  35989. * @param loop defines if animations must loop
  35990. * @returns the animation group
  35991. */
  35992. play(loop?: boolean): AnimationGroup;
  35993. /**
  35994. * Reset all animations to initial state
  35995. * @returns the animation group
  35996. */
  35997. reset(): AnimationGroup;
  35998. /**
  35999. * Restart animations from key 0
  36000. * @returns the animation group
  36001. */
  36002. restart(): AnimationGroup;
  36003. /**
  36004. * Stop all animations
  36005. * @returns the animation group
  36006. */
  36007. stop(): AnimationGroup;
  36008. /**
  36009. * Set animation weight for all animatables
  36010. * @param weight defines the weight to use
  36011. * @return the animationGroup
  36012. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36013. */
  36014. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36015. /**
  36016. * Synchronize and normalize all animatables with a source animatable
  36017. * @param root defines the root animatable to synchronize with
  36018. * @return the animationGroup
  36019. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36020. */
  36021. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36022. /**
  36023. * Goes to a specific frame in this animation group
  36024. * @param frame the frame number to go to
  36025. * @return the animationGroup
  36026. */
  36027. goToFrame(frame: number): AnimationGroup;
  36028. /**
  36029. * Dispose all associated resources
  36030. */
  36031. dispose(): void;
  36032. private _checkAnimationGroupEnded;
  36033. /**
  36034. * Clone the current animation group and returns a copy
  36035. * @param newName defines the name of the new group
  36036. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36037. * @returns the new aniamtion group
  36038. */
  36039. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36040. /**
  36041. * Serializes the animationGroup to an object
  36042. * @returns Serialized object
  36043. */
  36044. serialize(): any;
  36045. /**
  36046. * Returns a new AnimationGroup object parsed from the source provided.
  36047. * @param parsedAnimationGroup defines the source
  36048. * @param scene defines the scene that will receive the animationGroup
  36049. * @returns a new AnimationGroup
  36050. */
  36051. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36052. /**
  36053. * Returns the string "AnimationGroup"
  36054. * @returns "AnimationGroup"
  36055. */
  36056. getClassName(): string;
  36057. /**
  36058. * Creates a detailled string about the object
  36059. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36060. * @returns a string representing the object
  36061. */
  36062. toString(fullDetails?: boolean): string;
  36063. }
  36064. }
  36065. declare module "babylonjs/scene" {
  36066. import { Nullable } from "babylonjs/types";
  36067. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36068. import { Observable } from "babylonjs/Misc/observable";
  36069. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36070. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36071. import { Geometry } from "babylonjs/Meshes/geometry";
  36072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36075. import { Mesh } from "babylonjs/Meshes/mesh";
  36076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36077. import { Bone } from "babylonjs/Bones/bone";
  36078. import { Skeleton } from "babylonjs/Bones/skeleton";
  36079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36080. import { Camera } from "babylonjs/Cameras/camera";
  36081. import { AbstractScene } from "babylonjs/abstractScene";
  36082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36084. import { Material } from "babylonjs/Materials/material";
  36085. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36086. import { Effect } from "babylonjs/Materials/effect";
  36087. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36088. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36089. import { Light } from "babylonjs/Lights/light";
  36090. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36091. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36092. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36093. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36095. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36096. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36097. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36098. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36099. import { Engine } from "babylonjs/Engines/engine";
  36100. import { Node } from "babylonjs/node";
  36101. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36102. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36103. import { WebRequest } from "babylonjs/Misc/webRequest";
  36104. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36105. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36106. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36107. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36108. import { Plane } from "babylonjs/Maths/math.plane";
  36109. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36110. import { Ray } from "babylonjs/Culling/ray";
  36111. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36112. import { Animation } from "babylonjs/Animations/animation";
  36113. import { Animatable } from "babylonjs/Animations/animatable";
  36114. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36115. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36116. import { Collider } from "babylonjs/Collisions/collider";
  36117. /**
  36118. * Define an interface for all classes that will hold resources
  36119. */
  36120. export interface IDisposable {
  36121. /**
  36122. * Releases all held resources
  36123. */
  36124. dispose(): void;
  36125. }
  36126. /** Interface defining initialization parameters for Scene class */
  36127. export interface SceneOptions {
  36128. /**
  36129. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36130. * It will improve performance when the number of geometries becomes important.
  36131. */
  36132. useGeometryUniqueIdsMap?: boolean;
  36133. /**
  36134. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36136. */
  36137. useMaterialMeshMap?: boolean;
  36138. /**
  36139. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36140. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36141. */
  36142. useClonedMeshMap?: boolean;
  36143. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36144. virtual?: boolean;
  36145. }
  36146. /**
  36147. * Represents a scene to be rendered by the engine.
  36148. * @see http://doc.babylonjs.com/features/scene
  36149. */
  36150. export class Scene extends AbstractScene implements IAnimatable {
  36151. /** The fog is deactivated */
  36152. static readonly FOGMODE_NONE: number;
  36153. /** The fog density is following an exponential function */
  36154. static readonly FOGMODE_EXP: number;
  36155. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36156. static readonly FOGMODE_EXP2: number;
  36157. /** The fog density is following a linear function. */
  36158. static readonly FOGMODE_LINEAR: number;
  36159. /**
  36160. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36162. */
  36163. static MinDeltaTime: number;
  36164. /**
  36165. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36167. */
  36168. static MaxDeltaTime: number;
  36169. /**
  36170. * Factory used to create the default material.
  36171. * @param name The name of the material to create
  36172. * @param scene The scene to create the material for
  36173. * @returns The default material
  36174. */
  36175. static DefaultMaterialFactory(scene: Scene): Material;
  36176. /**
  36177. * Factory used to create the a collision coordinator.
  36178. * @returns The collision coordinator
  36179. */
  36180. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36181. /** @hidden */
  36182. _inputManager: InputManager;
  36183. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36184. cameraToUseForPointers: Nullable<Camera>;
  36185. /** @hidden */
  36186. readonly _isScene: boolean;
  36187. /** @hidden */
  36188. _blockEntityCollection: boolean;
  36189. /**
  36190. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36191. */
  36192. autoClear: boolean;
  36193. /**
  36194. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36195. */
  36196. autoClearDepthAndStencil: boolean;
  36197. /**
  36198. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36199. */
  36200. clearColor: Color4;
  36201. /**
  36202. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36203. */
  36204. ambientColor: Color3;
  36205. /**
  36206. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36207. * It should only be one of the following (if not the default embedded one):
  36208. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36209. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36210. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36211. * The material properties need to be setup according to the type of texture in use.
  36212. */
  36213. environmentBRDFTexture: BaseTexture;
  36214. /** @hidden */
  36215. protected _environmentTexture: Nullable<BaseTexture>;
  36216. /**
  36217. * Texture used in all pbr material as the reflection texture.
  36218. * As in the majority of the scene they are the same (exception for multi room and so on),
  36219. * this is easier to reference from here than from all the materials.
  36220. */
  36221. get environmentTexture(): Nullable<BaseTexture>;
  36222. /**
  36223. * Texture used in all pbr material as the reflection texture.
  36224. * As in the majority of the scene they are the same (exception for multi room and so on),
  36225. * this is easier to set here than in all the materials.
  36226. */
  36227. set environmentTexture(value: Nullable<BaseTexture>);
  36228. /** @hidden */
  36229. protected _environmentIntensity: number;
  36230. /**
  36231. * Intensity of the environment in all pbr material.
  36232. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36233. * As in the majority of the scene they are the same (exception for multi room and so on),
  36234. * this is easier to reference from here than from all the materials.
  36235. */
  36236. get environmentIntensity(): number;
  36237. /**
  36238. * Intensity of the environment in all pbr material.
  36239. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36240. * As in the majority of the scene they are the same (exception for multi room and so on),
  36241. * this is easier to set here than in all the materials.
  36242. */
  36243. set environmentIntensity(value: number);
  36244. /** @hidden */
  36245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36246. /**
  36247. * Default image processing configuration used either in the rendering
  36248. * Forward main pass or through the imageProcessingPostProcess if present.
  36249. * As in the majority of the scene they are the same (exception for multi camera),
  36250. * this is easier to reference from here than from all the materials and post process.
  36251. *
  36252. * No setter as we it is a shared configuration, you can set the values instead.
  36253. */
  36254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36255. private _forceWireframe;
  36256. /**
  36257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36258. */
  36259. set forceWireframe(value: boolean);
  36260. get forceWireframe(): boolean;
  36261. private _skipFrustumClipping;
  36262. /**
  36263. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36264. */
  36265. set skipFrustumClipping(value: boolean);
  36266. get skipFrustumClipping(): boolean;
  36267. private _forcePointsCloud;
  36268. /**
  36269. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36270. */
  36271. set forcePointsCloud(value: boolean);
  36272. get forcePointsCloud(): boolean;
  36273. /**
  36274. * Gets or sets the active clipplane 1
  36275. */
  36276. clipPlane: Nullable<Plane>;
  36277. /**
  36278. * Gets or sets the active clipplane 2
  36279. */
  36280. clipPlane2: Nullable<Plane>;
  36281. /**
  36282. * Gets or sets the active clipplane 3
  36283. */
  36284. clipPlane3: Nullable<Plane>;
  36285. /**
  36286. * Gets or sets the active clipplane 4
  36287. */
  36288. clipPlane4: Nullable<Plane>;
  36289. /**
  36290. * Gets or sets the active clipplane 5
  36291. */
  36292. clipPlane5: Nullable<Plane>;
  36293. /**
  36294. * Gets or sets the active clipplane 6
  36295. */
  36296. clipPlane6: Nullable<Plane>;
  36297. /**
  36298. * Gets or sets a boolean indicating if animations are enabled
  36299. */
  36300. animationsEnabled: boolean;
  36301. private _animationPropertiesOverride;
  36302. /**
  36303. * Gets or sets the animation properties override
  36304. */
  36305. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36306. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36307. /**
  36308. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36309. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36310. */
  36311. useConstantAnimationDeltaTime: boolean;
  36312. /**
  36313. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36314. * Please note that it requires to run a ray cast through the scene on every frame
  36315. */
  36316. constantlyUpdateMeshUnderPointer: boolean;
  36317. /**
  36318. * Defines the HTML cursor to use when hovering over interactive elements
  36319. */
  36320. hoverCursor: string;
  36321. /**
  36322. * Defines the HTML default cursor to use (empty by default)
  36323. */
  36324. defaultCursor: string;
  36325. /**
  36326. * Defines whether cursors are handled by the scene.
  36327. */
  36328. doNotHandleCursors: boolean;
  36329. /**
  36330. * This is used to call preventDefault() on pointer down
  36331. * in order to block unwanted artifacts like system double clicks
  36332. */
  36333. preventDefaultOnPointerDown: boolean;
  36334. /**
  36335. * This is used to call preventDefault() on pointer up
  36336. * in order to block unwanted artifacts like system double clicks
  36337. */
  36338. preventDefaultOnPointerUp: boolean;
  36339. /**
  36340. * Gets or sets user defined metadata
  36341. */
  36342. metadata: any;
  36343. /**
  36344. * For internal use only. Please do not use.
  36345. */
  36346. reservedDataStore: any;
  36347. /**
  36348. * Gets the name of the plugin used to load this scene (null by default)
  36349. */
  36350. loadingPluginName: string;
  36351. /**
  36352. * Use this array to add regular expressions used to disable offline support for specific urls
  36353. */
  36354. disableOfflineSupportExceptionRules: RegExp[];
  36355. /**
  36356. * An event triggered when the scene is disposed.
  36357. */
  36358. onDisposeObservable: Observable<Scene>;
  36359. private _onDisposeObserver;
  36360. /** Sets a function to be executed when this scene is disposed. */
  36361. set onDispose(callback: () => void);
  36362. /**
  36363. * An event triggered before rendering the scene (right after animations and physics)
  36364. */
  36365. onBeforeRenderObservable: Observable<Scene>;
  36366. private _onBeforeRenderObserver;
  36367. /** Sets a function to be executed before rendering this scene */
  36368. set beforeRender(callback: Nullable<() => void>);
  36369. /**
  36370. * An event triggered after rendering the scene
  36371. */
  36372. onAfterRenderObservable: Observable<Scene>;
  36373. /**
  36374. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36375. */
  36376. onAfterRenderCameraObservable: Observable<Camera>;
  36377. private _onAfterRenderObserver;
  36378. /** Sets a function to be executed after rendering this scene */
  36379. set afterRender(callback: Nullable<() => void>);
  36380. /**
  36381. * An event triggered before animating the scene
  36382. */
  36383. onBeforeAnimationsObservable: Observable<Scene>;
  36384. /**
  36385. * An event triggered after animations processing
  36386. */
  36387. onAfterAnimationsObservable: Observable<Scene>;
  36388. /**
  36389. * An event triggered before draw calls are ready to be sent
  36390. */
  36391. onBeforeDrawPhaseObservable: Observable<Scene>;
  36392. /**
  36393. * An event triggered after draw calls have been sent
  36394. */
  36395. onAfterDrawPhaseObservable: Observable<Scene>;
  36396. /**
  36397. * An event triggered when the scene is ready
  36398. */
  36399. onReadyObservable: Observable<Scene>;
  36400. /**
  36401. * An event triggered before rendering a camera
  36402. */
  36403. onBeforeCameraRenderObservable: Observable<Camera>;
  36404. private _onBeforeCameraRenderObserver;
  36405. /** Sets a function to be executed before rendering a camera*/
  36406. set beforeCameraRender(callback: () => void);
  36407. /**
  36408. * An event triggered after rendering a camera
  36409. */
  36410. onAfterCameraRenderObservable: Observable<Camera>;
  36411. private _onAfterCameraRenderObserver;
  36412. /** Sets a function to be executed after rendering a camera*/
  36413. set afterCameraRender(callback: () => void);
  36414. /**
  36415. * An event triggered when active meshes evaluation is about to start
  36416. */
  36417. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36418. /**
  36419. * An event triggered when active meshes evaluation is done
  36420. */
  36421. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36422. /**
  36423. * An event triggered when particles rendering is about to start
  36424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36425. */
  36426. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36427. /**
  36428. * An event triggered when particles rendering is done
  36429. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36430. */
  36431. onAfterParticlesRenderingObservable: Observable<Scene>;
  36432. /**
  36433. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36434. */
  36435. onDataLoadedObservable: Observable<Scene>;
  36436. /**
  36437. * An event triggered when a camera is created
  36438. */
  36439. onNewCameraAddedObservable: Observable<Camera>;
  36440. /**
  36441. * An event triggered when a camera is removed
  36442. */
  36443. onCameraRemovedObservable: Observable<Camera>;
  36444. /**
  36445. * An event triggered when a light is created
  36446. */
  36447. onNewLightAddedObservable: Observable<Light>;
  36448. /**
  36449. * An event triggered when a light is removed
  36450. */
  36451. onLightRemovedObservable: Observable<Light>;
  36452. /**
  36453. * An event triggered when a geometry is created
  36454. */
  36455. onNewGeometryAddedObservable: Observable<Geometry>;
  36456. /**
  36457. * An event triggered when a geometry is removed
  36458. */
  36459. onGeometryRemovedObservable: Observable<Geometry>;
  36460. /**
  36461. * An event triggered when a transform node is created
  36462. */
  36463. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36464. /**
  36465. * An event triggered when a transform node is removed
  36466. */
  36467. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36468. /**
  36469. * An event triggered when a mesh is created
  36470. */
  36471. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36472. /**
  36473. * An event triggered when a mesh is removed
  36474. */
  36475. onMeshRemovedObservable: Observable<AbstractMesh>;
  36476. /**
  36477. * An event triggered when a skeleton is created
  36478. */
  36479. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36480. /**
  36481. * An event triggered when a skeleton is removed
  36482. */
  36483. onSkeletonRemovedObservable: Observable<Skeleton>;
  36484. /**
  36485. * An event triggered when a material is created
  36486. */
  36487. onNewMaterialAddedObservable: Observable<Material>;
  36488. /**
  36489. * An event triggered when a material is removed
  36490. */
  36491. onMaterialRemovedObservable: Observable<Material>;
  36492. /**
  36493. * An event triggered when a texture is created
  36494. */
  36495. onNewTextureAddedObservable: Observable<BaseTexture>;
  36496. /**
  36497. * An event triggered when a texture is removed
  36498. */
  36499. onTextureRemovedObservable: Observable<BaseTexture>;
  36500. /**
  36501. * An event triggered when render targets are about to be rendered
  36502. * Can happen multiple times per frame.
  36503. */
  36504. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36505. /**
  36506. * An event triggered when render targets were rendered.
  36507. * Can happen multiple times per frame.
  36508. */
  36509. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36510. /**
  36511. * An event triggered before calculating deterministic simulation step
  36512. */
  36513. onBeforeStepObservable: Observable<Scene>;
  36514. /**
  36515. * An event triggered after calculating deterministic simulation step
  36516. */
  36517. onAfterStepObservable: Observable<Scene>;
  36518. /**
  36519. * An event triggered when the activeCamera property is updated
  36520. */
  36521. onActiveCameraChanged: Observable<Scene>;
  36522. /**
  36523. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36525. * 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)
  36526. */
  36527. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36528. /**
  36529. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36530. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36531. * 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)
  36532. */
  36533. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36534. /**
  36535. * This Observable will when a mesh has been imported into the scene.
  36536. */
  36537. onMeshImportedObservable: Observable<AbstractMesh>;
  36538. /**
  36539. * This Observable will when an animation file has been imported into the scene.
  36540. */
  36541. onAnimationFileImportedObservable: Observable<Scene>;
  36542. /**
  36543. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36544. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36545. */
  36546. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36547. /** @hidden */
  36548. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36549. /**
  36550. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36551. */
  36552. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36553. /**
  36554. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36555. */
  36556. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36557. /**
  36558. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36559. */
  36560. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36561. /** Callback called when a pointer move is detected */
  36562. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36563. /** Callback called when a pointer down is detected */
  36564. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36565. /** Callback called when a pointer up is detected */
  36566. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36567. /** Callback called when a pointer pick is detected */
  36568. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36569. /**
  36570. * 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).
  36571. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36572. */
  36573. onPrePointerObservable: Observable<PointerInfoPre>;
  36574. /**
  36575. * Observable event triggered each time an input event is received from the rendering canvas
  36576. */
  36577. onPointerObservable: Observable<PointerInfo>;
  36578. /**
  36579. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36580. */
  36581. get unTranslatedPointer(): Vector2;
  36582. /**
  36583. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36584. */
  36585. static get DragMovementThreshold(): number;
  36586. static set DragMovementThreshold(value: number);
  36587. /**
  36588. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36589. */
  36590. static get LongPressDelay(): number;
  36591. static set LongPressDelay(value: number);
  36592. /**
  36593. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36594. */
  36595. static get DoubleClickDelay(): number;
  36596. static set DoubleClickDelay(value: number);
  36597. /** If you need to check double click without raising a single click at first click, enable this flag */
  36598. static get ExclusiveDoubleClickMode(): boolean;
  36599. static set ExclusiveDoubleClickMode(value: boolean);
  36600. /** @hidden */
  36601. _mirroredCameraPosition: Nullable<Vector3>;
  36602. /**
  36603. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36604. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36605. */
  36606. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36607. /**
  36608. * Observable event triggered each time an keyboard event is received from the hosting window
  36609. */
  36610. onKeyboardObservable: Observable<KeyboardInfo>;
  36611. private _useRightHandedSystem;
  36612. /**
  36613. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36614. */
  36615. set useRightHandedSystem(value: boolean);
  36616. get useRightHandedSystem(): boolean;
  36617. private _timeAccumulator;
  36618. private _currentStepId;
  36619. private _currentInternalStep;
  36620. /**
  36621. * Sets the step Id used by deterministic lock step
  36622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36623. * @param newStepId defines the step Id
  36624. */
  36625. setStepId(newStepId: number): void;
  36626. /**
  36627. * Gets the step Id used by deterministic lock step
  36628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36629. * @returns the step Id
  36630. */
  36631. getStepId(): number;
  36632. /**
  36633. * Gets the internal step used by deterministic lock step
  36634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36635. * @returns the internal step
  36636. */
  36637. getInternalStep(): number;
  36638. private _fogEnabled;
  36639. /**
  36640. * Gets or sets a boolean indicating if fog is enabled on this scene
  36641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36642. * (Default is true)
  36643. */
  36644. set fogEnabled(value: boolean);
  36645. get fogEnabled(): boolean;
  36646. private _fogMode;
  36647. /**
  36648. * Gets or sets the fog mode to use
  36649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36650. * | mode | value |
  36651. * | --- | --- |
  36652. * | FOGMODE_NONE | 0 |
  36653. * | FOGMODE_EXP | 1 |
  36654. * | FOGMODE_EXP2 | 2 |
  36655. * | FOGMODE_LINEAR | 3 |
  36656. */
  36657. set fogMode(value: number);
  36658. get fogMode(): number;
  36659. /**
  36660. * Gets or sets the fog color to use
  36661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36662. * (Default is Color3(0.2, 0.2, 0.3))
  36663. */
  36664. fogColor: Color3;
  36665. /**
  36666. * Gets or sets the fog density to use
  36667. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36668. * (Default is 0.1)
  36669. */
  36670. fogDensity: number;
  36671. /**
  36672. * Gets or sets the fog start distance to use
  36673. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36674. * (Default is 0)
  36675. */
  36676. fogStart: number;
  36677. /**
  36678. * Gets or sets the fog end distance to use
  36679. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36680. * (Default is 1000)
  36681. */
  36682. fogEnd: number;
  36683. private _shadowsEnabled;
  36684. /**
  36685. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36686. */
  36687. set shadowsEnabled(value: boolean);
  36688. get shadowsEnabled(): boolean;
  36689. private _lightsEnabled;
  36690. /**
  36691. * Gets or sets a boolean indicating if lights are enabled on this scene
  36692. */
  36693. set lightsEnabled(value: boolean);
  36694. get lightsEnabled(): boolean;
  36695. /** All of the active cameras added to this scene. */
  36696. activeCameras: Camera[];
  36697. /** @hidden */
  36698. _activeCamera: Nullable<Camera>;
  36699. /** Gets or sets the current active camera */
  36700. get activeCamera(): Nullable<Camera>;
  36701. set activeCamera(value: Nullable<Camera>);
  36702. private _defaultMaterial;
  36703. /** The default material used on meshes when no material is affected */
  36704. get defaultMaterial(): Material;
  36705. /** The default material used on meshes when no material is affected */
  36706. set defaultMaterial(value: Material);
  36707. private _texturesEnabled;
  36708. /**
  36709. * Gets or sets a boolean indicating if textures are enabled on this scene
  36710. */
  36711. set texturesEnabled(value: boolean);
  36712. get texturesEnabled(): boolean;
  36713. /**
  36714. * Gets or sets a boolean indicating if particles are enabled on this scene
  36715. */
  36716. particlesEnabled: boolean;
  36717. /**
  36718. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36719. */
  36720. spritesEnabled: boolean;
  36721. private _skeletonsEnabled;
  36722. /**
  36723. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36724. */
  36725. set skeletonsEnabled(value: boolean);
  36726. get skeletonsEnabled(): boolean;
  36727. /**
  36728. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36729. */
  36730. lensFlaresEnabled: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36734. */
  36735. collisionsEnabled: boolean;
  36736. private _collisionCoordinator;
  36737. /** @hidden */
  36738. get collisionCoordinator(): ICollisionCoordinator;
  36739. /**
  36740. * Defines the gravity applied to this scene (used only for collisions)
  36741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36742. */
  36743. gravity: Vector3;
  36744. /**
  36745. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36746. */
  36747. postProcessesEnabled: boolean;
  36748. /**
  36749. * The list of postprocesses added to the scene
  36750. */
  36751. postProcesses: PostProcess[];
  36752. /**
  36753. * Gets the current postprocess manager
  36754. */
  36755. postProcessManager: PostProcessManager;
  36756. /**
  36757. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36758. */
  36759. renderTargetsEnabled: boolean;
  36760. /**
  36761. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36762. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36763. */
  36764. dumpNextRenderTargets: boolean;
  36765. /**
  36766. * The list of user defined render targets added to the scene
  36767. */
  36768. customRenderTargets: RenderTargetTexture[];
  36769. /**
  36770. * Defines if texture loading must be delayed
  36771. * If true, textures will only be loaded when they need to be rendered
  36772. */
  36773. useDelayedTextureLoading: boolean;
  36774. /**
  36775. * Gets the list of meshes imported to the scene through SceneLoader
  36776. */
  36777. importedMeshesFiles: String[];
  36778. /**
  36779. * Gets or sets a boolean indicating if probes are enabled on this scene
  36780. */
  36781. probesEnabled: boolean;
  36782. /**
  36783. * Gets or sets the current offline provider to use to store scene data
  36784. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36785. */
  36786. offlineProvider: IOfflineProvider;
  36787. /**
  36788. * Gets or sets the action manager associated with the scene
  36789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36790. */
  36791. actionManager: AbstractActionManager;
  36792. private _meshesForIntersections;
  36793. /**
  36794. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36795. */
  36796. proceduralTexturesEnabled: boolean;
  36797. private _engine;
  36798. private _totalVertices;
  36799. /** @hidden */
  36800. _activeIndices: PerfCounter;
  36801. /** @hidden */
  36802. _activeParticles: PerfCounter;
  36803. /** @hidden */
  36804. _activeBones: PerfCounter;
  36805. private _animationRatio;
  36806. /** @hidden */
  36807. _animationTimeLast: number;
  36808. /** @hidden */
  36809. _animationTime: number;
  36810. /**
  36811. * Gets or sets a general scale for animation speed
  36812. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36813. */
  36814. animationTimeScale: number;
  36815. /** @hidden */
  36816. _cachedMaterial: Nullable<Material>;
  36817. /** @hidden */
  36818. _cachedEffect: Nullable<Effect>;
  36819. /** @hidden */
  36820. _cachedVisibility: Nullable<number>;
  36821. private _renderId;
  36822. private _frameId;
  36823. private _executeWhenReadyTimeoutId;
  36824. private _intermediateRendering;
  36825. private _viewUpdateFlag;
  36826. private _projectionUpdateFlag;
  36827. /** @hidden */
  36828. _toBeDisposed: Nullable<IDisposable>[];
  36829. private _activeRequests;
  36830. /** @hidden */
  36831. _pendingData: any[];
  36832. private _isDisposed;
  36833. /**
  36834. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36835. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36836. */
  36837. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36838. private _activeMeshes;
  36839. private _processedMaterials;
  36840. private _renderTargets;
  36841. /** @hidden */
  36842. _activeParticleSystems: SmartArray<IParticleSystem>;
  36843. private _activeSkeletons;
  36844. private _softwareSkinnedMeshes;
  36845. private _renderingManager;
  36846. /** @hidden */
  36847. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36848. private _transformMatrix;
  36849. private _sceneUbo;
  36850. /** @hidden */
  36851. _viewMatrix: Matrix;
  36852. private _projectionMatrix;
  36853. /** @hidden */
  36854. _forcedViewPosition: Nullable<Vector3>;
  36855. /** @hidden */
  36856. _frustumPlanes: Plane[];
  36857. /**
  36858. * Gets the list of frustum planes (built from the active camera)
  36859. */
  36860. get frustumPlanes(): Plane[];
  36861. /**
  36862. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36863. * This is useful if there are more lights that the maximum simulteanous authorized
  36864. */
  36865. requireLightSorting: boolean;
  36866. /** @hidden */
  36867. readonly useMaterialMeshMap: boolean;
  36868. /** @hidden */
  36869. readonly useClonedMeshMap: boolean;
  36870. private _externalData;
  36871. private _uid;
  36872. /**
  36873. * @hidden
  36874. * Backing store of defined scene components.
  36875. */
  36876. _components: ISceneComponent[];
  36877. /**
  36878. * @hidden
  36879. * Backing store of defined scene components.
  36880. */
  36881. _serializableComponents: ISceneSerializableComponent[];
  36882. /**
  36883. * List of components to register on the next registration step.
  36884. */
  36885. private _transientComponents;
  36886. /**
  36887. * Registers the transient components if needed.
  36888. */
  36889. private _registerTransientComponents;
  36890. /**
  36891. * @hidden
  36892. * Add a component to the scene.
  36893. * Note that the ccomponent could be registered on th next frame if this is called after
  36894. * the register component stage.
  36895. * @param component Defines the component to add to the scene
  36896. */
  36897. _addComponent(component: ISceneComponent): void;
  36898. /**
  36899. * @hidden
  36900. * Gets a component from the scene.
  36901. * @param name defines the name of the component to retrieve
  36902. * @returns the component or null if not present
  36903. */
  36904. _getComponent(name: string): Nullable<ISceneComponent>;
  36905. /**
  36906. * @hidden
  36907. * Defines the actions happening before camera updates.
  36908. */
  36909. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36910. /**
  36911. * @hidden
  36912. * Defines the actions happening before clear the canvas.
  36913. */
  36914. _beforeClearStage: Stage<SimpleStageAction>;
  36915. /**
  36916. * @hidden
  36917. * Defines the actions when collecting render targets for the frame.
  36918. */
  36919. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36920. /**
  36921. * @hidden
  36922. * Defines the actions happening for one camera in the frame.
  36923. */
  36924. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36925. /**
  36926. * @hidden
  36927. * Defines the actions happening during the per mesh ready checks.
  36928. */
  36929. _isReadyForMeshStage: Stage<MeshStageAction>;
  36930. /**
  36931. * @hidden
  36932. * Defines the actions happening before evaluate active mesh checks.
  36933. */
  36934. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36935. /**
  36936. * @hidden
  36937. * Defines the actions happening during the evaluate sub mesh checks.
  36938. */
  36939. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36940. /**
  36941. * @hidden
  36942. * Defines the actions happening during the active mesh stage.
  36943. */
  36944. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36945. /**
  36946. * @hidden
  36947. * Defines the actions happening during the per camera render target step.
  36948. */
  36949. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36950. /**
  36951. * @hidden
  36952. * Defines the actions happening just before the active camera is drawing.
  36953. */
  36954. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36955. /**
  36956. * @hidden
  36957. * Defines the actions happening just before a render target is drawing.
  36958. */
  36959. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36960. /**
  36961. * @hidden
  36962. * Defines the actions happening just before a rendering group is drawing.
  36963. */
  36964. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36965. /**
  36966. * @hidden
  36967. * Defines the actions happening just before a mesh is drawing.
  36968. */
  36969. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36970. /**
  36971. * @hidden
  36972. * Defines the actions happening just after a mesh has been drawn.
  36973. */
  36974. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36975. /**
  36976. * @hidden
  36977. * Defines the actions happening just after a rendering group has been drawn.
  36978. */
  36979. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36980. /**
  36981. * @hidden
  36982. * Defines the actions happening just after the active camera has been drawn.
  36983. */
  36984. _afterCameraDrawStage: Stage<CameraStageAction>;
  36985. /**
  36986. * @hidden
  36987. * Defines the actions happening just after a render target has been drawn.
  36988. */
  36989. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36990. /**
  36991. * @hidden
  36992. * Defines the actions happening just after rendering all cameras and computing intersections.
  36993. */
  36994. _afterRenderStage: Stage<SimpleStageAction>;
  36995. /**
  36996. * @hidden
  36997. * Defines the actions happening when a pointer move event happens.
  36998. */
  36999. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37000. /**
  37001. * @hidden
  37002. * Defines the actions happening when a pointer down event happens.
  37003. */
  37004. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37005. /**
  37006. * @hidden
  37007. * Defines the actions happening when a pointer up event happens.
  37008. */
  37009. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37010. /**
  37011. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37012. */
  37013. private geometriesByUniqueId;
  37014. /**
  37015. * Creates a new Scene
  37016. * @param engine defines the engine to use to render this scene
  37017. * @param options defines the scene options
  37018. */
  37019. constructor(engine: Engine, options?: SceneOptions);
  37020. /**
  37021. * Gets a string idenfifying the name of the class
  37022. * @returns "Scene" string
  37023. */
  37024. getClassName(): string;
  37025. private _defaultMeshCandidates;
  37026. /**
  37027. * @hidden
  37028. */
  37029. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37030. private _defaultSubMeshCandidates;
  37031. /**
  37032. * @hidden
  37033. */
  37034. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37035. /**
  37036. * Sets the default candidate providers for the scene.
  37037. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37038. * and getCollidingSubMeshCandidates to their default function
  37039. */
  37040. setDefaultCandidateProviders(): void;
  37041. /**
  37042. * Gets the mesh that is currently under the pointer
  37043. */
  37044. get meshUnderPointer(): Nullable<AbstractMesh>;
  37045. /**
  37046. * Gets or sets the current on-screen X position of the pointer
  37047. */
  37048. get pointerX(): number;
  37049. set pointerX(value: number);
  37050. /**
  37051. * Gets or sets the current on-screen Y position of the pointer
  37052. */
  37053. get pointerY(): number;
  37054. set pointerY(value: number);
  37055. /**
  37056. * Gets the cached material (ie. the latest rendered one)
  37057. * @returns the cached material
  37058. */
  37059. getCachedMaterial(): Nullable<Material>;
  37060. /**
  37061. * Gets the cached effect (ie. the latest rendered one)
  37062. * @returns the cached effect
  37063. */
  37064. getCachedEffect(): Nullable<Effect>;
  37065. /**
  37066. * Gets the cached visibility state (ie. the latest rendered one)
  37067. * @returns the cached visibility state
  37068. */
  37069. getCachedVisibility(): Nullable<number>;
  37070. /**
  37071. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37072. * @param material defines the current material
  37073. * @param effect defines the current effect
  37074. * @param visibility defines the current visibility state
  37075. * @returns true if one parameter is not cached
  37076. */
  37077. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37078. /**
  37079. * Gets the engine associated with the scene
  37080. * @returns an Engine
  37081. */
  37082. getEngine(): Engine;
  37083. /**
  37084. * Gets the total number of vertices rendered per frame
  37085. * @returns the total number of vertices rendered per frame
  37086. */
  37087. getTotalVertices(): number;
  37088. /**
  37089. * Gets the performance counter for total vertices
  37090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37091. */
  37092. get totalVerticesPerfCounter(): PerfCounter;
  37093. /**
  37094. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37095. * @returns the total number of active indices rendered per frame
  37096. */
  37097. getActiveIndices(): number;
  37098. /**
  37099. * Gets the performance counter for active indices
  37100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37101. */
  37102. get totalActiveIndicesPerfCounter(): PerfCounter;
  37103. /**
  37104. * Gets the total number of active particles rendered per frame
  37105. * @returns the total number of active particles rendered per frame
  37106. */
  37107. getActiveParticles(): number;
  37108. /**
  37109. * Gets the performance counter for active particles
  37110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37111. */
  37112. get activeParticlesPerfCounter(): PerfCounter;
  37113. /**
  37114. * Gets the total number of active bones rendered per frame
  37115. * @returns the total number of active bones rendered per frame
  37116. */
  37117. getActiveBones(): number;
  37118. /**
  37119. * Gets the performance counter for active bones
  37120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37121. */
  37122. get activeBonesPerfCounter(): PerfCounter;
  37123. /**
  37124. * Gets the array of active meshes
  37125. * @returns an array of AbstractMesh
  37126. */
  37127. getActiveMeshes(): SmartArray<AbstractMesh>;
  37128. /**
  37129. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37130. * @returns a number
  37131. */
  37132. getAnimationRatio(): number;
  37133. /**
  37134. * Gets an unique Id for the current render phase
  37135. * @returns a number
  37136. */
  37137. getRenderId(): number;
  37138. /**
  37139. * Gets an unique Id for the current frame
  37140. * @returns a number
  37141. */
  37142. getFrameId(): number;
  37143. /** Call this function if you want to manually increment the render Id*/
  37144. incrementRenderId(): void;
  37145. private _createUbo;
  37146. /**
  37147. * Use this method to simulate a pointer move on a mesh
  37148. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37149. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37150. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37151. * @returns the current scene
  37152. */
  37153. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37154. /**
  37155. * Use this method to simulate a pointer down on a mesh
  37156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37159. * @returns the current scene
  37160. */
  37161. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37162. /**
  37163. * Use this method to simulate a pointer up on a mesh
  37164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37167. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37168. * @returns the current scene
  37169. */
  37170. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37171. /**
  37172. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37173. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37174. * @returns true if the pointer was captured
  37175. */
  37176. isPointerCaptured(pointerId?: number): boolean;
  37177. /**
  37178. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37179. * @param attachUp defines if you want to attach events to pointerup
  37180. * @param attachDown defines if you want to attach events to pointerdown
  37181. * @param attachMove defines if you want to attach events to pointermove
  37182. */
  37183. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37184. /** Detaches all event handlers*/
  37185. detachControl(): void;
  37186. /**
  37187. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37188. * Delay loaded resources are not taking in account
  37189. * @return true if all required resources are ready
  37190. */
  37191. isReady(): boolean;
  37192. /** Resets all cached information relative to material (including effect and visibility) */
  37193. resetCachedMaterial(): void;
  37194. /**
  37195. * Registers a function to be called before every frame render
  37196. * @param func defines the function to register
  37197. */
  37198. registerBeforeRender(func: () => void): void;
  37199. /**
  37200. * Unregisters a function called before every frame render
  37201. * @param func defines the function to unregister
  37202. */
  37203. unregisterBeforeRender(func: () => void): void;
  37204. /**
  37205. * Registers a function to be called after every frame render
  37206. * @param func defines the function to register
  37207. */
  37208. registerAfterRender(func: () => void): void;
  37209. /**
  37210. * Unregisters a function called after every frame render
  37211. * @param func defines the function to unregister
  37212. */
  37213. unregisterAfterRender(func: () => void): void;
  37214. private _executeOnceBeforeRender;
  37215. /**
  37216. * The provided function will run before render once and will be disposed afterwards.
  37217. * A timeout delay can be provided so that the function will be executed in N ms.
  37218. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37219. * @param func The function to be executed.
  37220. * @param timeout optional delay in ms
  37221. */
  37222. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37223. /** @hidden */
  37224. _addPendingData(data: any): void;
  37225. /** @hidden */
  37226. _removePendingData(data: any): void;
  37227. /**
  37228. * Returns the number of items waiting to be loaded
  37229. * @returns the number of items waiting to be loaded
  37230. */
  37231. getWaitingItemsCount(): number;
  37232. /**
  37233. * Returns a boolean indicating if the scene is still loading data
  37234. */
  37235. get isLoading(): boolean;
  37236. /**
  37237. * Registers a function to be executed when the scene is ready
  37238. * @param {Function} func - the function to be executed
  37239. */
  37240. executeWhenReady(func: () => void): void;
  37241. /**
  37242. * Returns a promise that resolves when the scene is ready
  37243. * @returns A promise that resolves when the scene is ready
  37244. */
  37245. whenReadyAsync(): Promise<void>;
  37246. /** @hidden */
  37247. _checkIsReady(): void;
  37248. /**
  37249. * Gets all animatable attached to the scene
  37250. */
  37251. get animatables(): Animatable[];
  37252. /**
  37253. * Resets the last animation time frame.
  37254. * Useful to override when animations start running when loading a scene for the first time.
  37255. */
  37256. resetLastAnimationTimeFrame(): void;
  37257. /**
  37258. * Gets the current view matrix
  37259. * @returns a Matrix
  37260. */
  37261. getViewMatrix(): Matrix;
  37262. /**
  37263. * Gets the current projection matrix
  37264. * @returns a Matrix
  37265. */
  37266. getProjectionMatrix(): Matrix;
  37267. /**
  37268. * Gets the current transform matrix
  37269. * @returns a Matrix made of View * Projection
  37270. */
  37271. getTransformMatrix(): Matrix;
  37272. /**
  37273. * Sets the current transform matrix
  37274. * @param viewL defines the View matrix to use
  37275. * @param projectionL defines the Projection matrix to use
  37276. * @param viewR defines the right View matrix to use (if provided)
  37277. * @param projectionR defines the right Projection matrix to use (if provided)
  37278. */
  37279. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37280. /**
  37281. * Gets the uniform buffer used to store scene data
  37282. * @returns a UniformBuffer
  37283. */
  37284. getSceneUniformBuffer(): UniformBuffer;
  37285. /**
  37286. * Gets an unique (relatively to the current scene) Id
  37287. * @returns an unique number for the scene
  37288. */
  37289. getUniqueId(): number;
  37290. /**
  37291. * Add a mesh to the list of scene's meshes
  37292. * @param newMesh defines the mesh to add
  37293. * @param recursive if all child meshes should also be added to the scene
  37294. */
  37295. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37296. /**
  37297. * Remove a mesh for the list of scene's meshes
  37298. * @param toRemove defines the mesh to remove
  37299. * @param recursive if all child meshes should also be removed from the scene
  37300. * @returns the index where the mesh was in the mesh list
  37301. */
  37302. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37303. /**
  37304. * Add a transform node to the list of scene's transform nodes
  37305. * @param newTransformNode defines the transform node to add
  37306. */
  37307. addTransformNode(newTransformNode: TransformNode): void;
  37308. /**
  37309. * Remove a transform node for the list of scene's transform nodes
  37310. * @param toRemove defines the transform node to remove
  37311. * @returns the index where the transform node was in the transform node list
  37312. */
  37313. removeTransformNode(toRemove: TransformNode): number;
  37314. /**
  37315. * Remove a skeleton for the list of scene's skeletons
  37316. * @param toRemove defines the skeleton to remove
  37317. * @returns the index where the skeleton was in the skeleton list
  37318. */
  37319. removeSkeleton(toRemove: Skeleton): number;
  37320. /**
  37321. * Remove a morph target for the list of scene's morph targets
  37322. * @param toRemove defines the morph target to remove
  37323. * @returns the index where the morph target was in the morph target list
  37324. */
  37325. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37326. /**
  37327. * Remove a light for the list of scene's lights
  37328. * @param toRemove defines the light to remove
  37329. * @returns the index where the light was in the light list
  37330. */
  37331. removeLight(toRemove: Light): number;
  37332. /**
  37333. * Remove a camera for the list of scene's cameras
  37334. * @param toRemove defines the camera to remove
  37335. * @returns the index where the camera was in the camera list
  37336. */
  37337. removeCamera(toRemove: Camera): number;
  37338. /**
  37339. * Remove a particle system for the list of scene's particle systems
  37340. * @param toRemove defines the particle system to remove
  37341. * @returns the index where the particle system was in the particle system list
  37342. */
  37343. removeParticleSystem(toRemove: IParticleSystem): number;
  37344. /**
  37345. * Remove a animation for the list of scene's animations
  37346. * @param toRemove defines the animation to remove
  37347. * @returns the index where the animation was in the animation list
  37348. */
  37349. removeAnimation(toRemove: Animation): number;
  37350. /**
  37351. * Will stop the animation of the given target
  37352. * @param target - the target
  37353. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37354. * @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)
  37355. */
  37356. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37357. /**
  37358. * Removes the given animation group from this scene.
  37359. * @param toRemove The animation group to remove
  37360. * @returns The index of the removed animation group
  37361. */
  37362. removeAnimationGroup(toRemove: AnimationGroup): number;
  37363. /**
  37364. * Removes the given multi-material from this scene.
  37365. * @param toRemove The multi-material to remove
  37366. * @returns The index of the removed multi-material
  37367. */
  37368. removeMultiMaterial(toRemove: MultiMaterial): number;
  37369. /**
  37370. * Removes the given material from this scene.
  37371. * @param toRemove The material to remove
  37372. * @returns The index of the removed material
  37373. */
  37374. removeMaterial(toRemove: Material): number;
  37375. /**
  37376. * Removes the given action manager from this scene.
  37377. * @param toRemove The action manager to remove
  37378. * @returns The index of the removed action manager
  37379. */
  37380. removeActionManager(toRemove: AbstractActionManager): number;
  37381. /**
  37382. * Removes the given texture from this scene.
  37383. * @param toRemove The texture to remove
  37384. * @returns The index of the removed texture
  37385. */
  37386. removeTexture(toRemove: BaseTexture): number;
  37387. /**
  37388. * Adds the given light to this scene
  37389. * @param newLight The light to add
  37390. */
  37391. addLight(newLight: Light): void;
  37392. /**
  37393. * Sorts the list list based on light priorities
  37394. */
  37395. sortLightsByPriority(): void;
  37396. /**
  37397. * Adds the given camera to this scene
  37398. * @param newCamera The camera to add
  37399. */
  37400. addCamera(newCamera: Camera): void;
  37401. /**
  37402. * Adds the given skeleton to this scene
  37403. * @param newSkeleton The skeleton to add
  37404. */
  37405. addSkeleton(newSkeleton: Skeleton): void;
  37406. /**
  37407. * Adds the given particle system to this scene
  37408. * @param newParticleSystem The particle system to add
  37409. */
  37410. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37411. /**
  37412. * Adds the given animation to this scene
  37413. * @param newAnimation The animation to add
  37414. */
  37415. addAnimation(newAnimation: Animation): void;
  37416. /**
  37417. * Adds the given animation group to this scene.
  37418. * @param newAnimationGroup The animation group to add
  37419. */
  37420. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37421. /**
  37422. * Adds the given multi-material to this scene
  37423. * @param newMultiMaterial The multi-material to add
  37424. */
  37425. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37426. /**
  37427. * Adds the given material to this scene
  37428. * @param newMaterial The material to add
  37429. */
  37430. addMaterial(newMaterial: Material): void;
  37431. /**
  37432. * Adds the given morph target to this scene
  37433. * @param newMorphTargetManager The morph target to add
  37434. */
  37435. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37436. /**
  37437. * Adds the given geometry to this scene
  37438. * @param newGeometry The geometry to add
  37439. */
  37440. addGeometry(newGeometry: Geometry): void;
  37441. /**
  37442. * Adds the given action manager to this scene
  37443. * @param newActionManager The action manager to add
  37444. */
  37445. addActionManager(newActionManager: AbstractActionManager): void;
  37446. /**
  37447. * Adds the given texture to this scene.
  37448. * @param newTexture The texture to add
  37449. */
  37450. addTexture(newTexture: BaseTexture): void;
  37451. /**
  37452. * Switch active camera
  37453. * @param newCamera defines the new active camera
  37454. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37455. */
  37456. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37457. /**
  37458. * sets the active camera of the scene using its ID
  37459. * @param id defines the camera's ID
  37460. * @return the new active camera or null if none found.
  37461. */
  37462. setActiveCameraByID(id: string): Nullable<Camera>;
  37463. /**
  37464. * sets the active camera of the scene using its name
  37465. * @param name defines the camera's name
  37466. * @returns the new active camera or null if none found.
  37467. */
  37468. setActiveCameraByName(name: string): Nullable<Camera>;
  37469. /**
  37470. * get an animation group using its name
  37471. * @param name defines the material's name
  37472. * @return the animation group or null if none found.
  37473. */
  37474. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37475. /**
  37476. * Get a material using its unique id
  37477. * @param uniqueId defines the material's unique id
  37478. * @return the material or null if none found.
  37479. */
  37480. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37481. /**
  37482. * get a material using its id
  37483. * @param id defines the material's ID
  37484. * @return the material or null if none found.
  37485. */
  37486. getMaterialByID(id: string): Nullable<Material>;
  37487. /**
  37488. * Gets a the last added material using a given id
  37489. * @param id defines the material's ID
  37490. * @return the last material with the given id or null if none found.
  37491. */
  37492. getLastMaterialByID(id: string): Nullable<Material>;
  37493. /**
  37494. * Gets a material using its name
  37495. * @param name defines the material's name
  37496. * @return the material or null if none found.
  37497. */
  37498. getMaterialByName(name: string): Nullable<Material>;
  37499. /**
  37500. * Get a texture using its unique id
  37501. * @param uniqueId defines the texture's unique id
  37502. * @return the texture or null if none found.
  37503. */
  37504. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37505. /**
  37506. * Gets a camera using its id
  37507. * @param id defines the id to look for
  37508. * @returns the camera or null if not found
  37509. */
  37510. getCameraByID(id: string): Nullable<Camera>;
  37511. /**
  37512. * Gets a camera using its unique id
  37513. * @param uniqueId defines the unique id to look for
  37514. * @returns the camera or null if not found
  37515. */
  37516. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37517. /**
  37518. * Gets a camera using its name
  37519. * @param name defines the camera's name
  37520. * @return the camera or null if none found.
  37521. */
  37522. getCameraByName(name: string): Nullable<Camera>;
  37523. /**
  37524. * Gets a bone using its id
  37525. * @param id defines the bone's id
  37526. * @return the bone or null if not found
  37527. */
  37528. getBoneByID(id: string): Nullable<Bone>;
  37529. /**
  37530. * Gets a bone using its id
  37531. * @param name defines the bone's name
  37532. * @return the bone or null if not found
  37533. */
  37534. getBoneByName(name: string): Nullable<Bone>;
  37535. /**
  37536. * Gets a light node using its name
  37537. * @param name defines the the light's name
  37538. * @return the light or null if none found.
  37539. */
  37540. getLightByName(name: string): Nullable<Light>;
  37541. /**
  37542. * Gets a light node using its id
  37543. * @param id defines the light's id
  37544. * @return the light or null if none found.
  37545. */
  37546. getLightByID(id: string): Nullable<Light>;
  37547. /**
  37548. * Gets a light node using its scene-generated unique ID
  37549. * @param uniqueId defines the light's unique id
  37550. * @return the light or null if none found.
  37551. */
  37552. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37553. /**
  37554. * Gets a particle system by id
  37555. * @param id defines the particle system id
  37556. * @return the corresponding system or null if none found
  37557. */
  37558. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37559. /**
  37560. * Gets a geometry using its ID
  37561. * @param id defines the geometry's id
  37562. * @return the geometry or null if none found.
  37563. */
  37564. getGeometryByID(id: string): Nullable<Geometry>;
  37565. private _getGeometryByUniqueID;
  37566. /**
  37567. * Add a new geometry to this scene
  37568. * @param geometry defines the geometry to be added to the scene.
  37569. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37570. * @return a boolean defining if the geometry was added or not
  37571. */
  37572. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37573. /**
  37574. * Removes an existing geometry
  37575. * @param geometry defines the geometry to be removed from the scene
  37576. * @return a boolean defining if the geometry was removed or not
  37577. */
  37578. removeGeometry(geometry: Geometry): boolean;
  37579. /**
  37580. * Gets the list of geometries attached to the scene
  37581. * @returns an array of Geometry
  37582. */
  37583. getGeometries(): Geometry[];
  37584. /**
  37585. * Gets the first added mesh found of a given ID
  37586. * @param id defines the id to search for
  37587. * @return the mesh found or null if not found at all
  37588. */
  37589. getMeshByID(id: string): Nullable<AbstractMesh>;
  37590. /**
  37591. * Gets a list of meshes using their id
  37592. * @param id defines the id to search for
  37593. * @returns a list of meshes
  37594. */
  37595. getMeshesByID(id: string): Array<AbstractMesh>;
  37596. /**
  37597. * Gets the first added transform node found of a given ID
  37598. * @param id defines the id to search for
  37599. * @return the found transform node or null if not found at all.
  37600. */
  37601. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37602. /**
  37603. * Gets a transform node with its auto-generated unique id
  37604. * @param uniqueId efines the unique id to search for
  37605. * @return the found transform node or null if not found at all.
  37606. */
  37607. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37608. /**
  37609. * Gets a list of transform nodes using their id
  37610. * @param id defines the id to search for
  37611. * @returns a list of transform nodes
  37612. */
  37613. getTransformNodesByID(id: string): Array<TransformNode>;
  37614. /**
  37615. * Gets a mesh with its auto-generated unique id
  37616. * @param uniqueId defines the unique id to search for
  37617. * @return the found mesh or null if not found at all.
  37618. */
  37619. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37620. /**
  37621. * Gets a the last added mesh using a given id
  37622. * @param id defines the id to search for
  37623. * @return the found mesh or null if not found at all.
  37624. */
  37625. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37626. /**
  37627. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37628. * @param id defines the id to search for
  37629. * @return the found node or null if not found at all
  37630. */
  37631. getLastEntryByID(id: string): Nullable<Node>;
  37632. /**
  37633. * Gets a node (Mesh, Camera, Light) using a given id
  37634. * @param id defines the id to search for
  37635. * @return the found node or null if not found at all
  37636. */
  37637. getNodeByID(id: string): Nullable<Node>;
  37638. /**
  37639. * Gets a node (Mesh, Camera, Light) using a given name
  37640. * @param name defines the name to search for
  37641. * @return the found node or null if not found at all.
  37642. */
  37643. getNodeByName(name: string): Nullable<Node>;
  37644. /**
  37645. * Gets a mesh using a given name
  37646. * @param name defines the name to search for
  37647. * @return the found mesh or null if not found at all.
  37648. */
  37649. getMeshByName(name: string): Nullable<AbstractMesh>;
  37650. /**
  37651. * Gets a transform node using a given name
  37652. * @param name defines the name to search for
  37653. * @return the found transform node or null if not found at all.
  37654. */
  37655. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37656. /**
  37657. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37658. * @param id defines the id to search for
  37659. * @return the found skeleton or null if not found at all.
  37660. */
  37661. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37662. /**
  37663. * Gets a skeleton using a given auto generated unique id
  37664. * @param uniqueId defines the unique id to search for
  37665. * @return the found skeleton or null if not found at all.
  37666. */
  37667. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37668. /**
  37669. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37670. * @param id defines the id to search for
  37671. * @return the found skeleton or null if not found at all.
  37672. */
  37673. getSkeletonById(id: string): Nullable<Skeleton>;
  37674. /**
  37675. * Gets a skeleton using a given name
  37676. * @param name defines the name to search for
  37677. * @return the found skeleton or null if not found at all.
  37678. */
  37679. getSkeletonByName(name: string): Nullable<Skeleton>;
  37680. /**
  37681. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37682. * @param id defines the id to search for
  37683. * @return the found morph target manager or null if not found at all.
  37684. */
  37685. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37686. /**
  37687. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37688. * @param id defines the id to search for
  37689. * @return the found morph target or null if not found at all.
  37690. */
  37691. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37692. /**
  37693. * Gets a boolean indicating if the given mesh is active
  37694. * @param mesh defines the mesh to look for
  37695. * @returns true if the mesh is in the active list
  37696. */
  37697. isActiveMesh(mesh: AbstractMesh): boolean;
  37698. /**
  37699. * Return a unique id as a string which can serve as an identifier for the scene
  37700. */
  37701. get uid(): string;
  37702. /**
  37703. * Add an externaly attached data from its key.
  37704. * This method call will fail and return false, if such key already exists.
  37705. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37706. * @param key the unique key that identifies the data
  37707. * @param data the data object to associate to the key for this Engine instance
  37708. * @return true if no such key were already present and the data was added successfully, false otherwise
  37709. */
  37710. addExternalData<T>(key: string, data: T): boolean;
  37711. /**
  37712. * Get an externaly attached data from its key
  37713. * @param key the unique key that identifies the data
  37714. * @return the associated data, if present (can be null), or undefined if not present
  37715. */
  37716. getExternalData<T>(key: string): Nullable<T>;
  37717. /**
  37718. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37719. * @param key the unique key that identifies the data
  37720. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37721. * @return the associated data, can be null if the factory returned null.
  37722. */
  37723. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37724. /**
  37725. * Remove an externaly attached data from the Engine instance
  37726. * @param key the unique key that identifies the data
  37727. * @return true if the data was successfully removed, false if it doesn't exist
  37728. */
  37729. removeExternalData(key: string): boolean;
  37730. private _evaluateSubMesh;
  37731. /**
  37732. * Clear the processed materials smart array preventing retention point in material dispose.
  37733. */
  37734. freeProcessedMaterials(): void;
  37735. private _preventFreeActiveMeshesAndRenderingGroups;
  37736. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37737. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37738. * when disposing several meshes in a row or a hierarchy of meshes.
  37739. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37740. */
  37741. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37742. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37743. /**
  37744. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37745. */
  37746. freeActiveMeshes(): void;
  37747. /**
  37748. * Clear the info related to rendering groups preventing retention points during dispose.
  37749. */
  37750. freeRenderingGroups(): void;
  37751. /** @hidden */
  37752. _isInIntermediateRendering(): boolean;
  37753. /**
  37754. * Lambda returning the list of potentially active meshes.
  37755. */
  37756. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37757. /**
  37758. * Lambda returning the list of potentially active sub meshes.
  37759. */
  37760. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37761. /**
  37762. * Lambda returning the list of potentially intersecting sub meshes.
  37763. */
  37764. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37765. /**
  37766. * Lambda returning the list of potentially colliding sub meshes.
  37767. */
  37768. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37769. private _activeMeshesFrozen;
  37770. private _skipEvaluateActiveMeshesCompletely;
  37771. /**
  37772. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37773. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37774. * @returns the current scene
  37775. */
  37776. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37777. /**
  37778. * Use this function to restart evaluating active meshes on every frame
  37779. * @returns the current scene
  37780. */
  37781. unfreezeActiveMeshes(): Scene;
  37782. private _evaluateActiveMeshes;
  37783. private _activeMesh;
  37784. /**
  37785. * Update the transform matrix to update from the current active camera
  37786. * @param force defines a boolean used to force the update even if cache is up to date
  37787. */
  37788. updateTransformMatrix(force?: boolean): void;
  37789. private _bindFrameBuffer;
  37790. /** @hidden */
  37791. _allowPostProcessClearColor: boolean;
  37792. /** @hidden */
  37793. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37794. private _processSubCameras;
  37795. private _checkIntersections;
  37796. /** @hidden */
  37797. _advancePhysicsEngineStep(step: number): void;
  37798. /**
  37799. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37800. */
  37801. getDeterministicFrameTime: () => number;
  37802. /** @hidden */
  37803. _animate(): void;
  37804. /** Execute all animations (for a frame) */
  37805. animate(): void;
  37806. /**
  37807. * Render the scene
  37808. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37809. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37810. */
  37811. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37812. /**
  37813. * Freeze all materials
  37814. * A frozen material will not be updatable but should be faster to render
  37815. */
  37816. freezeMaterials(): void;
  37817. /**
  37818. * Unfreeze all materials
  37819. * A frozen material will not be updatable but should be faster to render
  37820. */
  37821. unfreezeMaterials(): void;
  37822. /**
  37823. * Releases all held ressources
  37824. */
  37825. dispose(): void;
  37826. /**
  37827. * Gets if the scene is already disposed
  37828. */
  37829. get isDisposed(): boolean;
  37830. /**
  37831. * Call this function to reduce memory footprint of the scene.
  37832. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37833. */
  37834. clearCachedVertexData(): void;
  37835. /**
  37836. * This function will remove the local cached buffer data from texture.
  37837. * It will save memory but will prevent the texture from being rebuilt
  37838. */
  37839. cleanCachedTextureBuffer(): void;
  37840. /**
  37841. * Get the world extend vectors with an optional filter
  37842. *
  37843. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37844. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37845. */
  37846. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37847. min: Vector3;
  37848. max: Vector3;
  37849. };
  37850. /**
  37851. * Creates a ray that can be used to pick in the scene
  37852. * @param x defines the x coordinate of the origin (on-screen)
  37853. * @param y defines the y coordinate of the origin (on-screen)
  37854. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37855. * @param camera defines the camera to use for the picking
  37856. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37857. * @returns a Ray
  37858. */
  37859. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37860. /**
  37861. * Creates a ray that can be used to pick in the scene
  37862. * @param x defines the x coordinate of the origin (on-screen)
  37863. * @param y defines the y coordinate of the origin (on-screen)
  37864. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37865. * @param result defines the ray where to store the picking ray
  37866. * @param camera defines the camera to use for the picking
  37867. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37868. * @returns the current scene
  37869. */
  37870. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37871. /**
  37872. * Creates a ray that can be used to pick in the scene
  37873. * @param x defines the x coordinate of the origin (on-screen)
  37874. * @param y defines the y coordinate of the origin (on-screen)
  37875. * @param camera defines the camera to use for the picking
  37876. * @returns a Ray
  37877. */
  37878. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37879. /**
  37880. * Creates a ray that can be used to pick in the scene
  37881. * @param x defines the x coordinate of the origin (on-screen)
  37882. * @param y defines the y coordinate of the origin (on-screen)
  37883. * @param result defines the ray where to store the picking ray
  37884. * @param camera defines the camera to use for the picking
  37885. * @returns the current scene
  37886. */
  37887. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37888. /** Launch a ray to try to pick a mesh in the scene
  37889. * @param x position on screen
  37890. * @param y position on screen
  37891. * @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
  37892. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37893. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37895. * @returns a PickingInfo
  37896. */
  37897. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37898. /** Use the given ray to pick a mesh in the scene
  37899. * @param ray The ray to use to pick meshes
  37900. * @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
  37901. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37903. * @returns a PickingInfo
  37904. */
  37905. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37906. /**
  37907. * Launch a ray to try to pick a mesh in the scene
  37908. * @param x X position on screen
  37909. * @param y Y position on screen
  37910. * @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
  37911. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37913. * @returns an array of PickingInfo
  37914. */
  37915. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37916. /**
  37917. * Launch a ray to try to pick a mesh in the scene
  37918. * @param ray Ray to use
  37919. * @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
  37920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37921. * @returns an array of PickingInfo
  37922. */
  37923. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37924. /**
  37925. * Force the value of meshUnderPointer
  37926. * @param mesh defines the mesh to use
  37927. */
  37928. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37929. /**
  37930. * Gets the mesh under the pointer
  37931. * @returns a Mesh or null if no mesh is under the pointer
  37932. */
  37933. getPointerOverMesh(): Nullable<AbstractMesh>;
  37934. /** @hidden */
  37935. _rebuildGeometries(): void;
  37936. /** @hidden */
  37937. _rebuildTextures(): void;
  37938. private _getByTags;
  37939. /**
  37940. * Get a list of meshes by tags
  37941. * @param tagsQuery defines the tags query to use
  37942. * @param forEach defines a predicate used to filter results
  37943. * @returns an array of Mesh
  37944. */
  37945. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37946. /**
  37947. * Get a list of cameras by tags
  37948. * @param tagsQuery defines the tags query to use
  37949. * @param forEach defines a predicate used to filter results
  37950. * @returns an array of Camera
  37951. */
  37952. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37953. /**
  37954. * Get a list of lights by tags
  37955. * @param tagsQuery defines the tags query to use
  37956. * @param forEach defines a predicate used to filter results
  37957. * @returns an array of Light
  37958. */
  37959. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37960. /**
  37961. * Get a list of materials by tags
  37962. * @param tagsQuery defines the tags query to use
  37963. * @param forEach defines a predicate used to filter results
  37964. * @returns an array of Material
  37965. */
  37966. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37967. /**
  37968. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37969. * This allowed control for front to back rendering or reversly depending of the special needs.
  37970. *
  37971. * @param renderingGroupId The rendering group id corresponding to its index
  37972. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37973. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37974. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37975. */
  37976. 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;
  37977. /**
  37978. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37979. *
  37980. * @param renderingGroupId The rendering group id corresponding to its index
  37981. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37982. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37983. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37984. */
  37985. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37986. /**
  37987. * Gets the current auto clear configuration for one rendering group of the rendering
  37988. * manager.
  37989. * @param index the rendering group index to get the information for
  37990. * @returns The auto clear setup for the requested rendering group
  37991. */
  37992. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37993. private _blockMaterialDirtyMechanism;
  37994. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37995. get blockMaterialDirtyMechanism(): boolean;
  37996. set blockMaterialDirtyMechanism(value: boolean);
  37997. /**
  37998. * Will flag all materials as dirty to trigger new shader compilation
  37999. * @param flag defines the flag used to specify which material part must be marked as dirty
  38000. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38001. */
  38002. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38003. /** @hidden */
  38004. _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;
  38005. /** @hidden */
  38006. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38007. /** @hidden */
  38008. _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;
  38009. /** @hidden */
  38010. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38011. /** @hidden */
  38012. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38013. /** @hidden */
  38014. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38015. }
  38016. }
  38017. declare module "babylonjs/assetContainer" {
  38018. import { AbstractScene } from "babylonjs/abstractScene";
  38019. import { Scene } from "babylonjs/scene";
  38020. import { Mesh } from "babylonjs/Meshes/mesh";
  38021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38022. import { Skeleton } from "babylonjs/Bones/skeleton";
  38023. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38024. import { Animatable } from "babylonjs/Animations/animatable";
  38025. import { Nullable } from "babylonjs/types";
  38026. import { Node } from "babylonjs/node";
  38027. /**
  38028. * Set of assets to keep when moving a scene into an asset container.
  38029. */
  38030. export class KeepAssets extends AbstractScene {
  38031. }
  38032. /**
  38033. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38034. */
  38035. export class InstantiatedEntries {
  38036. /**
  38037. * List of new root nodes (eg. nodes with no parent)
  38038. */
  38039. rootNodes: TransformNode[];
  38040. /**
  38041. * List of new skeletons
  38042. */
  38043. skeletons: Skeleton[];
  38044. /**
  38045. * List of new animation groups
  38046. */
  38047. animationGroups: AnimationGroup[];
  38048. }
  38049. /**
  38050. * Container with a set of assets that can be added or removed from a scene.
  38051. */
  38052. export class AssetContainer extends AbstractScene {
  38053. private _wasAddedToScene;
  38054. /**
  38055. * The scene the AssetContainer belongs to.
  38056. */
  38057. scene: Scene;
  38058. /**
  38059. * Instantiates an AssetContainer.
  38060. * @param scene The scene the AssetContainer belongs to.
  38061. */
  38062. constructor(scene: Scene);
  38063. /**
  38064. * Instantiate or clone all meshes and add the new ones to the scene.
  38065. * Skeletons and animation groups will all be cloned
  38066. * @param nameFunction defines an optional function used to get new names for clones
  38067. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38068. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38069. */
  38070. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38071. /**
  38072. * Adds all the assets from the container to the scene.
  38073. */
  38074. addAllToScene(): void;
  38075. /**
  38076. * Removes all the assets in the container from the scene
  38077. */
  38078. removeAllFromScene(): void;
  38079. /**
  38080. * Disposes all the assets in the container
  38081. */
  38082. dispose(): void;
  38083. private _moveAssets;
  38084. /**
  38085. * Removes all the assets contained in the scene and adds them to the container.
  38086. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38087. */
  38088. moveAllFromScene(keepAssets?: KeepAssets): void;
  38089. /**
  38090. * 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.
  38091. * @returns the root mesh
  38092. */
  38093. createRootMesh(): Mesh;
  38094. /**
  38095. * Merge animations from this asset container into a scene
  38096. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38097. * @param animatables set of animatables to retarget to a node from the scene
  38098. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38099. */
  38100. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38101. }
  38102. }
  38103. declare module "babylonjs/abstractScene" {
  38104. import { Scene } from "babylonjs/scene";
  38105. import { Nullable } from "babylonjs/types";
  38106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38107. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38108. import { Geometry } from "babylonjs/Meshes/geometry";
  38109. import { Skeleton } from "babylonjs/Bones/skeleton";
  38110. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38111. import { AssetContainer } from "babylonjs/assetContainer";
  38112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38113. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38115. import { Material } from "babylonjs/Materials/material";
  38116. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38117. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38118. import { Camera } from "babylonjs/Cameras/camera";
  38119. import { Light } from "babylonjs/Lights/light";
  38120. import { Node } from "babylonjs/node";
  38121. import { Animation } from "babylonjs/Animations/animation";
  38122. /**
  38123. * Defines how the parser contract is defined.
  38124. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38125. */
  38126. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38127. /**
  38128. * Defines how the individual parser contract is defined.
  38129. * These parser can parse an individual asset
  38130. */
  38131. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38132. /**
  38133. * Base class of the scene acting as a container for the different elements composing a scene.
  38134. * This class is dynamically extended by the different components of the scene increasing
  38135. * flexibility and reducing coupling
  38136. */
  38137. export abstract class AbstractScene {
  38138. /**
  38139. * Stores the list of available parsers in the application.
  38140. */
  38141. private static _BabylonFileParsers;
  38142. /**
  38143. * Stores the list of available individual parsers in the application.
  38144. */
  38145. private static _IndividualBabylonFileParsers;
  38146. /**
  38147. * Adds a parser in the list of available ones
  38148. * @param name Defines the name of the parser
  38149. * @param parser Defines the parser to add
  38150. */
  38151. static AddParser(name: string, parser: BabylonFileParser): void;
  38152. /**
  38153. * Gets a general parser from the list of avaialble ones
  38154. * @param name Defines the name of the parser
  38155. * @returns the requested parser or null
  38156. */
  38157. static GetParser(name: string): Nullable<BabylonFileParser>;
  38158. /**
  38159. * Adds n individual parser in the list of available ones
  38160. * @param name Defines the name of the parser
  38161. * @param parser Defines the parser to add
  38162. */
  38163. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38164. /**
  38165. * Gets an individual parser from the list of avaialble ones
  38166. * @param name Defines the name of the parser
  38167. * @returns the requested parser or null
  38168. */
  38169. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38170. /**
  38171. * Parser json data and populate both a scene and its associated container object
  38172. * @param jsonData Defines the data to parse
  38173. * @param scene Defines the scene to parse the data for
  38174. * @param container Defines the container attached to the parsing sequence
  38175. * @param rootUrl Defines the root url of the data
  38176. */
  38177. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38178. /**
  38179. * Gets the list of root nodes (ie. nodes with no parent)
  38180. */
  38181. rootNodes: Node[];
  38182. /** All of the cameras added to this scene
  38183. * @see http://doc.babylonjs.com/babylon101/cameras
  38184. */
  38185. cameras: Camera[];
  38186. /**
  38187. * All of the lights added to this scene
  38188. * @see http://doc.babylonjs.com/babylon101/lights
  38189. */
  38190. lights: Light[];
  38191. /**
  38192. * All of the (abstract) meshes added to this scene
  38193. */
  38194. meshes: AbstractMesh[];
  38195. /**
  38196. * The list of skeletons added to the scene
  38197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38198. */
  38199. skeletons: Skeleton[];
  38200. /**
  38201. * All of the particle systems added to this scene
  38202. * @see http://doc.babylonjs.com/babylon101/particles
  38203. */
  38204. particleSystems: IParticleSystem[];
  38205. /**
  38206. * Gets a list of Animations associated with the scene
  38207. */
  38208. animations: Animation[];
  38209. /**
  38210. * All of the animation groups added to this scene
  38211. * @see http://doc.babylonjs.com/how_to/group
  38212. */
  38213. animationGroups: AnimationGroup[];
  38214. /**
  38215. * All of the multi-materials added to this scene
  38216. * @see http://doc.babylonjs.com/how_to/multi_materials
  38217. */
  38218. multiMaterials: MultiMaterial[];
  38219. /**
  38220. * All of the materials added to this scene
  38221. * In the context of a Scene, it is not supposed to be modified manually.
  38222. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38223. * Note also that the order of the Material within the array is not significant and might change.
  38224. * @see http://doc.babylonjs.com/babylon101/materials
  38225. */
  38226. materials: Material[];
  38227. /**
  38228. * The list of morph target managers added to the scene
  38229. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38230. */
  38231. morphTargetManagers: MorphTargetManager[];
  38232. /**
  38233. * The list of geometries used in the scene.
  38234. */
  38235. geometries: Geometry[];
  38236. /**
  38237. * All of the tranform nodes added to this scene
  38238. * In the context of a Scene, it is not supposed to be modified manually.
  38239. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38240. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38241. * @see http://doc.babylonjs.com/how_to/transformnode
  38242. */
  38243. transformNodes: TransformNode[];
  38244. /**
  38245. * ActionManagers available on the scene.
  38246. */
  38247. actionManagers: AbstractActionManager[];
  38248. /**
  38249. * Textures to keep.
  38250. */
  38251. textures: BaseTexture[];
  38252. /**
  38253. * Environment texture for the scene
  38254. */
  38255. environmentTexture: Nullable<BaseTexture>;
  38256. /**
  38257. * @returns all meshes, lights, cameras, transformNodes and bones
  38258. */
  38259. getNodes(): Array<Node>;
  38260. }
  38261. }
  38262. declare module "babylonjs/Audio/sound" {
  38263. import { Observable } from "babylonjs/Misc/observable";
  38264. import { Vector3 } from "babylonjs/Maths/math.vector";
  38265. import { Nullable } from "babylonjs/types";
  38266. import { Scene } from "babylonjs/scene";
  38267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38268. /**
  38269. * Interface used to define options for Sound class
  38270. */
  38271. export interface ISoundOptions {
  38272. /**
  38273. * Does the sound autoplay once loaded.
  38274. */
  38275. autoplay?: boolean;
  38276. /**
  38277. * Does the sound loop after it finishes playing once.
  38278. */
  38279. loop?: boolean;
  38280. /**
  38281. * Sound's volume
  38282. */
  38283. volume?: number;
  38284. /**
  38285. * Is it a spatial sound?
  38286. */
  38287. spatialSound?: boolean;
  38288. /**
  38289. * Maximum distance to hear that sound
  38290. */
  38291. maxDistance?: number;
  38292. /**
  38293. * Uses user defined attenuation function
  38294. */
  38295. useCustomAttenuation?: boolean;
  38296. /**
  38297. * Define the roll off factor of spatial sounds.
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38299. */
  38300. rolloffFactor?: number;
  38301. /**
  38302. * Define the reference distance the sound should be heard perfectly.
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38304. */
  38305. refDistance?: number;
  38306. /**
  38307. * Define the distance attenuation model the sound will follow.
  38308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38309. */
  38310. distanceModel?: string;
  38311. /**
  38312. * Defines the playback speed (1 by default)
  38313. */
  38314. playbackRate?: number;
  38315. /**
  38316. * Defines if the sound is from a streaming source
  38317. */
  38318. streaming?: boolean;
  38319. /**
  38320. * Defines an optional length (in seconds) inside the sound file
  38321. */
  38322. length?: number;
  38323. /**
  38324. * Defines an optional offset (in seconds) inside the sound file
  38325. */
  38326. offset?: number;
  38327. /**
  38328. * If true, URLs will not be required to state the audio file codec to use.
  38329. */
  38330. skipCodecCheck?: boolean;
  38331. }
  38332. /**
  38333. * Defines a sound that can be played in the application.
  38334. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38336. */
  38337. export class Sound {
  38338. /**
  38339. * The name of the sound in the scene.
  38340. */
  38341. name: string;
  38342. /**
  38343. * Does the sound autoplay once loaded.
  38344. */
  38345. autoplay: boolean;
  38346. /**
  38347. * Does the sound loop after it finishes playing once.
  38348. */
  38349. loop: boolean;
  38350. /**
  38351. * Does the sound use a custom attenuation curve to simulate the falloff
  38352. * happening when the source gets further away from the camera.
  38353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38354. */
  38355. useCustomAttenuation: boolean;
  38356. /**
  38357. * The sound track id this sound belongs to.
  38358. */
  38359. soundTrackId: number;
  38360. /**
  38361. * Is this sound currently played.
  38362. */
  38363. isPlaying: boolean;
  38364. /**
  38365. * Is this sound currently paused.
  38366. */
  38367. isPaused: boolean;
  38368. /**
  38369. * Does this sound enables spatial sound.
  38370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38371. */
  38372. spatialSound: boolean;
  38373. /**
  38374. * Define the reference distance the sound should be heard perfectly.
  38375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38376. */
  38377. refDistance: number;
  38378. /**
  38379. * Define the roll off factor of spatial sounds.
  38380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38381. */
  38382. rolloffFactor: number;
  38383. /**
  38384. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38386. */
  38387. maxDistance: number;
  38388. /**
  38389. * Define the distance attenuation model the sound will follow.
  38390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38391. */
  38392. distanceModel: string;
  38393. /**
  38394. * @hidden
  38395. * Back Compat
  38396. **/
  38397. onended: () => any;
  38398. /**
  38399. * Observable event when the current playing sound finishes.
  38400. */
  38401. onEndedObservable: Observable<Sound>;
  38402. private _panningModel;
  38403. private _playbackRate;
  38404. private _streaming;
  38405. private _startTime;
  38406. private _startOffset;
  38407. private _position;
  38408. /** @hidden */
  38409. _positionInEmitterSpace: boolean;
  38410. private _localDirection;
  38411. private _volume;
  38412. private _isReadyToPlay;
  38413. private _isDirectional;
  38414. private _readyToPlayCallback;
  38415. private _audioBuffer;
  38416. private _soundSource;
  38417. private _streamingSource;
  38418. private _soundPanner;
  38419. private _soundGain;
  38420. private _inputAudioNode;
  38421. private _outputAudioNode;
  38422. private _coneInnerAngle;
  38423. private _coneOuterAngle;
  38424. private _coneOuterGain;
  38425. private _scene;
  38426. private _connectedTransformNode;
  38427. private _customAttenuationFunction;
  38428. private _registerFunc;
  38429. private _isOutputConnected;
  38430. private _htmlAudioElement;
  38431. private _urlType;
  38432. private _length?;
  38433. private _offset?;
  38434. /** @hidden */
  38435. static _SceneComponentInitialization: (scene: Scene) => void;
  38436. /**
  38437. * Create a sound and attach it to a scene
  38438. * @param name Name of your sound
  38439. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38440. * @param scene defines the scene the sound belongs to
  38441. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38442. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38443. */
  38444. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38445. /**
  38446. * Release the sound and its associated resources
  38447. */
  38448. dispose(): void;
  38449. /**
  38450. * Gets if the sounds is ready to be played or not.
  38451. * @returns true if ready, otherwise false
  38452. */
  38453. isReady(): boolean;
  38454. private _soundLoaded;
  38455. /**
  38456. * Sets the data of the sound from an audiobuffer
  38457. * @param audioBuffer The audioBuffer containing the data
  38458. */
  38459. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38460. /**
  38461. * Updates the current sounds options such as maxdistance, loop...
  38462. * @param options A JSON object containing values named as the object properties
  38463. */
  38464. updateOptions(options: ISoundOptions): void;
  38465. private _createSpatialParameters;
  38466. private _updateSpatialParameters;
  38467. /**
  38468. * Switch the panning model to HRTF:
  38469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38471. */
  38472. switchPanningModelToHRTF(): void;
  38473. /**
  38474. * Switch the panning model to Equal Power:
  38475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38477. */
  38478. switchPanningModelToEqualPower(): void;
  38479. private _switchPanningModel;
  38480. /**
  38481. * Connect this sound to a sound track audio node like gain...
  38482. * @param soundTrackAudioNode the sound track audio node to connect to
  38483. */
  38484. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38485. /**
  38486. * Transform this sound into a directional source
  38487. * @param coneInnerAngle Size of the inner cone in degree
  38488. * @param coneOuterAngle Size of the outer cone in degree
  38489. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38490. */
  38491. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38492. /**
  38493. * Gets or sets the inner angle for the directional cone.
  38494. */
  38495. get directionalConeInnerAngle(): number;
  38496. /**
  38497. * Gets or sets the inner angle for the directional cone.
  38498. */
  38499. set directionalConeInnerAngle(value: number);
  38500. /**
  38501. * Gets or sets the outer angle for the directional cone.
  38502. */
  38503. get directionalConeOuterAngle(): number;
  38504. /**
  38505. * Gets or sets the outer angle for the directional cone.
  38506. */
  38507. set directionalConeOuterAngle(value: number);
  38508. /**
  38509. * Sets the position of the emitter if spatial sound is enabled
  38510. * @param newPosition Defines the new posisiton
  38511. */
  38512. setPosition(newPosition: Vector3): void;
  38513. /**
  38514. * Sets the local direction of the emitter if spatial sound is enabled
  38515. * @param newLocalDirection Defines the new local direction
  38516. */
  38517. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38518. private _updateDirection;
  38519. /** @hidden */
  38520. updateDistanceFromListener(): void;
  38521. /**
  38522. * Sets a new custom attenuation function for the sound.
  38523. * @param callback Defines the function used for the attenuation
  38524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38525. */
  38526. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38527. /**
  38528. * Play the sound
  38529. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38530. * @param offset (optional) Start the sound at a specific time in seconds
  38531. * @param length (optional) Sound duration (in seconds)
  38532. */
  38533. play(time?: number, offset?: number, length?: number): void;
  38534. private _onended;
  38535. /**
  38536. * Stop the sound
  38537. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38538. */
  38539. stop(time?: number): void;
  38540. /**
  38541. * Put the sound in pause
  38542. */
  38543. pause(): void;
  38544. /**
  38545. * Sets a dedicated volume for this sounds
  38546. * @param newVolume Define the new volume of the sound
  38547. * @param time Define time for gradual change to new volume
  38548. */
  38549. setVolume(newVolume: number, time?: number): void;
  38550. /**
  38551. * Set the sound play back rate
  38552. * @param newPlaybackRate Define the playback rate the sound should be played at
  38553. */
  38554. setPlaybackRate(newPlaybackRate: number): void;
  38555. /**
  38556. * Gets the volume of the sound.
  38557. * @returns the volume of the sound
  38558. */
  38559. getVolume(): number;
  38560. /**
  38561. * Attach the sound to a dedicated mesh
  38562. * @param transformNode The transform node to connect the sound with
  38563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38564. */
  38565. attachToMesh(transformNode: TransformNode): void;
  38566. /**
  38567. * Detach the sound from the previously attached mesh
  38568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38569. */
  38570. detachFromMesh(): void;
  38571. private _onRegisterAfterWorldMatrixUpdate;
  38572. /**
  38573. * Clone the current sound in the scene.
  38574. * @returns the new sound clone
  38575. */
  38576. clone(): Nullable<Sound>;
  38577. /**
  38578. * Gets the current underlying audio buffer containing the data
  38579. * @returns the audio buffer
  38580. */
  38581. getAudioBuffer(): Nullable<AudioBuffer>;
  38582. /**
  38583. * Serializes the Sound in a JSON representation
  38584. * @returns the JSON representation of the sound
  38585. */
  38586. serialize(): any;
  38587. /**
  38588. * Parse a JSON representation of a sound to innstantiate in a given scene
  38589. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38590. * @param scene Define the scene the new parsed sound should be created in
  38591. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38592. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38593. * @returns the newly parsed sound
  38594. */
  38595. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38596. }
  38597. }
  38598. declare module "babylonjs/Actions/directAudioActions" {
  38599. import { Action } from "babylonjs/Actions/action";
  38600. import { Condition } from "babylonjs/Actions/condition";
  38601. import { Sound } from "babylonjs/Audio/sound";
  38602. /**
  38603. * This defines an action helpful to play a defined sound on a triggered action.
  38604. */
  38605. export class PlaySoundAction extends Action {
  38606. private _sound;
  38607. /**
  38608. * Instantiate the action
  38609. * @param triggerOptions defines the trigger options
  38610. * @param sound defines the sound to play
  38611. * @param condition defines the trigger related conditions
  38612. */
  38613. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38614. /** @hidden */
  38615. _prepare(): void;
  38616. /**
  38617. * Execute the action and play the sound.
  38618. */
  38619. execute(): void;
  38620. /**
  38621. * Serializes the actions and its related information.
  38622. * @param parent defines the object to serialize in
  38623. * @returns the serialized object
  38624. */
  38625. serialize(parent: any): any;
  38626. }
  38627. /**
  38628. * This defines an action helpful to stop a defined sound on a triggered action.
  38629. */
  38630. export class StopSoundAction extends Action {
  38631. private _sound;
  38632. /**
  38633. * Instantiate the action
  38634. * @param triggerOptions defines the trigger options
  38635. * @param sound defines the sound to stop
  38636. * @param condition defines the trigger related conditions
  38637. */
  38638. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38639. /** @hidden */
  38640. _prepare(): void;
  38641. /**
  38642. * Execute the action and stop the sound.
  38643. */
  38644. execute(): void;
  38645. /**
  38646. * Serializes the actions and its related information.
  38647. * @param parent defines the object to serialize in
  38648. * @returns the serialized object
  38649. */
  38650. serialize(parent: any): any;
  38651. }
  38652. }
  38653. declare module "babylonjs/Actions/interpolateValueAction" {
  38654. import { Action } from "babylonjs/Actions/action";
  38655. import { Condition } from "babylonjs/Actions/condition";
  38656. import { Observable } from "babylonjs/Misc/observable";
  38657. /**
  38658. * This defines an action responsible to change the value of a property
  38659. * by interpolating between its current value and the newly set one once triggered.
  38660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38661. */
  38662. export class InterpolateValueAction extends Action {
  38663. /**
  38664. * Defines the path of the property where the value should be interpolated
  38665. */
  38666. propertyPath: string;
  38667. /**
  38668. * Defines the target value at the end of the interpolation.
  38669. */
  38670. value: any;
  38671. /**
  38672. * Defines the time it will take for the property to interpolate to the value.
  38673. */
  38674. duration: number;
  38675. /**
  38676. * Defines if the other scene animations should be stopped when the action has been triggered
  38677. */
  38678. stopOtherAnimations?: boolean;
  38679. /**
  38680. * Defines a callback raised once the interpolation animation has been done.
  38681. */
  38682. onInterpolationDone?: () => void;
  38683. /**
  38684. * Observable triggered once the interpolation animation has been done.
  38685. */
  38686. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38687. private _target;
  38688. private _effectiveTarget;
  38689. private _property;
  38690. /**
  38691. * Instantiate the action
  38692. * @param triggerOptions defines the trigger options
  38693. * @param target defines the object containing the value to interpolate
  38694. * @param propertyPath defines the path to the property in the target object
  38695. * @param value defines the target value at the end of the interpolation
  38696. * @param duration deines the time it will take for the property to interpolate to the value.
  38697. * @param condition defines the trigger related conditions
  38698. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38699. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38700. */
  38701. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38702. /** @hidden */
  38703. _prepare(): void;
  38704. /**
  38705. * Execute the action starts the value interpolation.
  38706. */
  38707. execute(): void;
  38708. /**
  38709. * Serializes the actions and its related information.
  38710. * @param parent defines the object to serialize in
  38711. * @returns the serialized object
  38712. */
  38713. serialize(parent: any): any;
  38714. }
  38715. }
  38716. declare module "babylonjs/Actions/index" {
  38717. export * from "babylonjs/Actions/abstractActionManager";
  38718. export * from "babylonjs/Actions/action";
  38719. export * from "babylonjs/Actions/actionEvent";
  38720. export * from "babylonjs/Actions/actionManager";
  38721. export * from "babylonjs/Actions/condition";
  38722. export * from "babylonjs/Actions/directActions";
  38723. export * from "babylonjs/Actions/directAudioActions";
  38724. export * from "babylonjs/Actions/interpolateValueAction";
  38725. }
  38726. declare module "babylonjs/Animations/index" {
  38727. export * from "babylonjs/Animations/animatable";
  38728. export * from "babylonjs/Animations/animation";
  38729. export * from "babylonjs/Animations/animationGroup";
  38730. export * from "babylonjs/Animations/animationPropertiesOverride";
  38731. export * from "babylonjs/Animations/easing";
  38732. export * from "babylonjs/Animations/runtimeAnimation";
  38733. export * from "babylonjs/Animations/animationEvent";
  38734. export * from "babylonjs/Animations/animationGroup";
  38735. export * from "babylonjs/Animations/animationKey";
  38736. export * from "babylonjs/Animations/animationRange";
  38737. export * from "babylonjs/Animations/animatable.interface";
  38738. }
  38739. declare module "babylonjs/Audio/soundTrack" {
  38740. import { Sound } from "babylonjs/Audio/sound";
  38741. import { Analyser } from "babylonjs/Audio/analyser";
  38742. import { Scene } from "babylonjs/scene";
  38743. /**
  38744. * Options allowed during the creation of a sound track.
  38745. */
  38746. export interface ISoundTrackOptions {
  38747. /**
  38748. * The volume the sound track should take during creation
  38749. */
  38750. volume?: number;
  38751. /**
  38752. * Define if the sound track is the main sound track of the scene
  38753. */
  38754. mainTrack?: boolean;
  38755. }
  38756. /**
  38757. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38758. * It will be also used in a future release to apply effects on a specific track.
  38759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38760. */
  38761. export class SoundTrack {
  38762. /**
  38763. * The unique identifier of the sound track in the scene.
  38764. */
  38765. id: number;
  38766. /**
  38767. * The list of sounds included in the sound track.
  38768. */
  38769. soundCollection: Array<Sound>;
  38770. private _outputAudioNode;
  38771. private _scene;
  38772. private _connectedAnalyser;
  38773. private _options;
  38774. private _isInitialized;
  38775. /**
  38776. * Creates a new sound track.
  38777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38778. * @param scene Define the scene the sound track belongs to
  38779. * @param options
  38780. */
  38781. constructor(scene: Scene, options?: ISoundTrackOptions);
  38782. private _initializeSoundTrackAudioGraph;
  38783. /**
  38784. * Release the sound track and its associated resources
  38785. */
  38786. dispose(): void;
  38787. /**
  38788. * Adds a sound to this sound track
  38789. * @param sound define the cound to add
  38790. * @ignoreNaming
  38791. */
  38792. AddSound(sound: Sound): void;
  38793. /**
  38794. * Removes a sound to this sound track
  38795. * @param sound define the cound to remove
  38796. * @ignoreNaming
  38797. */
  38798. RemoveSound(sound: Sound): void;
  38799. /**
  38800. * Set a global volume for the full sound track.
  38801. * @param newVolume Define the new volume of the sound track
  38802. */
  38803. setVolume(newVolume: number): void;
  38804. /**
  38805. * Switch the panning model to HRTF:
  38806. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38808. */
  38809. switchPanningModelToHRTF(): void;
  38810. /**
  38811. * Switch the panning model to Equal Power:
  38812. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38814. */
  38815. switchPanningModelToEqualPower(): void;
  38816. /**
  38817. * Connect the sound track to an audio analyser allowing some amazing
  38818. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38820. * @param analyser The analyser to connect to the engine
  38821. */
  38822. connectToAnalyser(analyser: Analyser): void;
  38823. }
  38824. }
  38825. declare module "babylonjs/Audio/audioSceneComponent" {
  38826. import { Sound } from "babylonjs/Audio/sound";
  38827. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38828. import { Nullable } from "babylonjs/types";
  38829. import { Vector3 } from "babylonjs/Maths/math.vector";
  38830. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { AbstractScene } from "babylonjs/abstractScene";
  38833. import "babylonjs/Audio/audioEngine";
  38834. module "babylonjs/abstractScene" {
  38835. interface AbstractScene {
  38836. /**
  38837. * The list of sounds used in the scene.
  38838. */
  38839. sounds: Nullable<Array<Sound>>;
  38840. }
  38841. }
  38842. module "babylonjs/scene" {
  38843. interface Scene {
  38844. /**
  38845. * @hidden
  38846. * Backing field
  38847. */
  38848. _mainSoundTrack: SoundTrack;
  38849. /**
  38850. * The main sound track played by the scene.
  38851. * It cotains your primary collection of sounds.
  38852. */
  38853. mainSoundTrack: SoundTrack;
  38854. /**
  38855. * The list of sound tracks added to the scene
  38856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38857. */
  38858. soundTracks: Nullable<Array<SoundTrack>>;
  38859. /**
  38860. * Gets a sound using a given name
  38861. * @param name defines the name to search for
  38862. * @return the found sound or null if not found at all.
  38863. */
  38864. getSoundByName(name: string): Nullable<Sound>;
  38865. /**
  38866. * Gets or sets if audio support is enabled
  38867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38868. */
  38869. audioEnabled: boolean;
  38870. /**
  38871. * Gets or sets if audio will be output to headphones
  38872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38873. */
  38874. headphone: boolean;
  38875. /**
  38876. * Gets or sets custom audio listener position provider
  38877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38878. */
  38879. audioListenerPositionProvider: Nullable<() => Vector3>;
  38880. /**
  38881. * Gets or sets a refresh rate when using 3D audio positioning
  38882. */
  38883. audioPositioningRefreshRate: number;
  38884. }
  38885. }
  38886. /**
  38887. * Defines the sound scene component responsible to manage any sounds
  38888. * in a given scene.
  38889. */
  38890. export class AudioSceneComponent implements ISceneSerializableComponent {
  38891. /**
  38892. * The component name helpfull to identify the component in the list of scene components.
  38893. */
  38894. readonly name: string;
  38895. /**
  38896. * The scene the component belongs to.
  38897. */
  38898. scene: Scene;
  38899. private _audioEnabled;
  38900. /**
  38901. * Gets whether audio is enabled or not.
  38902. * Please use related enable/disable method to switch state.
  38903. */
  38904. get audioEnabled(): boolean;
  38905. private _headphone;
  38906. /**
  38907. * Gets whether audio is outputing to headphone or not.
  38908. * Please use the according Switch methods to change output.
  38909. */
  38910. get headphone(): boolean;
  38911. /**
  38912. * Gets or sets a refresh rate when using 3D audio positioning
  38913. */
  38914. audioPositioningRefreshRate: number;
  38915. private _audioListenerPositionProvider;
  38916. /**
  38917. * Gets the current audio listener position provider
  38918. */
  38919. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38920. /**
  38921. * Sets a custom listener position for all sounds in the scene
  38922. * By default, this is the position of the first active camera
  38923. */
  38924. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38925. /**
  38926. * Creates a new instance of the component for the given scene
  38927. * @param scene Defines the scene to register the component in
  38928. */
  38929. constructor(scene: Scene);
  38930. /**
  38931. * Registers the component in a given scene
  38932. */
  38933. register(): void;
  38934. /**
  38935. * Rebuilds the elements related to this component in case of
  38936. * context lost for instance.
  38937. */
  38938. rebuild(): void;
  38939. /**
  38940. * Serializes the component data to the specified json object
  38941. * @param serializationObject The object to serialize to
  38942. */
  38943. serialize(serializationObject: any): void;
  38944. /**
  38945. * Adds all the elements from the container to the scene
  38946. * @param container the container holding the elements
  38947. */
  38948. addFromContainer(container: AbstractScene): void;
  38949. /**
  38950. * Removes all the elements in the container from the scene
  38951. * @param container contains the elements to remove
  38952. * @param dispose if the removed element should be disposed (default: false)
  38953. */
  38954. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38955. /**
  38956. * Disposes the component and the associated ressources.
  38957. */
  38958. dispose(): void;
  38959. /**
  38960. * Disables audio in the associated scene.
  38961. */
  38962. disableAudio(): void;
  38963. /**
  38964. * Enables audio in the associated scene.
  38965. */
  38966. enableAudio(): void;
  38967. /**
  38968. * Switch audio to headphone output.
  38969. */
  38970. switchAudioModeForHeadphones(): void;
  38971. /**
  38972. * Switch audio to normal speakers.
  38973. */
  38974. switchAudioModeForNormalSpeakers(): void;
  38975. private _cachedCameraDirection;
  38976. private _cachedCameraPosition;
  38977. private _lastCheck;
  38978. private _afterRender;
  38979. }
  38980. }
  38981. declare module "babylonjs/Audio/weightedsound" {
  38982. import { Sound } from "babylonjs/Audio/sound";
  38983. /**
  38984. * Wraps one or more Sound objects and selects one with random weight for playback.
  38985. */
  38986. export class WeightedSound {
  38987. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38988. loop: boolean;
  38989. private _coneInnerAngle;
  38990. private _coneOuterAngle;
  38991. private _volume;
  38992. /** A Sound is currently playing. */
  38993. isPlaying: boolean;
  38994. /** A Sound is currently paused. */
  38995. isPaused: boolean;
  38996. private _sounds;
  38997. private _weights;
  38998. private _currentIndex?;
  38999. /**
  39000. * Creates a new WeightedSound from the list of sounds given.
  39001. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39002. * @param sounds Array of Sounds that will be selected from.
  39003. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39004. */
  39005. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39006. /**
  39007. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39008. */
  39009. get directionalConeInnerAngle(): number;
  39010. /**
  39011. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39012. */
  39013. set directionalConeInnerAngle(value: number);
  39014. /**
  39015. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39016. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39017. */
  39018. get directionalConeOuterAngle(): number;
  39019. /**
  39020. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39021. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39022. */
  39023. set directionalConeOuterAngle(value: number);
  39024. /**
  39025. * Playback volume.
  39026. */
  39027. get volume(): number;
  39028. /**
  39029. * Playback volume.
  39030. */
  39031. set volume(value: number);
  39032. private _onended;
  39033. /**
  39034. * Suspend playback
  39035. */
  39036. pause(): void;
  39037. /**
  39038. * Stop playback
  39039. */
  39040. stop(): void;
  39041. /**
  39042. * Start playback.
  39043. * @param startOffset Position the clip head at a specific time in seconds.
  39044. */
  39045. play(startOffset?: number): void;
  39046. }
  39047. }
  39048. declare module "babylonjs/Audio/index" {
  39049. export * from "babylonjs/Audio/analyser";
  39050. export * from "babylonjs/Audio/audioEngine";
  39051. export * from "babylonjs/Audio/audioSceneComponent";
  39052. export * from "babylonjs/Audio/sound";
  39053. export * from "babylonjs/Audio/soundTrack";
  39054. export * from "babylonjs/Audio/weightedsound";
  39055. }
  39056. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39057. import { Behavior } from "babylonjs/Behaviors/behavior";
  39058. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39059. import { BackEase } from "babylonjs/Animations/easing";
  39060. /**
  39061. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39063. */
  39064. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39065. /**
  39066. * Gets the name of the behavior.
  39067. */
  39068. get name(): string;
  39069. /**
  39070. * The easing function used by animations
  39071. */
  39072. static EasingFunction: BackEase;
  39073. /**
  39074. * The easing mode used by animations
  39075. */
  39076. static EasingMode: number;
  39077. /**
  39078. * The duration of the animation, in milliseconds
  39079. */
  39080. transitionDuration: number;
  39081. /**
  39082. * Length of the distance animated by the transition when lower radius is reached
  39083. */
  39084. lowerRadiusTransitionRange: number;
  39085. /**
  39086. * Length of the distance animated by the transition when upper radius is reached
  39087. */
  39088. upperRadiusTransitionRange: number;
  39089. private _autoTransitionRange;
  39090. /**
  39091. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39092. */
  39093. get autoTransitionRange(): boolean;
  39094. /**
  39095. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39096. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39097. */
  39098. set autoTransitionRange(value: boolean);
  39099. private _attachedCamera;
  39100. private _onAfterCheckInputsObserver;
  39101. private _onMeshTargetChangedObserver;
  39102. /**
  39103. * Initializes the behavior.
  39104. */
  39105. init(): void;
  39106. /**
  39107. * Attaches the behavior to its arc rotate camera.
  39108. * @param camera Defines the camera to attach the behavior to
  39109. */
  39110. attach(camera: ArcRotateCamera): void;
  39111. /**
  39112. * Detaches the behavior from its current arc rotate camera.
  39113. */
  39114. detach(): void;
  39115. private _radiusIsAnimating;
  39116. private _radiusBounceTransition;
  39117. private _animatables;
  39118. private _cachedWheelPrecision;
  39119. /**
  39120. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39121. * @param radiusLimit The limit to check against.
  39122. * @return Bool to indicate if at limit.
  39123. */
  39124. private _isRadiusAtLimit;
  39125. /**
  39126. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39127. * @param radiusDelta The delta by which to animate to. Can be negative.
  39128. */
  39129. private _applyBoundRadiusAnimation;
  39130. /**
  39131. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39132. */
  39133. protected _clearAnimationLocks(): void;
  39134. /**
  39135. * Stops and removes all animations that have been applied to the camera
  39136. */
  39137. stopAllAnimations(): void;
  39138. }
  39139. }
  39140. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39141. import { Behavior } from "babylonjs/Behaviors/behavior";
  39142. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39143. import { ExponentialEase } from "babylonjs/Animations/easing";
  39144. import { Nullable } from "babylonjs/types";
  39145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39146. import { Vector3 } from "babylonjs/Maths/math.vector";
  39147. /**
  39148. * 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.
  39149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39150. */
  39151. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39152. /**
  39153. * Gets the name of the behavior.
  39154. */
  39155. get name(): string;
  39156. private _mode;
  39157. private _radiusScale;
  39158. private _positionScale;
  39159. private _defaultElevation;
  39160. private _elevationReturnTime;
  39161. private _elevationReturnWaitTime;
  39162. private _zoomStopsAnimation;
  39163. private _framingTime;
  39164. /**
  39165. * The easing function used by animations
  39166. */
  39167. static EasingFunction: ExponentialEase;
  39168. /**
  39169. * The easing mode used by animations
  39170. */
  39171. static EasingMode: number;
  39172. /**
  39173. * Sets the current mode used by the behavior
  39174. */
  39175. set mode(mode: number);
  39176. /**
  39177. * Gets current mode used by the behavior.
  39178. */
  39179. get mode(): number;
  39180. /**
  39181. * Sets the scale applied to the radius (1 by default)
  39182. */
  39183. set radiusScale(radius: number);
  39184. /**
  39185. * Gets the scale applied to the radius
  39186. */
  39187. get radiusScale(): number;
  39188. /**
  39189. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39190. */
  39191. set positionScale(scale: number);
  39192. /**
  39193. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39194. */
  39195. get positionScale(): number;
  39196. /**
  39197. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39198. * behaviour is triggered, in radians.
  39199. */
  39200. set defaultElevation(elevation: number);
  39201. /**
  39202. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39203. * behaviour is triggered, in radians.
  39204. */
  39205. get defaultElevation(): number;
  39206. /**
  39207. * Sets the time (in milliseconds) taken to return to the default beta position.
  39208. * Negative value indicates camera should not return to default.
  39209. */
  39210. set elevationReturnTime(speed: number);
  39211. /**
  39212. * Gets the time (in milliseconds) taken to return to the default beta position.
  39213. * Negative value indicates camera should not return to default.
  39214. */
  39215. get elevationReturnTime(): number;
  39216. /**
  39217. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39218. */
  39219. set elevationReturnWaitTime(time: number);
  39220. /**
  39221. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39222. */
  39223. get elevationReturnWaitTime(): number;
  39224. /**
  39225. * Sets the flag that indicates if user zooming should stop animation.
  39226. */
  39227. set zoomStopsAnimation(flag: boolean);
  39228. /**
  39229. * Gets the flag that indicates if user zooming should stop animation.
  39230. */
  39231. get zoomStopsAnimation(): boolean;
  39232. /**
  39233. * Sets the transition time when framing the mesh, in milliseconds
  39234. */
  39235. set framingTime(time: number);
  39236. /**
  39237. * Gets the transition time when framing the mesh, in milliseconds
  39238. */
  39239. get framingTime(): number;
  39240. /**
  39241. * Define if the behavior should automatically change the configured
  39242. * camera limits and sensibilities.
  39243. */
  39244. autoCorrectCameraLimitsAndSensibility: boolean;
  39245. private _onPrePointerObservableObserver;
  39246. private _onAfterCheckInputsObserver;
  39247. private _onMeshTargetChangedObserver;
  39248. private _attachedCamera;
  39249. private _isPointerDown;
  39250. private _lastInteractionTime;
  39251. /**
  39252. * Initializes the behavior.
  39253. */
  39254. init(): void;
  39255. /**
  39256. * Attaches the behavior to its arc rotate camera.
  39257. * @param camera Defines the camera to attach the behavior to
  39258. */
  39259. attach(camera: ArcRotateCamera): void;
  39260. /**
  39261. * Detaches the behavior from its current arc rotate camera.
  39262. */
  39263. detach(): void;
  39264. private _animatables;
  39265. private _betaIsAnimating;
  39266. private _betaTransition;
  39267. private _radiusTransition;
  39268. private _vectorTransition;
  39269. /**
  39270. * Targets the given mesh and updates zoom level accordingly.
  39271. * @param mesh The mesh to target.
  39272. * @param radius Optional. If a cached radius position already exists, overrides default.
  39273. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39274. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39275. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39276. */
  39277. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39278. /**
  39279. * Targets the given mesh with its children and updates zoom level accordingly.
  39280. * @param mesh The mesh to target.
  39281. * @param radius Optional. If a cached radius position already exists, overrides default.
  39282. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39283. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39284. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39285. */
  39286. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39287. /**
  39288. * Targets the given meshes with their children and updates zoom level accordingly.
  39289. * @param meshes The mesh to target.
  39290. * @param radius Optional. If a cached radius position already exists, overrides default.
  39291. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39294. */
  39295. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39296. /**
  39297. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39298. * @param minimumWorld Determines the smaller position of the bounding box extend
  39299. * @param maximumWorld Determines the bigger position of the bounding box extend
  39300. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39301. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39302. */
  39303. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39304. /**
  39305. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39306. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39307. * frustum width.
  39308. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39309. * to fully enclose the mesh in the viewing frustum.
  39310. */
  39311. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39312. /**
  39313. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39314. * is automatically returned to its default position (expected to be above ground plane).
  39315. */
  39316. private _maintainCameraAboveGround;
  39317. /**
  39318. * Returns the frustum slope based on the canvas ratio and camera FOV
  39319. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39320. */
  39321. private _getFrustumSlope;
  39322. /**
  39323. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39324. */
  39325. private _clearAnimationLocks;
  39326. /**
  39327. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39328. */
  39329. private _applyUserInteraction;
  39330. /**
  39331. * Stops and removes all animations that have been applied to the camera
  39332. */
  39333. stopAllAnimations(): void;
  39334. /**
  39335. * Gets a value indicating if the user is moving the camera
  39336. */
  39337. get isUserIsMoving(): boolean;
  39338. /**
  39339. * The camera can move all the way towards the mesh.
  39340. */
  39341. static IgnoreBoundsSizeMode: number;
  39342. /**
  39343. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39344. */
  39345. static FitFrustumSidesMode: number;
  39346. }
  39347. }
  39348. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39349. import { Nullable } from "babylonjs/types";
  39350. import { Camera } from "babylonjs/Cameras/camera";
  39351. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39352. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39353. /**
  39354. * Base class for Camera Pointer Inputs.
  39355. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39356. * for example usage.
  39357. */
  39358. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39359. /**
  39360. * Defines the camera the input is attached to.
  39361. */
  39362. abstract camera: Camera;
  39363. /**
  39364. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39365. */
  39366. protected _altKey: boolean;
  39367. protected _ctrlKey: boolean;
  39368. protected _metaKey: boolean;
  39369. protected _shiftKey: boolean;
  39370. /**
  39371. * Which mouse buttons were pressed at time of last mouse event.
  39372. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39373. */
  39374. protected _buttonsPressed: number;
  39375. /**
  39376. * Defines the buttons associated with the input to handle camera move.
  39377. */
  39378. buttons: number[];
  39379. /**
  39380. * Attach the input controls to a specific dom element to get the input from.
  39381. * @param element Defines the element the controls should be listened from
  39382. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39383. */
  39384. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39385. /**
  39386. * Detach the current controls from the specified dom element.
  39387. * @param element Defines the element to stop listening the inputs from
  39388. */
  39389. detachControl(element: Nullable<HTMLElement>): void;
  39390. /**
  39391. * Gets the class name of the current input.
  39392. * @returns the class name
  39393. */
  39394. getClassName(): string;
  39395. /**
  39396. * Get the friendly name associated with the input class.
  39397. * @returns the input friendly name
  39398. */
  39399. getSimpleName(): string;
  39400. /**
  39401. * Called on pointer POINTERDOUBLETAP event.
  39402. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39403. */
  39404. protected onDoubleTap(type: string): void;
  39405. /**
  39406. * Called on pointer POINTERMOVE event if only a single touch is active.
  39407. * Override this method to provide functionality.
  39408. */
  39409. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39410. /**
  39411. * Called on pointer POINTERMOVE event if multiple touches are active.
  39412. * Override this method to provide functionality.
  39413. */
  39414. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39415. /**
  39416. * Called on JS contextmenu event.
  39417. * Override this method to provide functionality.
  39418. */
  39419. protected onContextMenu(evt: PointerEvent): void;
  39420. /**
  39421. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39422. * press.
  39423. * Override this method to provide functionality.
  39424. */
  39425. protected onButtonDown(evt: PointerEvent): void;
  39426. /**
  39427. * Called each time a new POINTERUP event occurs. Ie, for each button
  39428. * release.
  39429. * Override this method to provide functionality.
  39430. */
  39431. protected onButtonUp(evt: PointerEvent): void;
  39432. /**
  39433. * Called when window becomes inactive.
  39434. * Override this method to provide functionality.
  39435. */
  39436. protected onLostFocus(): void;
  39437. private _pointerInput;
  39438. private _observer;
  39439. private _onLostFocus;
  39440. private pointA;
  39441. private pointB;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39445. import { Nullable } from "babylonjs/types";
  39446. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39447. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39448. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39449. /**
  39450. * Manage the pointers inputs to control an arc rotate camera.
  39451. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39452. */
  39453. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39454. /**
  39455. * Defines the camera the input is attached to.
  39456. */
  39457. camera: ArcRotateCamera;
  39458. /**
  39459. * Gets the class name of the current input.
  39460. * @returns the class name
  39461. */
  39462. getClassName(): string;
  39463. /**
  39464. * Defines the buttons associated with the input to handle camera move.
  39465. */
  39466. buttons: number[];
  39467. /**
  39468. * Defines the pointer angular sensibility along the X axis or how fast is
  39469. * the camera rotating.
  39470. */
  39471. angularSensibilityX: number;
  39472. /**
  39473. * Defines the pointer angular sensibility along the Y axis or how fast is
  39474. * the camera rotating.
  39475. */
  39476. angularSensibilityY: number;
  39477. /**
  39478. * Defines the pointer pinch precision or how fast is the camera zooming.
  39479. */
  39480. pinchPrecision: number;
  39481. /**
  39482. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39483. * from 0.
  39484. * It defines the percentage of current camera.radius to use as delta when
  39485. * pinch zoom is used.
  39486. */
  39487. pinchDeltaPercentage: number;
  39488. /**
  39489. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39490. * that any object in the plane at the camera's target point will scale
  39491. * perfectly with finger motion.
  39492. * Overrides pinchDeltaPercentage and pinchPrecision.
  39493. */
  39494. useNaturalPinchZoom: boolean;
  39495. /**
  39496. * Defines the pointer panning sensibility or how fast is the camera moving.
  39497. */
  39498. panningSensibility: number;
  39499. /**
  39500. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39501. */
  39502. multiTouchPanning: boolean;
  39503. /**
  39504. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39505. * zoom (pinch) through multitouch.
  39506. */
  39507. multiTouchPanAndZoom: boolean;
  39508. /**
  39509. * Revers pinch action direction.
  39510. */
  39511. pinchInwards: boolean;
  39512. private _isPanClick;
  39513. private _twoFingerActivityCount;
  39514. private _isPinching;
  39515. /**
  39516. * Called on pointer POINTERMOVE event if only a single touch is active.
  39517. */
  39518. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39519. /**
  39520. * Called on pointer POINTERDOUBLETAP event.
  39521. */
  39522. protected onDoubleTap(type: string): void;
  39523. /**
  39524. * Called on pointer POINTERMOVE event if multiple touches are active.
  39525. */
  39526. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39527. /**
  39528. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39529. * press.
  39530. */
  39531. protected onButtonDown(evt: PointerEvent): void;
  39532. /**
  39533. * Called each time a new POINTERUP event occurs. Ie, for each button
  39534. * release.
  39535. */
  39536. protected onButtonUp(evt: PointerEvent): void;
  39537. /**
  39538. * Called when window becomes inactive.
  39539. */
  39540. protected onLostFocus(): void;
  39541. }
  39542. }
  39543. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39544. import { Nullable } from "babylonjs/types";
  39545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39547. /**
  39548. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39550. */
  39551. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39552. /**
  39553. * Defines the camera the input is attached to.
  39554. */
  39555. camera: ArcRotateCamera;
  39556. /**
  39557. * Defines the list of key codes associated with the up action (increase alpha)
  39558. */
  39559. keysUp: number[];
  39560. /**
  39561. * Defines the list of key codes associated with the down action (decrease alpha)
  39562. */
  39563. keysDown: number[];
  39564. /**
  39565. * Defines the list of key codes associated with the left action (increase beta)
  39566. */
  39567. keysLeft: number[];
  39568. /**
  39569. * Defines the list of key codes associated with the right action (decrease beta)
  39570. */
  39571. keysRight: number[];
  39572. /**
  39573. * Defines the list of key codes associated with the reset action.
  39574. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39575. */
  39576. keysReset: number[];
  39577. /**
  39578. * Defines the panning sensibility of the inputs.
  39579. * (How fast is the camera panning)
  39580. */
  39581. panningSensibility: number;
  39582. /**
  39583. * Defines the zooming sensibility of the inputs.
  39584. * (How fast is the camera zooming)
  39585. */
  39586. zoomingSensibility: number;
  39587. /**
  39588. * Defines whether maintaining the alt key down switch the movement mode from
  39589. * orientation to zoom.
  39590. */
  39591. useAltToZoom: boolean;
  39592. /**
  39593. * Rotation speed of the camera
  39594. */
  39595. angularSpeed: number;
  39596. private _keys;
  39597. private _ctrlPressed;
  39598. private _altPressed;
  39599. private _onCanvasBlurObserver;
  39600. private _onKeyboardObserver;
  39601. private _engine;
  39602. private _scene;
  39603. /**
  39604. * Attach the input controls to a specific dom element to get the input from.
  39605. * @param element Defines the element the controls should be listened from
  39606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39607. */
  39608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39609. /**
  39610. * Detach the current controls from the specified dom element.
  39611. * @param element Defines the element to stop listening the inputs from
  39612. */
  39613. detachControl(element: Nullable<HTMLElement>): void;
  39614. /**
  39615. * Update the current camera state depending on the inputs that have been used this frame.
  39616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39617. */
  39618. checkInputs(): void;
  39619. /**
  39620. * Gets the class name of the current intput.
  39621. * @returns the class name
  39622. */
  39623. getClassName(): string;
  39624. /**
  39625. * Get the friendly name associated with the input class.
  39626. * @returns the input friendly name
  39627. */
  39628. getSimpleName(): string;
  39629. }
  39630. }
  39631. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39632. import { Nullable } from "babylonjs/types";
  39633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39634. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39635. /**
  39636. * Manage the mouse wheel inputs to control an arc rotate camera.
  39637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39638. */
  39639. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39640. /**
  39641. * Defines the camera the input is attached to.
  39642. */
  39643. camera: ArcRotateCamera;
  39644. /**
  39645. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39646. */
  39647. wheelPrecision: number;
  39648. /**
  39649. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39650. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39651. */
  39652. wheelDeltaPercentage: number;
  39653. private _wheel;
  39654. private _observer;
  39655. private computeDeltaFromMouseWheelLegacyEvent;
  39656. /**
  39657. * Attach the input controls to a specific dom element to get the input from.
  39658. * @param element Defines the element the controls should be listened from
  39659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39660. */
  39661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39662. /**
  39663. * Detach the current controls from the specified dom element.
  39664. * @param element Defines the element to stop listening the inputs from
  39665. */
  39666. detachControl(element: Nullable<HTMLElement>): void;
  39667. /**
  39668. * Gets the class name of the current intput.
  39669. * @returns the class name
  39670. */
  39671. getClassName(): string;
  39672. /**
  39673. * Get the friendly name associated with the input class.
  39674. * @returns the input friendly name
  39675. */
  39676. getSimpleName(): string;
  39677. }
  39678. }
  39679. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39680. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39681. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39682. /**
  39683. * Default Inputs manager for the ArcRotateCamera.
  39684. * It groups all the default supported inputs for ease of use.
  39685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39686. */
  39687. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39688. /**
  39689. * Instantiates a new ArcRotateCameraInputsManager.
  39690. * @param camera Defines the camera the inputs belong to
  39691. */
  39692. constructor(camera: ArcRotateCamera);
  39693. /**
  39694. * Add mouse wheel input support to the input manager.
  39695. * @returns the current input manager
  39696. */
  39697. addMouseWheel(): ArcRotateCameraInputsManager;
  39698. /**
  39699. * Add pointers input support to the input manager.
  39700. * @returns the current input manager
  39701. */
  39702. addPointers(): ArcRotateCameraInputsManager;
  39703. /**
  39704. * Add keyboard input support to the input manager.
  39705. * @returns the current input manager
  39706. */
  39707. addKeyboard(): ArcRotateCameraInputsManager;
  39708. }
  39709. }
  39710. declare module "babylonjs/Cameras/arcRotateCamera" {
  39711. import { Observable } from "babylonjs/Misc/observable";
  39712. import { Nullable } from "babylonjs/types";
  39713. import { Scene } from "babylonjs/scene";
  39714. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39716. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39717. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39718. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39719. import { Camera } from "babylonjs/Cameras/camera";
  39720. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39721. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39722. import { Collider } from "babylonjs/Collisions/collider";
  39723. /**
  39724. * This represents an orbital type of camera.
  39725. *
  39726. * 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.
  39727. * 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.
  39728. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39729. */
  39730. export class ArcRotateCamera extends TargetCamera {
  39731. /**
  39732. * Defines the rotation angle of the camera along the longitudinal axis.
  39733. */
  39734. alpha: number;
  39735. /**
  39736. * Defines the rotation angle of the camera along the latitudinal axis.
  39737. */
  39738. beta: number;
  39739. /**
  39740. * Defines the radius of the camera from it s target point.
  39741. */
  39742. radius: number;
  39743. protected _target: Vector3;
  39744. protected _targetHost: Nullable<AbstractMesh>;
  39745. /**
  39746. * Defines the target point of the camera.
  39747. * The camera looks towards it form the radius distance.
  39748. */
  39749. get target(): Vector3;
  39750. set target(value: Vector3);
  39751. /**
  39752. * Define the current local position of the camera in the scene
  39753. */
  39754. get position(): Vector3;
  39755. set position(newPosition: Vector3);
  39756. protected _upVector: Vector3;
  39757. protected _upToYMatrix: Matrix;
  39758. protected _YToUpMatrix: Matrix;
  39759. /**
  39760. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39761. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39762. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39763. */
  39764. set upVector(vec: Vector3);
  39765. get upVector(): Vector3;
  39766. /**
  39767. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39768. */
  39769. setMatUp(): void;
  39770. /**
  39771. * Current inertia value on the longitudinal axis.
  39772. * The bigger this number the longer it will take for the camera to stop.
  39773. */
  39774. inertialAlphaOffset: number;
  39775. /**
  39776. * Current inertia value on the latitudinal axis.
  39777. * The bigger this number the longer it will take for the camera to stop.
  39778. */
  39779. inertialBetaOffset: number;
  39780. /**
  39781. * Current inertia value on the radius axis.
  39782. * The bigger this number the longer it will take for the camera to stop.
  39783. */
  39784. inertialRadiusOffset: number;
  39785. /**
  39786. * Minimum allowed angle on the longitudinal axis.
  39787. * This can help limiting how the Camera is able to move in the scene.
  39788. */
  39789. lowerAlphaLimit: Nullable<number>;
  39790. /**
  39791. * Maximum allowed angle on the longitudinal axis.
  39792. * This can help limiting how the Camera is able to move in the scene.
  39793. */
  39794. upperAlphaLimit: Nullable<number>;
  39795. /**
  39796. * Minimum allowed angle on the latitudinal axis.
  39797. * This can help limiting how the Camera is able to move in the scene.
  39798. */
  39799. lowerBetaLimit: number;
  39800. /**
  39801. * Maximum allowed angle on the latitudinal axis.
  39802. * This can help limiting how the Camera is able to move in the scene.
  39803. */
  39804. upperBetaLimit: number;
  39805. /**
  39806. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39807. * This can help limiting how the Camera is able to move in the scene.
  39808. */
  39809. lowerRadiusLimit: Nullable<number>;
  39810. /**
  39811. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39812. * This can help limiting how the Camera is able to move in the scene.
  39813. */
  39814. upperRadiusLimit: Nullable<number>;
  39815. /**
  39816. * Defines the current inertia value used during panning of the camera along the X axis.
  39817. */
  39818. inertialPanningX: number;
  39819. /**
  39820. * Defines the current inertia value used during panning of the camera along the Y axis.
  39821. */
  39822. inertialPanningY: number;
  39823. /**
  39824. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39825. * Basically if your fingers moves away from more than this distance you will be considered
  39826. * in pinch mode.
  39827. */
  39828. pinchToPanMaxDistance: number;
  39829. /**
  39830. * Defines the maximum distance the camera can pan.
  39831. * This could help keeping the cammera always in your scene.
  39832. */
  39833. panningDistanceLimit: Nullable<number>;
  39834. /**
  39835. * Defines the target of the camera before paning.
  39836. */
  39837. panningOriginTarget: Vector3;
  39838. /**
  39839. * Defines the value of the inertia used during panning.
  39840. * 0 would mean stop inertia and one would mean no decelleration at all.
  39841. */
  39842. panningInertia: number;
  39843. /**
  39844. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39845. */
  39846. get angularSensibilityX(): number;
  39847. set angularSensibilityX(value: number);
  39848. /**
  39849. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39850. */
  39851. get angularSensibilityY(): number;
  39852. set angularSensibilityY(value: number);
  39853. /**
  39854. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39855. */
  39856. get pinchPrecision(): number;
  39857. set pinchPrecision(value: number);
  39858. /**
  39859. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39860. * It will be used instead of pinchDeltaPrecision if different from 0.
  39861. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39862. */
  39863. get pinchDeltaPercentage(): number;
  39864. set pinchDeltaPercentage(value: number);
  39865. /**
  39866. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39867. * and pinch delta percentage.
  39868. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39869. * that any object in the plane at the camera's target point will scale
  39870. * perfectly with finger motion.
  39871. */
  39872. get useNaturalPinchZoom(): boolean;
  39873. set useNaturalPinchZoom(value: boolean);
  39874. /**
  39875. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39876. */
  39877. get panningSensibility(): number;
  39878. set panningSensibility(value: number);
  39879. /**
  39880. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39881. */
  39882. get keysUp(): number[];
  39883. set keysUp(value: number[]);
  39884. /**
  39885. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39886. */
  39887. get keysDown(): number[];
  39888. set keysDown(value: number[]);
  39889. /**
  39890. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39891. */
  39892. get keysLeft(): number[];
  39893. set keysLeft(value: number[]);
  39894. /**
  39895. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39896. */
  39897. get keysRight(): number[];
  39898. set keysRight(value: number[]);
  39899. /**
  39900. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39901. */
  39902. get wheelPrecision(): number;
  39903. set wheelPrecision(value: number);
  39904. /**
  39905. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39906. * It will be used instead of pinchDeltaPrecision if different from 0.
  39907. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39908. */
  39909. get wheelDeltaPercentage(): number;
  39910. set wheelDeltaPercentage(value: number);
  39911. /**
  39912. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39913. */
  39914. zoomOnFactor: number;
  39915. /**
  39916. * Defines a screen offset for the camera position.
  39917. */
  39918. targetScreenOffset: Vector2;
  39919. /**
  39920. * Allows the camera to be completely reversed.
  39921. * If false the camera can not arrive upside down.
  39922. */
  39923. allowUpsideDown: boolean;
  39924. /**
  39925. * Define if double tap/click is used to restore the previously saved state of the camera.
  39926. */
  39927. useInputToRestoreState: boolean;
  39928. /** @hidden */
  39929. _viewMatrix: Matrix;
  39930. /** @hidden */
  39931. _useCtrlForPanning: boolean;
  39932. /** @hidden */
  39933. _panningMouseButton: number;
  39934. /**
  39935. * Defines the input associated to the camera.
  39936. */
  39937. inputs: ArcRotateCameraInputsManager;
  39938. /** @hidden */
  39939. _reset: () => void;
  39940. /**
  39941. * Defines the allowed panning axis.
  39942. */
  39943. panningAxis: Vector3;
  39944. protected _localDirection: Vector3;
  39945. protected _transformedDirection: Vector3;
  39946. private _bouncingBehavior;
  39947. /**
  39948. * Gets the bouncing behavior of the camera if it has been enabled.
  39949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39950. */
  39951. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39952. /**
  39953. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39954. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39955. */
  39956. get useBouncingBehavior(): boolean;
  39957. set useBouncingBehavior(value: boolean);
  39958. private _framingBehavior;
  39959. /**
  39960. * Gets the framing behavior of the camera if it has been enabled.
  39961. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39962. */
  39963. get framingBehavior(): Nullable<FramingBehavior>;
  39964. /**
  39965. * Defines if the framing behavior of the camera is enabled on the camera.
  39966. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39967. */
  39968. get useFramingBehavior(): boolean;
  39969. set useFramingBehavior(value: boolean);
  39970. private _autoRotationBehavior;
  39971. /**
  39972. * Gets the auto rotation behavior of the camera if it has been enabled.
  39973. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39974. */
  39975. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39976. /**
  39977. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39978. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39979. */
  39980. get useAutoRotationBehavior(): boolean;
  39981. set useAutoRotationBehavior(value: boolean);
  39982. /**
  39983. * Observable triggered when the mesh target has been changed on the camera.
  39984. */
  39985. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39986. /**
  39987. * Event raised when the camera is colliding with a mesh.
  39988. */
  39989. onCollide: (collidedMesh: AbstractMesh) => void;
  39990. /**
  39991. * Defines whether the camera should check collision with the objects oh the scene.
  39992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39993. */
  39994. checkCollisions: boolean;
  39995. /**
  39996. * Defines the collision radius of the camera.
  39997. * This simulates a sphere around the camera.
  39998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39999. */
  40000. collisionRadius: Vector3;
  40001. protected _collider: Collider;
  40002. protected _previousPosition: Vector3;
  40003. protected _collisionVelocity: Vector3;
  40004. protected _newPosition: Vector3;
  40005. protected _previousAlpha: number;
  40006. protected _previousBeta: number;
  40007. protected _previousRadius: number;
  40008. protected _collisionTriggered: boolean;
  40009. protected _targetBoundingCenter: Nullable<Vector3>;
  40010. private _computationVector;
  40011. /**
  40012. * Instantiates a new ArcRotateCamera in a given scene
  40013. * @param name Defines the name of the camera
  40014. * @param alpha Defines the camera rotation along the logitudinal axis
  40015. * @param beta Defines the camera rotation along the latitudinal axis
  40016. * @param radius Defines the camera distance from its target
  40017. * @param target Defines the camera target
  40018. * @param scene Defines the scene the camera belongs to
  40019. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40020. */
  40021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40022. /** @hidden */
  40023. _initCache(): void;
  40024. /** @hidden */
  40025. _updateCache(ignoreParentClass?: boolean): void;
  40026. protected _getTargetPosition(): Vector3;
  40027. private _storedAlpha;
  40028. private _storedBeta;
  40029. private _storedRadius;
  40030. private _storedTarget;
  40031. private _storedTargetScreenOffset;
  40032. /**
  40033. * Stores the current state of the camera (alpha, beta, radius and target)
  40034. * @returns the camera itself
  40035. */
  40036. storeState(): Camera;
  40037. /**
  40038. * @hidden
  40039. * Restored camera state. You must call storeState() first
  40040. */
  40041. _restoreStateValues(): boolean;
  40042. /** @hidden */
  40043. _isSynchronizedViewMatrix(): boolean;
  40044. /**
  40045. * Attached controls to the current camera.
  40046. * @param element Defines the element the controls should be listened from
  40047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40048. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40049. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40050. */
  40051. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40052. /**
  40053. * Detach the current controls from the camera.
  40054. * The camera will stop reacting to inputs.
  40055. * @param element Defines the element to stop listening the inputs from
  40056. */
  40057. detachControl(element: HTMLElement): void;
  40058. /** @hidden */
  40059. _checkInputs(): void;
  40060. protected _checkLimits(): void;
  40061. /**
  40062. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40063. */
  40064. rebuildAnglesAndRadius(): void;
  40065. /**
  40066. * Use a position to define the current camera related information like alpha, beta and radius
  40067. * @param position Defines the position to set the camera at
  40068. */
  40069. setPosition(position: Vector3): void;
  40070. /**
  40071. * Defines the target the camera should look at.
  40072. * This will automatically adapt alpha beta and radius to fit within the new target.
  40073. * @param target Defines the new target as a Vector or a mesh
  40074. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40075. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40076. */
  40077. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40078. /** @hidden */
  40079. _getViewMatrix(): Matrix;
  40080. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40081. /**
  40082. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40083. * @param meshes Defines the mesh to zoom on
  40084. * @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)
  40085. */
  40086. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40087. /**
  40088. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40089. * The target will be changed but the radius
  40090. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40091. * @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)
  40092. */
  40093. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40094. min: Vector3;
  40095. max: Vector3;
  40096. distance: number;
  40097. }, doNotUpdateMaxZ?: boolean): void;
  40098. /**
  40099. * @override
  40100. * Override Camera.createRigCamera
  40101. */
  40102. createRigCamera(name: string, cameraIndex: number): Camera;
  40103. /**
  40104. * @hidden
  40105. * @override
  40106. * Override Camera._updateRigCameras
  40107. */
  40108. _updateRigCameras(): void;
  40109. /**
  40110. * Destroy the camera and release the current resources hold by it.
  40111. */
  40112. dispose(): void;
  40113. /**
  40114. * Gets the current object class name.
  40115. * @return the class name
  40116. */
  40117. getClassName(): string;
  40118. }
  40119. }
  40120. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40121. import { Behavior } from "babylonjs/Behaviors/behavior";
  40122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40123. /**
  40124. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40126. */
  40127. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40128. /**
  40129. * Gets the name of the behavior.
  40130. */
  40131. get name(): string;
  40132. private _zoomStopsAnimation;
  40133. private _idleRotationSpeed;
  40134. private _idleRotationWaitTime;
  40135. private _idleRotationSpinupTime;
  40136. /**
  40137. * Sets the flag that indicates if user zooming should stop animation.
  40138. */
  40139. set zoomStopsAnimation(flag: boolean);
  40140. /**
  40141. * Gets the flag that indicates if user zooming should stop animation.
  40142. */
  40143. get zoomStopsAnimation(): boolean;
  40144. /**
  40145. * Sets the default speed at which the camera rotates around the model.
  40146. */
  40147. set idleRotationSpeed(speed: number);
  40148. /**
  40149. * Gets the default speed at which the camera rotates around the model.
  40150. */
  40151. get idleRotationSpeed(): number;
  40152. /**
  40153. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40154. */
  40155. set idleRotationWaitTime(time: number);
  40156. /**
  40157. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40158. */
  40159. get idleRotationWaitTime(): number;
  40160. /**
  40161. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40162. */
  40163. set idleRotationSpinupTime(time: number);
  40164. /**
  40165. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40166. */
  40167. get idleRotationSpinupTime(): number;
  40168. /**
  40169. * Gets a value indicating if the camera is currently rotating because of this behavior
  40170. */
  40171. get rotationInProgress(): boolean;
  40172. private _onPrePointerObservableObserver;
  40173. private _onAfterCheckInputsObserver;
  40174. private _attachedCamera;
  40175. private _isPointerDown;
  40176. private _lastFrameTime;
  40177. private _lastInteractionTime;
  40178. private _cameraRotationSpeed;
  40179. /**
  40180. * Initializes the behavior.
  40181. */
  40182. init(): void;
  40183. /**
  40184. * Attaches the behavior to its arc rotate camera.
  40185. * @param camera Defines the camera to attach the behavior to
  40186. */
  40187. attach(camera: ArcRotateCamera): void;
  40188. /**
  40189. * Detaches the behavior from its current arc rotate camera.
  40190. */
  40191. detach(): void;
  40192. /**
  40193. * Returns true if user is scrolling.
  40194. * @return true if user is scrolling.
  40195. */
  40196. private _userIsZooming;
  40197. private _lastFrameRadius;
  40198. private _shouldAnimationStopForInteraction;
  40199. /**
  40200. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40201. */
  40202. private _applyUserInteraction;
  40203. private _userIsMoving;
  40204. }
  40205. }
  40206. declare module "babylonjs/Behaviors/Cameras/index" {
  40207. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40208. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40209. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40210. }
  40211. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40212. import { Mesh } from "babylonjs/Meshes/mesh";
  40213. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40214. import { Behavior } from "babylonjs/Behaviors/behavior";
  40215. /**
  40216. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40217. */
  40218. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40219. private ui;
  40220. /**
  40221. * The name of the behavior
  40222. */
  40223. name: string;
  40224. /**
  40225. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40226. */
  40227. distanceAwayFromFace: number;
  40228. /**
  40229. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40230. */
  40231. distanceAwayFromBottomOfFace: number;
  40232. private _faceVectors;
  40233. private _target;
  40234. private _scene;
  40235. private _onRenderObserver;
  40236. private _tmpMatrix;
  40237. private _tmpVector;
  40238. /**
  40239. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40240. * @param ui The transform node that should be attched to the mesh
  40241. */
  40242. constructor(ui: TransformNode);
  40243. /**
  40244. * Initializes the behavior
  40245. */
  40246. init(): void;
  40247. private _closestFace;
  40248. private _zeroVector;
  40249. private _lookAtTmpMatrix;
  40250. private _lookAtToRef;
  40251. /**
  40252. * Attaches the AttachToBoxBehavior to the passed in mesh
  40253. * @param target The mesh that the specified node will be attached to
  40254. */
  40255. attach(target: Mesh): void;
  40256. /**
  40257. * Detaches the behavior from the mesh
  40258. */
  40259. detach(): void;
  40260. }
  40261. }
  40262. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40263. import { Behavior } from "babylonjs/Behaviors/behavior";
  40264. import { Mesh } from "babylonjs/Meshes/mesh";
  40265. /**
  40266. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40267. */
  40268. export class FadeInOutBehavior implements Behavior<Mesh> {
  40269. /**
  40270. * Time in milliseconds to delay before fading in (Default: 0)
  40271. */
  40272. delay: number;
  40273. /**
  40274. * Time in milliseconds for the mesh to fade in (Default: 300)
  40275. */
  40276. fadeInTime: number;
  40277. private _millisecondsPerFrame;
  40278. private _hovered;
  40279. private _hoverValue;
  40280. private _ownerNode;
  40281. /**
  40282. * Instatiates the FadeInOutBehavior
  40283. */
  40284. constructor();
  40285. /**
  40286. * The name of the behavior
  40287. */
  40288. get name(): string;
  40289. /**
  40290. * Initializes the behavior
  40291. */
  40292. init(): void;
  40293. /**
  40294. * Attaches the fade behavior on the passed in mesh
  40295. * @param ownerNode The mesh that will be faded in/out once attached
  40296. */
  40297. attach(ownerNode: Mesh): void;
  40298. /**
  40299. * Detaches the behavior from the mesh
  40300. */
  40301. detach(): void;
  40302. /**
  40303. * Triggers the mesh to begin fading in or out
  40304. * @param value if the object should fade in or out (true to fade in)
  40305. */
  40306. fadeIn(value: boolean): void;
  40307. private _update;
  40308. private _setAllVisibility;
  40309. }
  40310. }
  40311. declare module "babylonjs/Misc/pivotTools" {
  40312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40313. /**
  40314. * Class containing a set of static utilities functions for managing Pivots
  40315. * @hidden
  40316. */
  40317. export class PivotTools {
  40318. private static _PivotCached;
  40319. private static _OldPivotPoint;
  40320. private static _PivotTranslation;
  40321. private static _PivotTmpVector;
  40322. /** @hidden */
  40323. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40324. /** @hidden */
  40325. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40326. }
  40327. }
  40328. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40329. import { Scene } from "babylonjs/scene";
  40330. import { Vector4 } from "babylonjs/Maths/math.vector";
  40331. import { Mesh } from "babylonjs/Meshes/mesh";
  40332. import { Nullable } from "babylonjs/types";
  40333. import { Plane } from "babylonjs/Maths/math.plane";
  40334. /**
  40335. * Class containing static functions to help procedurally build meshes
  40336. */
  40337. export class PlaneBuilder {
  40338. /**
  40339. * Creates a plane mesh
  40340. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40341. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40342. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40346. * @param name defines the name of the mesh
  40347. * @param options defines the options used to create the mesh
  40348. * @param scene defines the hosting scene
  40349. * @returns the plane mesh
  40350. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40351. */
  40352. static CreatePlane(name: string, options: {
  40353. size?: number;
  40354. width?: number;
  40355. height?: number;
  40356. sideOrientation?: number;
  40357. frontUVs?: Vector4;
  40358. backUVs?: Vector4;
  40359. updatable?: boolean;
  40360. sourcePlane?: Plane;
  40361. }, scene?: Nullable<Scene>): Mesh;
  40362. }
  40363. }
  40364. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40365. import { Behavior } from "babylonjs/Behaviors/behavior";
  40366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40367. import { Observable } from "babylonjs/Misc/observable";
  40368. import { Vector3 } from "babylonjs/Maths/math.vector";
  40369. import { Ray } from "babylonjs/Culling/ray";
  40370. import "babylonjs/Meshes/Builders/planeBuilder";
  40371. /**
  40372. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40373. */
  40374. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40375. private static _AnyMouseID;
  40376. /**
  40377. * Abstract mesh the behavior is set on
  40378. */
  40379. attachedNode: AbstractMesh;
  40380. private _dragPlane;
  40381. private _scene;
  40382. private _pointerObserver;
  40383. private _beforeRenderObserver;
  40384. private static _planeScene;
  40385. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40386. /**
  40387. * 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)
  40388. */
  40389. maxDragAngle: number;
  40390. /**
  40391. * @hidden
  40392. */
  40393. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40394. /**
  40395. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40396. */
  40397. currentDraggingPointerID: number;
  40398. /**
  40399. * The last position where the pointer hit the drag plane in world space
  40400. */
  40401. lastDragPosition: Vector3;
  40402. /**
  40403. * If the behavior is currently in a dragging state
  40404. */
  40405. dragging: boolean;
  40406. /**
  40407. * 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)
  40408. */
  40409. dragDeltaRatio: number;
  40410. /**
  40411. * If the drag plane orientation should be updated during the dragging (Default: true)
  40412. */
  40413. updateDragPlane: boolean;
  40414. private _debugMode;
  40415. private _moving;
  40416. /**
  40417. * Fires each time the attached mesh is dragged with the pointer
  40418. * * delta between last drag position and current drag position in world space
  40419. * * dragDistance along the drag axis
  40420. * * dragPlaneNormal normal of the current drag plane used during the drag
  40421. * * dragPlanePoint in world space where the drag intersects the drag plane
  40422. */
  40423. onDragObservable: Observable<{
  40424. delta: Vector3;
  40425. dragPlanePoint: Vector3;
  40426. dragPlaneNormal: Vector3;
  40427. dragDistance: number;
  40428. pointerId: number;
  40429. }>;
  40430. /**
  40431. * Fires each time a drag begins (eg. mouse down on mesh)
  40432. */
  40433. onDragStartObservable: Observable<{
  40434. dragPlanePoint: Vector3;
  40435. pointerId: number;
  40436. }>;
  40437. /**
  40438. * Fires each time a drag ends (eg. mouse release after drag)
  40439. */
  40440. onDragEndObservable: Observable<{
  40441. dragPlanePoint: Vector3;
  40442. pointerId: number;
  40443. }>;
  40444. /**
  40445. * If the attached mesh should be moved when dragged
  40446. */
  40447. moveAttached: boolean;
  40448. /**
  40449. * If the drag behavior will react to drag events (Default: true)
  40450. */
  40451. enabled: boolean;
  40452. /**
  40453. * If pointer events should start and release the drag (Default: true)
  40454. */
  40455. startAndReleaseDragOnPointerEvents: boolean;
  40456. /**
  40457. * If camera controls should be detached during the drag
  40458. */
  40459. detachCameraControls: boolean;
  40460. /**
  40461. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40462. */
  40463. useObjectOrientationForDragging: boolean;
  40464. private _options;
  40465. /**
  40466. * Gets the options used by the behavior
  40467. */
  40468. get options(): {
  40469. dragAxis?: Vector3;
  40470. dragPlaneNormal?: Vector3;
  40471. };
  40472. /**
  40473. * Sets the options used by the behavior
  40474. */
  40475. set options(options: {
  40476. dragAxis?: Vector3;
  40477. dragPlaneNormal?: Vector3;
  40478. });
  40479. /**
  40480. * Creates a pointer drag behavior that can be attached to a mesh
  40481. * @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)
  40482. */
  40483. constructor(options?: {
  40484. dragAxis?: Vector3;
  40485. dragPlaneNormal?: Vector3;
  40486. });
  40487. /**
  40488. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40489. */
  40490. validateDrag: (targetPosition: Vector3) => boolean;
  40491. /**
  40492. * The name of the behavior
  40493. */
  40494. get name(): string;
  40495. /**
  40496. * Initializes the behavior
  40497. */
  40498. init(): void;
  40499. private _tmpVector;
  40500. private _alternatePickedPoint;
  40501. private _worldDragAxis;
  40502. private _targetPosition;
  40503. private _attachedElement;
  40504. /**
  40505. * Attaches the drag behavior the passed in mesh
  40506. * @param ownerNode The mesh that will be dragged around once attached
  40507. * @param predicate Predicate to use for pick filtering
  40508. */
  40509. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40510. /**
  40511. * Force relase the drag action by code.
  40512. */
  40513. releaseDrag(): void;
  40514. private _startDragRay;
  40515. private _lastPointerRay;
  40516. /**
  40517. * Simulates the start of a pointer drag event on the behavior
  40518. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40519. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40520. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40521. */
  40522. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40523. private _startDrag;
  40524. private _dragDelta;
  40525. private _moveDrag;
  40526. private _pickWithRayOnDragPlane;
  40527. private _pointA;
  40528. private _pointB;
  40529. private _pointC;
  40530. private _lineA;
  40531. private _lineB;
  40532. private _localAxis;
  40533. private _lookAt;
  40534. private _updateDragPlanePosition;
  40535. /**
  40536. * Detaches the behavior from the mesh
  40537. */
  40538. detach(): void;
  40539. }
  40540. }
  40541. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40542. import { Mesh } from "babylonjs/Meshes/mesh";
  40543. import { Behavior } from "babylonjs/Behaviors/behavior";
  40544. /**
  40545. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40546. */
  40547. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40548. private _dragBehaviorA;
  40549. private _dragBehaviorB;
  40550. private _startDistance;
  40551. private _initialScale;
  40552. private _targetScale;
  40553. private _ownerNode;
  40554. private _sceneRenderObserver;
  40555. /**
  40556. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40557. */
  40558. constructor();
  40559. /**
  40560. * The name of the behavior
  40561. */
  40562. get name(): string;
  40563. /**
  40564. * Initializes the behavior
  40565. */
  40566. init(): void;
  40567. private _getCurrentDistance;
  40568. /**
  40569. * Attaches the scale behavior the passed in mesh
  40570. * @param ownerNode The mesh that will be scaled around once attached
  40571. */
  40572. attach(ownerNode: Mesh): void;
  40573. /**
  40574. * Detaches the behavior from the mesh
  40575. */
  40576. detach(): void;
  40577. }
  40578. }
  40579. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40580. import { Behavior } from "babylonjs/Behaviors/behavior";
  40581. import { Mesh } from "babylonjs/Meshes/mesh";
  40582. import { Observable } from "babylonjs/Misc/observable";
  40583. /**
  40584. * 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
  40585. */
  40586. export class SixDofDragBehavior implements Behavior<Mesh> {
  40587. private static _virtualScene;
  40588. private _ownerNode;
  40589. private _sceneRenderObserver;
  40590. private _scene;
  40591. private _targetPosition;
  40592. private _virtualOriginMesh;
  40593. private _virtualDragMesh;
  40594. private _pointerObserver;
  40595. private _moving;
  40596. private _startingOrientation;
  40597. /**
  40598. * 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)
  40599. */
  40600. private zDragFactor;
  40601. /**
  40602. * If the object should rotate to face the drag origin
  40603. */
  40604. rotateDraggedObject: boolean;
  40605. /**
  40606. * If the behavior is currently in a dragging state
  40607. */
  40608. dragging: boolean;
  40609. /**
  40610. * 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)
  40611. */
  40612. dragDeltaRatio: number;
  40613. /**
  40614. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40615. */
  40616. currentDraggingPointerID: number;
  40617. /**
  40618. * If camera controls should be detached during the drag
  40619. */
  40620. detachCameraControls: boolean;
  40621. /**
  40622. * Fires each time a drag starts
  40623. */
  40624. onDragStartObservable: Observable<{}>;
  40625. /**
  40626. * Fires each time a drag ends (eg. mouse release after drag)
  40627. */
  40628. onDragEndObservable: Observable<{}>;
  40629. /**
  40630. * 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
  40631. */
  40632. constructor();
  40633. /**
  40634. * The name of the behavior
  40635. */
  40636. get name(): string;
  40637. /**
  40638. * Initializes the behavior
  40639. */
  40640. init(): void;
  40641. /**
  40642. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40643. */
  40644. private get _pointerCamera();
  40645. /**
  40646. * Attaches the scale behavior the passed in mesh
  40647. * @param ownerNode The mesh that will be scaled around once attached
  40648. */
  40649. attach(ownerNode: Mesh): void;
  40650. /**
  40651. * Detaches the behavior from the mesh
  40652. */
  40653. detach(): void;
  40654. }
  40655. }
  40656. declare module "babylonjs/Behaviors/Meshes/index" {
  40657. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40658. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40659. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40660. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40661. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40662. }
  40663. declare module "babylonjs/Behaviors/index" {
  40664. export * from "babylonjs/Behaviors/behavior";
  40665. export * from "babylonjs/Behaviors/Cameras/index";
  40666. export * from "babylonjs/Behaviors/Meshes/index";
  40667. }
  40668. declare module "babylonjs/Bones/boneIKController" {
  40669. import { Bone } from "babylonjs/Bones/bone";
  40670. import { Vector3 } from "babylonjs/Maths/math.vector";
  40671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40672. import { Nullable } from "babylonjs/types";
  40673. /**
  40674. * Class used to apply inverse kinematics to bones
  40675. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40676. */
  40677. export class BoneIKController {
  40678. private static _tmpVecs;
  40679. private static _tmpQuat;
  40680. private static _tmpMats;
  40681. /**
  40682. * Gets or sets the target mesh
  40683. */
  40684. targetMesh: AbstractMesh;
  40685. /** Gets or sets the mesh used as pole */
  40686. poleTargetMesh: AbstractMesh;
  40687. /**
  40688. * Gets or sets the bone used as pole
  40689. */
  40690. poleTargetBone: Nullable<Bone>;
  40691. /**
  40692. * Gets or sets the target position
  40693. */
  40694. targetPosition: Vector3;
  40695. /**
  40696. * Gets or sets the pole target position
  40697. */
  40698. poleTargetPosition: Vector3;
  40699. /**
  40700. * Gets or sets the pole target local offset
  40701. */
  40702. poleTargetLocalOffset: Vector3;
  40703. /**
  40704. * Gets or sets the pole angle
  40705. */
  40706. poleAngle: number;
  40707. /**
  40708. * Gets or sets the mesh associated with the controller
  40709. */
  40710. mesh: AbstractMesh;
  40711. /**
  40712. * 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)
  40713. */
  40714. slerpAmount: number;
  40715. private _bone1Quat;
  40716. private _bone1Mat;
  40717. private _bone2Ang;
  40718. private _bone1;
  40719. private _bone2;
  40720. private _bone1Length;
  40721. private _bone2Length;
  40722. private _maxAngle;
  40723. private _maxReach;
  40724. private _rightHandedSystem;
  40725. private _bendAxis;
  40726. private _slerping;
  40727. private _adjustRoll;
  40728. /**
  40729. * Gets or sets maximum allowed angle
  40730. */
  40731. get maxAngle(): number;
  40732. set maxAngle(value: number);
  40733. /**
  40734. * Creates a new BoneIKController
  40735. * @param mesh defines the mesh to control
  40736. * @param bone defines the bone to control
  40737. * @param options defines options to set up the controller
  40738. */
  40739. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40740. targetMesh?: AbstractMesh;
  40741. poleTargetMesh?: AbstractMesh;
  40742. poleTargetBone?: Bone;
  40743. poleTargetLocalOffset?: Vector3;
  40744. poleAngle?: number;
  40745. bendAxis?: Vector3;
  40746. maxAngle?: number;
  40747. slerpAmount?: number;
  40748. });
  40749. private _setMaxAngle;
  40750. /**
  40751. * Force the controller to update the bones
  40752. */
  40753. update(): void;
  40754. }
  40755. }
  40756. declare module "babylonjs/Bones/boneLookController" {
  40757. import { Vector3 } from "babylonjs/Maths/math.vector";
  40758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40759. import { Bone } from "babylonjs/Bones/bone";
  40760. import { Space } from "babylonjs/Maths/math.axis";
  40761. /**
  40762. * Class used to make a bone look toward a point in space
  40763. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40764. */
  40765. export class BoneLookController {
  40766. private static _tmpVecs;
  40767. private static _tmpQuat;
  40768. private static _tmpMats;
  40769. /**
  40770. * The target Vector3 that the bone will look at
  40771. */
  40772. target: Vector3;
  40773. /**
  40774. * The mesh that the bone is attached to
  40775. */
  40776. mesh: AbstractMesh;
  40777. /**
  40778. * The bone that will be looking to the target
  40779. */
  40780. bone: Bone;
  40781. /**
  40782. * The up axis of the coordinate system that is used when the bone is rotated
  40783. */
  40784. upAxis: Vector3;
  40785. /**
  40786. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40787. */
  40788. upAxisSpace: Space;
  40789. /**
  40790. * Used to make an adjustment to the yaw of the bone
  40791. */
  40792. adjustYaw: number;
  40793. /**
  40794. * Used to make an adjustment to the pitch of the bone
  40795. */
  40796. adjustPitch: number;
  40797. /**
  40798. * Used to make an adjustment to the roll of the bone
  40799. */
  40800. adjustRoll: number;
  40801. /**
  40802. * 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)
  40803. */
  40804. slerpAmount: number;
  40805. private _minYaw;
  40806. private _maxYaw;
  40807. private _minPitch;
  40808. private _maxPitch;
  40809. private _minYawSin;
  40810. private _minYawCos;
  40811. private _maxYawSin;
  40812. private _maxYawCos;
  40813. private _midYawConstraint;
  40814. private _minPitchTan;
  40815. private _maxPitchTan;
  40816. private _boneQuat;
  40817. private _slerping;
  40818. private _transformYawPitch;
  40819. private _transformYawPitchInv;
  40820. private _firstFrameSkipped;
  40821. private _yawRange;
  40822. private _fowardAxis;
  40823. /**
  40824. * Gets or sets the minimum yaw angle that the bone can look to
  40825. */
  40826. get minYaw(): number;
  40827. set minYaw(value: number);
  40828. /**
  40829. * Gets or sets the maximum yaw angle that the bone can look to
  40830. */
  40831. get maxYaw(): number;
  40832. set maxYaw(value: number);
  40833. /**
  40834. * Gets or sets the minimum pitch angle that the bone can look to
  40835. */
  40836. get minPitch(): number;
  40837. set minPitch(value: number);
  40838. /**
  40839. * Gets or sets the maximum pitch angle that the bone can look to
  40840. */
  40841. get maxPitch(): number;
  40842. set maxPitch(value: number);
  40843. /**
  40844. * Create a BoneLookController
  40845. * @param mesh the mesh that the bone belongs to
  40846. * @param bone the bone that will be looking to the target
  40847. * @param target the target Vector3 to look at
  40848. * @param options optional settings:
  40849. * * maxYaw: the maximum angle the bone will yaw to
  40850. * * minYaw: the minimum angle the bone will yaw to
  40851. * * maxPitch: the maximum angle the bone will pitch to
  40852. * * minPitch: the minimum angle the bone will yaw to
  40853. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40854. * * upAxis: the up axis of the coordinate system
  40855. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40856. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40857. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40858. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40859. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40860. * * adjustRoll: used to make an adjustment to the roll of the bone
  40861. **/
  40862. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40863. maxYaw?: number;
  40864. minYaw?: number;
  40865. maxPitch?: number;
  40866. minPitch?: number;
  40867. slerpAmount?: number;
  40868. upAxis?: Vector3;
  40869. upAxisSpace?: Space;
  40870. yawAxis?: Vector3;
  40871. pitchAxis?: Vector3;
  40872. adjustYaw?: number;
  40873. adjustPitch?: number;
  40874. adjustRoll?: number;
  40875. });
  40876. /**
  40877. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40878. */
  40879. update(): void;
  40880. private _getAngleDiff;
  40881. private _getAngleBetween;
  40882. private _isAngleBetween;
  40883. }
  40884. }
  40885. declare module "babylonjs/Bones/index" {
  40886. export * from "babylonjs/Bones/bone";
  40887. export * from "babylonjs/Bones/boneIKController";
  40888. export * from "babylonjs/Bones/boneLookController";
  40889. export * from "babylonjs/Bones/skeleton";
  40890. }
  40891. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40892. import { Nullable } from "babylonjs/types";
  40893. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40894. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40895. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40896. /**
  40897. * Manage the gamepad inputs to control an arc rotate camera.
  40898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40899. */
  40900. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40901. /**
  40902. * Defines the camera the input is attached to.
  40903. */
  40904. camera: ArcRotateCamera;
  40905. /**
  40906. * Defines the gamepad the input is gathering event from.
  40907. */
  40908. gamepad: Nullable<Gamepad>;
  40909. /**
  40910. * Defines the gamepad rotation sensiblity.
  40911. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40912. */
  40913. gamepadRotationSensibility: number;
  40914. /**
  40915. * Defines the gamepad move sensiblity.
  40916. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40917. */
  40918. gamepadMoveSensibility: number;
  40919. private _yAxisScale;
  40920. /**
  40921. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40922. */
  40923. get invertYAxis(): boolean;
  40924. set invertYAxis(value: boolean);
  40925. private _onGamepadConnectedObserver;
  40926. private _onGamepadDisconnectedObserver;
  40927. /**
  40928. * Attach the input controls to a specific dom element to get the input from.
  40929. * @param element Defines the element the controls should be listened from
  40930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40931. */
  40932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40933. /**
  40934. * Detach the current controls from the specified dom element.
  40935. * @param element Defines the element to stop listening the inputs from
  40936. */
  40937. detachControl(element: Nullable<HTMLElement>): void;
  40938. /**
  40939. * Update the current camera state depending on the inputs that have been used this frame.
  40940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40941. */
  40942. checkInputs(): void;
  40943. /**
  40944. * Gets the class name of the current intput.
  40945. * @returns the class name
  40946. */
  40947. getClassName(): string;
  40948. /**
  40949. * Get the friendly name associated with the input class.
  40950. * @returns the input friendly name
  40951. */
  40952. getSimpleName(): string;
  40953. }
  40954. }
  40955. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40956. import { Nullable } from "babylonjs/types";
  40957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40958. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40959. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40960. interface ArcRotateCameraInputsManager {
  40961. /**
  40962. * Add orientation input support to the input manager.
  40963. * @returns the current input manager
  40964. */
  40965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40966. }
  40967. }
  40968. /**
  40969. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40971. */
  40972. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40973. /**
  40974. * Defines the camera the input is attached to.
  40975. */
  40976. camera: ArcRotateCamera;
  40977. /**
  40978. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40979. */
  40980. alphaCorrection: number;
  40981. /**
  40982. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40983. */
  40984. gammaCorrection: number;
  40985. private _alpha;
  40986. private _gamma;
  40987. private _dirty;
  40988. private _deviceOrientationHandler;
  40989. /**
  40990. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40991. */
  40992. constructor();
  40993. /**
  40994. * Attach the input controls to a specific dom element to get the input from.
  40995. * @param element Defines the element the controls should be listened from
  40996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40997. */
  40998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40999. /** @hidden */
  41000. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41001. /**
  41002. * Update the current camera state depending on the inputs that have been used this frame.
  41003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41004. */
  41005. checkInputs(): void;
  41006. /**
  41007. * Detach the current controls from the specified dom element.
  41008. * @param element Defines the element to stop listening the inputs from
  41009. */
  41010. detachControl(element: Nullable<HTMLElement>): void;
  41011. /**
  41012. * Gets the class name of the current intput.
  41013. * @returns the class name
  41014. */
  41015. getClassName(): string;
  41016. /**
  41017. * Get the friendly name associated with the input class.
  41018. * @returns the input friendly name
  41019. */
  41020. getSimpleName(): string;
  41021. }
  41022. }
  41023. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41024. import { Nullable } from "babylonjs/types";
  41025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41026. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41027. /**
  41028. * Listen to mouse events to control the camera.
  41029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41030. */
  41031. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41032. /**
  41033. * Defines the camera the input is attached to.
  41034. */
  41035. camera: FlyCamera;
  41036. /**
  41037. * Defines if touch is enabled. (Default is true.)
  41038. */
  41039. touchEnabled: boolean;
  41040. /**
  41041. * Defines the buttons associated with the input to handle camera rotation.
  41042. */
  41043. buttons: number[];
  41044. /**
  41045. * Assign buttons for Yaw control.
  41046. */
  41047. buttonsYaw: number[];
  41048. /**
  41049. * Assign buttons for Pitch control.
  41050. */
  41051. buttonsPitch: number[];
  41052. /**
  41053. * Assign buttons for Roll control.
  41054. */
  41055. buttonsRoll: number[];
  41056. /**
  41057. * Detect if any button is being pressed while mouse is moved.
  41058. * -1 = Mouse locked.
  41059. * 0 = Left button.
  41060. * 1 = Middle Button.
  41061. * 2 = Right Button.
  41062. */
  41063. activeButton: number;
  41064. /**
  41065. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41066. * Higher values reduce its sensitivity.
  41067. */
  41068. angularSensibility: number;
  41069. private _mousemoveCallback;
  41070. private _observer;
  41071. private _rollObserver;
  41072. private previousPosition;
  41073. private noPreventDefault;
  41074. private element;
  41075. /**
  41076. * Listen to mouse events to control the camera.
  41077. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41079. */
  41080. constructor(touchEnabled?: boolean);
  41081. /**
  41082. * Attach the mouse control to the HTML DOM element.
  41083. * @param element Defines the element that listens to the input events.
  41084. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41085. */
  41086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41087. /**
  41088. * Detach the current controls from the specified dom element.
  41089. * @param element Defines the element to stop listening the inputs from
  41090. */
  41091. detachControl(element: Nullable<HTMLElement>): void;
  41092. /**
  41093. * Gets the class name of the current input.
  41094. * @returns the class name.
  41095. */
  41096. getClassName(): string;
  41097. /**
  41098. * Get the friendly name associated with the input class.
  41099. * @returns the input's friendly name.
  41100. */
  41101. getSimpleName(): string;
  41102. private _pointerInput;
  41103. private _onMouseMove;
  41104. /**
  41105. * Rotate camera by mouse offset.
  41106. */
  41107. private rotateCamera;
  41108. }
  41109. }
  41110. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41111. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41112. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41113. /**
  41114. * Default Inputs manager for the FlyCamera.
  41115. * It groups all the default supported inputs for ease of use.
  41116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41117. */
  41118. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41119. /**
  41120. * Instantiates a new FlyCameraInputsManager.
  41121. * @param camera Defines the camera the inputs belong to.
  41122. */
  41123. constructor(camera: FlyCamera);
  41124. /**
  41125. * Add keyboard input support to the input manager.
  41126. * @returns the new FlyCameraKeyboardMoveInput().
  41127. */
  41128. addKeyboard(): FlyCameraInputsManager;
  41129. /**
  41130. * Add mouse input support to the input manager.
  41131. * @param touchEnabled Enable touch screen support.
  41132. * @returns the new FlyCameraMouseInput().
  41133. */
  41134. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41135. }
  41136. }
  41137. declare module "babylonjs/Cameras/flyCamera" {
  41138. import { Scene } from "babylonjs/scene";
  41139. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41141. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41142. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41143. /**
  41144. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41145. * such as in a 3D Space Shooter or a Flight Simulator.
  41146. */
  41147. export class FlyCamera extends TargetCamera {
  41148. /**
  41149. * Define the collision ellipsoid of the camera.
  41150. * This is helpful for simulating a camera body, like a player's body.
  41151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41152. */
  41153. ellipsoid: Vector3;
  41154. /**
  41155. * Define an offset for the position of the ellipsoid around the camera.
  41156. * This can be helpful if the camera is attached away from the player's body center,
  41157. * such as at its head.
  41158. */
  41159. ellipsoidOffset: Vector3;
  41160. /**
  41161. * Enable or disable collisions of the camera with the rest of the scene objects.
  41162. */
  41163. checkCollisions: boolean;
  41164. /**
  41165. * Enable or disable gravity on the camera.
  41166. */
  41167. applyGravity: boolean;
  41168. /**
  41169. * Define the current direction the camera is moving to.
  41170. */
  41171. cameraDirection: Vector3;
  41172. /**
  41173. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41174. * This overrides and empties cameraRotation.
  41175. */
  41176. rotationQuaternion: Quaternion;
  41177. /**
  41178. * Track Roll to maintain the wanted Rolling when looking around.
  41179. */
  41180. _trackRoll: number;
  41181. /**
  41182. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41183. */
  41184. rollCorrect: number;
  41185. /**
  41186. * Mimic a banked turn, Rolling the camera when Yawing.
  41187. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41188. */
  41189. bankedTurn: boolean;
  41190. /**
  41191. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41192. */
  41193. bankedTurnLimit: number;
  41194. /**
  41195. * Value of 0 disables the banked Roll.
  41196. * Value of 1 is equal to the Yaw angle in radians.
  41197. */
  41198. bankedTurnMultiplier: number;
  41199. /**
  41200. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41201. */
  41202. inputs: FlyCameraInputsManager;
  41203. /**
  41204. * Gets the input sensibility for mouse input.
  41205. * Higher values reduce sensitivity.
  41206. */
  41207. get angularSensibility(): number;
  41208. /**
  41209. * Sets the input sensibility for a mouse input.
  41210. * Higher values reduce sensitivity.
  41211. */
  41212. set angularSensibility(value: number);
  41213. /**
  41214. * Get the keys for camera movement forward.
  41215. */
  41216. get keysForward(): number[];
  41217. /**
  41218. * Set the keys for camera movement forward.
  41219. */
  41220. set keysForward(value: number[]);
  41221. /**
  41222. * Get the keys for camera movement backward.
  41223. */
  41224. get keysBackward(): number[];
  41225. set keysBackward(value: number[]);
  41226. /**
  41227. * Get the keys for camera movement up.
  41228. */
  41229. get keysUp(): number[];
  41230. /**
  41231. * Set the keys for camera movement up.
  41232. */
  41233. set keysUp(value: number[]);
  41234. /**
  41235. * Get the keys for camera movement down.
  41236. */
  41237. get keysDown(): number[];
  41238. /**
  41239. * Set the keys for camera movement down.
  41240. */
  41241. set keysDown(value: number[]);
  41242. /**
  41243. * Get the keys for camera movement left.
  41244. */
  41245. get keysLeft(): number[];
  41246. /**
  41247. * Set the keys for camera movement left.
  41248. */
  41249. set keysLeft(value: number[]);
  41250. /**
  41251. * Set the keys for camera movement right.
  41252. */
  41253. get keysRight(): number[];
  41254. /**
  41255. * Set the keys for camera movement right.
  41256. */
  41257. set keysRight(value: number[]);
  41258. /**
  41259. * Event raised when the camera collides with a mesh in the scene.
  41260. */
  41261. onCollide: (collidedMesh: AbstractMesh) => void;
  41262. private _collider;
  41263. private _needMoveForGravity;
  41264. private _oldPosition;
  41265. private _diffPosition;
  41266. private _newPosition;
  41267. /** @hidden */
  41268. _localDirection: Vector3;
  41269. /** @hidden */
  41270. _transformedDirection: Vector3;
  41271. /**
  41272. * Instantiates a FlyCamera.
  41273. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41274. * such as in a 3D Space Shooter or a Flight Simulator.
  41275. * @param name Define the name of the camera in the scene.
  41276. * @param position Define the starting position of the camera in the scene.
  41277. * @param scene Define the scene the camera belongs to.
  41278. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41279. */
  41280. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41281. /**
  41282. * Attach a control to the HTML DOM element.
  41283. * @param element Defines the element that listens to the input events.
  41284. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41285. */
  41286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41287. /**
  41288. * Detach a control from the HTML DOM element.
  41289. * The camera will stop reacting to that input.
  41290. * @param element Defines the element that listens to the input events.
  41291. */
  41292. detachControl(element: HTMLElement): void;
  41293. private _collisionMask;
  41294. /**
  41295. * Get the mask that the camera ignores in collision events.
  41296. */
  41297. get collisionMask(): number;
  41298. /**
  41299. * Set the mask that the camera ignores in collision events.
  41300. */
  41301. set collisionMask(mask: number);
  41302. /** @hidden */
  41303. _collideWithWorld(displacement: Vector3): void;
  41304. /** @hidden */
  41305. private _onCollisionPositionChange;
  41306. /** @hidden */
  41307. _checkInputs(): void;
  41308. /** @hidden */
  41309. _decideIfNeedsToMove(): boolean;
  41310. /** @hidden */
  41311. _updatePosition(): void;
  41312. /**
  41313. * Restore the Roll to its target value at the rate specified.
  41314. * @param rate - Higher means slower restoring.
  41315. * @hidden
  41316. */
  41317. restoreRoll(rate: number): void;
  41318. /**
  41319. * Destroy the camera and release the current resources held by it.
  41320. */
  41321. dispose(): void;
  41322. /**
  41323. * Get the current object class name.
  41324. * @returns the class name.
  41325. */
  41326. getClassName(): string;
  41327. }
  41328. }
  41329. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41330. import { Nullable } from "babylonjs/types";
  41331. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41332. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41333. /**
  41334. * Listen to keyboard events to control the camera.
  41335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41336. */
  41337. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41338. /**
  41339. * Defines the camera the input is attached to.
  41340. */
  41341. camera: FlyCamera;
  41342. /**
  41343. * The list of keyboard keys used to control the forward move of the camera.
  41344. */
  41345. keysForward: number[];
  41346. /**
  41347. * The list of keyboard keys used to control the backward move of the camera.
  41348. */
  41349. keysBackward: number[];
  41350. /**
  41351. * The list of keyboard keys used to control the forward move of the camera.
  41352. */
  41353. keysUp: number[];
  41354. /**
  41355. * The list of keyboard keys used to control the backward move of the camera.
  41356. */
  41357. keysDown: number[];
  41358. /**
  41359. * The list of keyboard keys used to control the right strafe move of the camera.
  41360. */
  41361. keysRight: number[];
  41362. /**
  41363. * The list of keyboard keys used to control the left strafe move of the camera.
  41364. */
  41365. keysLeft: number[];
  41366. private _keys;
  41367. private _onCanvasBlurObserver;
  41368. private _onKeyboardObserver;
  41369. private _engine;
  41370. private _scene;
  41371. /**
  41372. * Attach the input controls to a specific dom element to get the input from.
  41373. * @param element Defines the element the controls should be listened from
  41374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41375. */
  41376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41377. /**
  41378. * Detach the current controls from the specified dom element.
  41379. * @param element Defines the element to stop listening the inputs from
  41380. */
  41381. detachControl(element: Nullable<HTMLElement>): void;
  41382. /**
  41383. * Gets the class name of the current intput.
  41384. * @returns the class name
  41385. */
  41386. getClassName(): string;
  41387. /** @hidden */
  41388. _onLostFocus(e: FocusEvent): void;
  41389. /**
  41390. * Get the friendly name associated with the input class.
  41391. * @returns the input friendly name
  41392. */
  41393. getSimpleName(): string;
  41394. /**
  41395. * Update the current camera state depending on the inputs that have been used this frame.
  41396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41397. */
  41398. checkInputs(): void;
  41399. }
  41400. }
  41401. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41402. import { Nullable } from "babylonjs/types";
  41403. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41404. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41405. /**
  41406. * Manage the mouse wheel inputs to control a follow camera.
  41407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41408. */
  41409. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41410. /**
  41411. * Defines the camera the input is attached to.
  41412. */
  41413. camera: FollowCamera;
  41414. /**
  41415. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41416. */
  41417. axisControlRadius: boolean;
  41418. /**
  41419. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41420. */
  41421. axisControlHeight: boolean;
  41422. /**
  41423. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41424. */
  41425. axisControlRotation: boolean;
  41426. /**
  41427. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41428. * relation to mouseWheel events.
  41429. */
  41430. wheelPrecision: number;
  41431. /**
  41432. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41433. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41434. */
  41435. wheelDeltaPercentage: number;
  41436. private _wheel;
  41437. private _observer;
  41438. /**
  41439. * Attach the input controls to a specific dom element to get the input from.
  41440. * @param element Defines the element the controls should be listened from
  41441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41442. */
  41443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41444. /**
  41445. * Detach the current controls from the specified dom element.
  41446. * @param element Defines the element to stop listening the inputs from
  41447. */
  41448. detachControl(element: Nullable<HTMLElement>): void;
  41449. /**
  41450. * Gets the class name of the current intput.
  41451. * @returns the class name
  41452. */
  41453. getClassName(): string;
  41454. /**
  41455. * Get the friendly name associated with the input class.
  41456. * @returns the input friendly name
  41457. */
  41458. getSimpleName(): string;
  41459. }
  41460. }
  41461. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41462. import { Nullable } from "babylonjs/types";
  41463. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41464. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41465. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41466. /**
  41467. * Manage the pointers inputs to control an follow camera.
  41468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41469. */
  41470. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41471. /**
  41472. * Defines the camera the input is attached to.
  41473. */
  41474. camera: FollowCamera;
  41475. /**
  41476. * Gets the class name of the current input.
  41477. * @returns the class name
  41478. */
  41479. getClassName(): string;
  41480. /**
  41481. * Defines the pointer angular sensibility along the X axis or how fast is
  41482. * the camera rotating.
  41483. * A negative number will reverse the axis direction.
  41484. */
  41485. angularSensibilityX: number;
  41486. /**
  41487. * Defines the pointer angular sensibility along the Y axis or how fast is
  41488. * the camera rotating.
  41489. * A negative number will reverse the axis direction.
  41490. */
  41491. angularSensibilityY: number;
  41492. /**
  41493. * Defines the pointer pinch precision or how fast is the camera zooming.
  41494. * A negative number will reverse the axis direction.
  41495. */
  41496. pinchPrecision: number;
  41497. /**
  41498. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41499. * from 0.
  41500. * It defines the percentage of current camera.radius to use as delta when
  41501. * pinch zoom is used.
  41502. */
  41503. pinchDeltaPercentage: number;
  41504. /**
  41505. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41506. */
  41507. axisXControlRadius: boolean;
  41508. /**
  41509. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41510. */
  41511. axisXControlHeight: boolean;
  41512. /**
  41513. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41514. */
  41515. axisXControlRotation: boolean;
  41516. /**
  41517. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41518. */
  41519. axisYControlRadius: boolean;
  41520. /**
  41521. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41522. */
  41523. axisYControlHeight: boolean;
  41524. /**
  41525. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41526. */
  41527. axisYControlRotation: boolean;
  41528. /**
  41529. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41530. */
  41531. axisPinchControlRadius: boolean;
  41532. /**
  41533. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41534. */
  41535. axisPinchControlHeight: boolean;
  41536. /**
  41537. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41538. */
  41539. axisPinchControlRotation: boolean;
  41540. /**
  41541. * Log error messages if basic misconfiguration has occurred.
  41542. */
  41543. warningEnable: boolean;
  41544. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41545. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41546. private _warningCounter;
  41547. private _warning;
  41548. }
  41549. }
  41550. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41551. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41552. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41553. /**
  41554. * Default Inputs manager for the FollowCamera.
  41555. * It groups all the default supported inputs for ease of use.
  41556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41557. */
  41558. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41559. /**
  41560. * Instantiates a new FollowCameraInputsManager.
  41561. * @param camera Defines the camera the inputs belong to
  41562. */
  41563. constructor(camera: FollowCamera);
  41564. /**
  41565. * Add keyboard input support to the input manager.
  41566. * @returns the current input manager
  41567. */
  41568. addKeyboard(): FollowCameraInputsManager;
  41569. /**
  41570. * Add mouse wheel input support to the input manager.
  41571. * @returns the current input manager
  41572. */
  41573. addMouseWheel(): FollowCameraInputsManager;
  41574. /**
  41575. * Add pointers input support to the input manager.
  41576. * @returns the current input manager
  41577. */
  41578. addPointers(): FollowCameraInputsManager;
  41579. /**
  41580. * Add orientation input support to the input manager.
  41581. * @returns the current input manager
  41582. */
  41583. addVRDeviceOrientation(): FollowCameraInputsManager;
  41584. }
  41585. }
  41586. declare module "babylonjs/Cameras/followCamera" {
  41587. import { Nullable } from "babylonjs/types";
  41588. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41589. import { Scene } from "babylonjs/scene";
  41590. import { Vector3 } from "babylonjs/Maths/math.vector";
  41591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41592. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41593. /**
  41594. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41595. * an arc rotate version arcFollowCamera are available.
  41596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41597. */
  41598. export class FollowCamera extends TargetCamera {
  41599. /**
  41600. * Distance the follow camera should follow an object at
  41601. */
  41602. radius: number;
  41603. /**
  41604. * Minimum allowed distance of the camera to the axis of rotation
  41605. * (The camera can not get closer).
  41606. * This can help limiting how the Camera is able to move in the scene.
  41607. */
  41608. lowerRadiusLimit: Nullable<number>;
  41609. /**
  41610. * Maximum allowed distance of the camera to the axis of rotation
  41611. * (The camera can not get further).
  41612. * This can help limiting how the Camera is able to move in the scene.
  41613. */
  41614. upperRadiusLimit: Nullable<number>;
  41615. /**
  41616. * Define a rotation offset between the camera and the object it follows
  41617. */
  41618. rotationOffset: number;
  41619. /**
  41620. * Minimum allowed angle to camera position relative to target object.
  41621. * This can help limiting how the Camera is able to move in the scene.
  41622. */
  41623. lowerRotationOffsetLimit: Nullable<number>;
  41624. /**
  41625. * Maximum allowed angle to camera position relative to target object.
  41626. * This can help limiting how the Camera is able to move in the scene.
  41627. */
  41628. upperRotationOffsetLimit: Nullable<number>;
  41629. /**
  41630. * Define a height offset between the camera and the object it follows.
  41631. * It can help following an object from the top (like a car chaing a plane)
  41632. */
  41633. heightOffset: number;
  41634. /**
  41635. * Minimum allowed height of camera position relative to target object.
  41636. * This can help limiting how the Camera is able to move in the scene.
  41637. */
  41638. lowerHeightOffsetLimit: Nullable<number>;
  41639. /**
  41640. * Maximum allowed height of camera position relative to target object.
  41641. * This can help limiting how the Camera is able to move in the scene.
  41642. */
  41643. upperHeightOffsetLimit: Nullable<number>;
  41644. /**
  41645. * Define how fast the camera can accelerate to follow it s target.
  41646. */
  41647. cameraAcceleration: number;
  41648. /**
  41649. * Define the speed limit of the camera following an object.
  41650. */
  41651. maxCameraSpeed: number;
  41652. /**
  41653. * Define the target of the camera.
  41654. */
  41655. lockedTarget: Nullable<AbstractMesh>;
  41656. /**
  41657. * Defines the input associated with the camera.
  41658. */
  41659. inputs: FollowCameraInputsManager;
  41660. /**
  41661. * Instantiates the follow camera.
  41662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41663. * @param name Define the name of the camera in the scene
  41664. * @param position Define the position of the camera
  41665. * @param scene Define the scene the camera belong to
  41666. * @param lockedTarget Define the target of the camera
  41667. */
  41668. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41669. private _follow;
  41670. /**
  41671. * Attached controls to the current camera.
  41672. * @param element Defines the element the controls should be listened from
  41673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41674. */
  41675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41676. /**
  41677. * Detach the current controls from the camera.
  41678. * The camera will stop reacting to inputs.
  41679. * @param element Defines the element to stop listening the inputs from
  41680. */
  41681. detachControl(element: HTMLElement): void;
  41682. /** @hidden */
  41683. _checkInputs(): void;
  41684. private _checkLimits;
  41685. /**
  41686. * Gets the camera class name.
  41687. * @returns the class name
  41688. */
  41689. getClassName(): string;
  41690. }
  41691. /**
  41692. * Arc Rotate version of the follow camera.
  41693. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41694. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41695. */
  41696. export class ArcFollowCamera extends TargetCamera {
  41697. /** The longitudinal angle of the camera */
  41698. alpha: number;
  41699. /** The latitudinal angle of the camera */
  41700. beta: number;
  41701. /** The radius of the camera from its target */
  41702. radius: number;
  41703. /** Define the camera target (the messh it should follow) */
  41704. target: Nullable<AbstractMesh>;
  41705. private _cartesianCoordinates;
  41706. /**
  41707. * Instantiates a new ArcFollowCamera
  41708. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41709. * @param name Define the name of the camera
  41710. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41711. * @param beta Define the rotation angle of the camera around the elevation axis
  41712. * @param radius Define the radius of the camera from its target point
  41713. * @param target Define the target of the camera
  41714. * @param scene Define the scene the camera belongs to
  41715. */
  41716. constructor(name: string,
  41717. /** The longitudinal angle of the camera */
  41718. alpha: number,
  41719. /** The latitudinal angle of the camera */
  41720. beta: number,
  41721. /** The radius of the camera from its target */
  41722. radius: number,
  41723. /** Define the camera target (the messh it should follow) */
  41724. target: Nullable<AbstractMesh>, scene: Scene);
  41725. private _follow;
  41726. /** @hidden */
  41727. _checkInputs(): void;
  41728. /**
  41729. * Returns the class name of the object.
  41730. * It is mostly used internally for serialization purposes.
  41731. */
  41732. getClassName(): string;
  41733. }
  41734. }
  41735. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41737. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41738. import { Nullable } from "babylonjs/types";
  41739. /**
  41740. * Manage the keyboard inputs to control the movement of a follow camera.
  41741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41742. */
  41743. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41744. /**
  41745. * Defines the camera the input is attached to.
  41746. */
  41747. camera: FollowCamera;
  41748. /**
  41749. * Defines the list of key codes associated with the up action (increase heightOffset)
  41750. */
  41751. keysHeightOffsetIncr: number[];
  41752. /**
  41753. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41754. */
  41755. keysHeightOffsetDecr: number[];
  41756. /**
  41757. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41758. */
  41759. keysHeightOffsetModifierAlt: boolean;
  41760. /**
  41761. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41762. */
  41763. keysHeightOffsetModifierCtrl: boolean;
  41764. /**
  41765. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41766. */
  41767. keysHeightOffsetModifierShift: boolean;
  41768. /**
  41769. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41770. */
  41771. keysRotationOffsetIncr: number[];
  41772. /**
  41773. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41774. */
  41775. keysRotationOffsetDecr: number[];
  41776. /**
  41777. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41778. */
  41779. keysRotationOffsetModifierAlt: boolean;
  41780. /**
  41781. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41782. */
  41783. keysRotationOffsetModifierCtrl: boolean;
  41784. /**
  41785. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41786. */
  41787. keysRotationOffsetModifierShift: boolean;
  41788. /**
  41789. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41790. */
  41791. keysRadiusIncr: number[];
  41792. /**
  41793. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41794. */
  41795. keysRadiusDecr: number[];
  41796. /**
  41797. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41798. */
  41799. keysRadiusModifierAlt: boolean;
  41800. /**
  41801. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41802. */
  41803. keysRadiusModifierCtrl: boolean;
  41804. /**
  41805. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41806. */
  41807. keysRadiusModifierShift: boolean;
  41808. /**
  41809. * Defines the rate of change of heightOffset.
  41810. */
  41811. heightSensibility: number;
  41812. /**
  41813. * Defines the rate of change of rotationOffset.
  41814. */
  41815. rotationSensibility: number;
  41816. /**
  41817. * Defines the rate of change of radius.
  41818. */
  41819. radiusSensibility: number;
  41820. private _keys;
  41821. private _ctrlPressed;
  41822. private _altPressed;
  41823. private _shiftPressed;
  41824. private _onCanvasBlurObserver;
  41825. private _onKeyboardObserver;
  41826. private _engine;
  41827. private _scene;
  41828. /**
  41829. * Attach the input controls to a specific dom element to get the input from.
  41830. * @param element Defines the element the controls should be listened from
  41831. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41832. */
  41833. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41834. /**
  41835. * Detach the current controls from the specified dom element.
  41836. * @param element Defines the element to stop listening the inputs from
  41837. */
  41838. detachControl(element: Nullable<HTMLElement>): void;
  41839. /**
  41840. * Update the current camera state depending on the inputs that have been used this frame.
  41841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41842. */
  41843. checkInputs(): void;
  41844. /**
  41845. * Gets the class name of the current input.
  41846. * @returns the class name
  41847. */
  41848. getClassName(): string;
  41849. /**
  41850. * Get the friendly name associated with the input class.
  41851. * @returns the input friendly name
  41852. */
  41853. getSimpleName(): string;
  41854. /**
  41855. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41856. * allow modification of the heightOffset value.
  41857. */
  41858. private _modifierHeightOffset;
  41859. /**
  41860. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41861. * allow modification of the rotationOffset value.
  41862. */
  41863. private _modifierRotationOffset;
  41864. /**
  41865. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41866. * allow modification of the radius value.
  41867. */
  41868. private _modifierRadius;
  41869. }
  41870. }
  41871. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41872. import { Nullable } from "babylonjs/types";
  41873. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41874. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41875. import { Observable } from "babylonjs/Misc/observable";
  41876. module "babylonjs/Cameras/freeCameraInputsManager" {
  41877. interface FreeCameraInputsManager {
  41878. /**
  41879. * @hidden
  41880. */
  41881. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41882. /**
  41883. * Add orientation input support to the input manager.
  41884. * @returns the current input manager
  41885. */
  41886. addDeviceOrientation(): FreeCameraInputsManager;
  41887. }
  41888. }
  41889. /**
  41890. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41891. * Screen rotation is taken into account.
  41892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41893. */
  41894. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41895. private _camera;
  41896. private _screenOrientationAngle;
  41897. private _constantTranform;
  41898. private _screenQuaternion;
  41899. private _alpha;
  41900. private _beta;
  41901. private _gamma;
  41902. /**
  41903. * Can be used to detect if a device orientation sensor is available on a device
  41904. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41905. * @returns a promise that will resolve on orientation change
  41906. */
  41907. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41908. /**
  41909. * @hidden
  41910. */
  41911. _onDeviceOrientationChangedObservable: Observable<void>;
  41912. /**
  41913. * Instantiates a new input
  41914. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41915. */
  41916. constructor();
  41917. /**
  41918. * Define the camera controlled by the input.
  41919. */
  41920. get camera(): FreeCamera;
  41921. set camera(camera: FreeCamera);
  41922. /**
  41923. * Attach the input controls to a specific dom element to get the input from.
  41924. * @param element Defines the element the controls should be listened from
  41925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41926. */
  41927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41928. private _orientationChanged;
  41929. private _deviceOrientation;
  41930. /**
  41931. * Detach the current controls from the specified dom element.
  41932. * @param element Defines the element to stop listening the inputs from
  41933. */
  41934. detachControl(element: Nullable<HTMLElement>): void;
  41935. /**
  41936. * Update the current camera state depending on the inputs that have been used this frame.
  41937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41938. */
  41939. checkInputs(): void;
  41940. /**
  41941. * Gets the class name of the current intput.
  41942. * @returns the class name
  41943. */
  41944. getClassName(): string;
  41945. /**
  41946. * Get the friendly name associated with the input class.
  41947. * @returns the input friendly name
  41948. */
  41949. getSimpleName(): string;
  41950. }
  41951. }
  41952. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41953. import { Nullable } from "babylonjs/types";
  41954. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41955. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41956. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41957. /**
  41958. * Manage the gamepad inputs to control a free camera.
  41959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41960. */
  41961. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41962. /**
  41963. * Define the camera the input is attached to.
  41964. */
  41965. camera: FreeCamera;
  41966. /**
  41967. * Define the Gamepad controlling the input
  41968. */
  41969. gamepad: Nullable<Gamepad>;
  41970. /**
  41971. * Defines the gamepad rotation sensiblity.
  41972. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41973. */
  41974. gamepadAngularSensibility: number;
  41975. /**
  41976. * Defines the gamepad move sensiblity.
  41977. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41978. */
  41979. gamepadMoveSensibility: number;
  41980. private _yAxisScale;
  41981. /**
  41982. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41983. */
  41984. get invertYAxis(): boolean;
  41985. set invertYAxis(value: boolean);
  41986. private _onGamepadConnectedObserver;
  41987. private _onGamepadDisconnectedObserver;
  41988. private _cameraTransform;
  41989. private _deltaTransform;
  41990. private _vector3;
  41991. private _vector2;
  41992. /**
  41993. * Attach the input controls to a specific dom element to get the input from.
  41994. * @param element Defines the element the controls should be listened from
  41995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41996. */
  41997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41998. /**
  41999. * Detach the current controls from the specified dom element.
  42000. * @param element Defines the element to stop listening the inputs from
  42001. */
  42002. detachControl(element: Nullable<HTMLElement>): void;
  42003. /**
  42004. * Update the current camera state depending on the inputs that have been used this frame.
  42005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42006. */
  42007. checkInputs(): void;
  42008. /**
  42009. * Gets the class name of the current intput.
  42010. * @returns the class name
  42011. */
  42012. getClassName(): string;
  42013. /**
  42014. * Get the friendly name associated with the input class.
  42015. * @returns the input friendly name
  42016. */
  42017. getSimpleName(): string;
  42018. }
  42019. }
  42020. declare module "babylonjs/Misc/virtualJoystick" {
  42021. import { Nullable } from "babylonjs/types";
  42022. import { Vector3 } from "babylonjs/Maths/math.vector";
  42023. /**
  42024. * Defines the potential axis of a Joystick
  42025. */
  42026. export enum JoystickAxis {
  42027. /** X axis */
  42028. X = 0,
  42029. /** Y axis */
  42030. Y = 1,
  42031. /** Z axis */
  42032. Z = 2
  42033. }
  42034. /**
  42035. * Class used to define virtual joystick (used in touch mode)
  42036. */
  42037. export class VirtualJoystick {
  42038. /**
  42039. * Gets or sets a boolean indicating that left and right values must be inverted
  42040. */
  42041. reverseLeftRight: boolean;
  42042. /**
  42043. * Gets or sets a boolean indicating that up and down values must be inverted
  42044. */
  42045. reverseUpDown: boolean;
  42046. /**
  42047. * Gets the offset value for the position (ie. the change of the position value)
  42048. */
  42049. deltaPosition: Vector3;
  42050. /**
  42051. * Gets a boolean indicating if the virtual joystick was pressed
  42052. */
  42053. pressed: boolean;
  42054. /**
  42055. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42056. */
  42057. static Canvas: Nullable<HTMLCanvasElement>;
  42058. private static _globalJoystickIndex;
  42059. private static vjCanvasContext;
  42060. private static vjCanvasWidth;
  42061. private static vjCanvasHeight;
  42062. private static halfWidth;
  42063. private _action;
  42064. private _axisTargetedByLeftAndRight;
  42065. private _axisTargetedByUpAndDown;
  42066. private _joystickSensibility;
  42067. private _inversedSensibility;
  42068. private _joystickPointerID;
  42069. private _joystickColor;
  42070. private _joystickPointerPos;
  42071. private _joystickPreviousPointerPos;
  42072. private _joystickPointerStartPos;
  42073. private _deltaJoystickVector;
  42074. private _leftJoystick;
  42075. private _touches;
  42076. private _onPointerDownHandlerRef;
  42077. private _onPointerMoveHandlerRef;
  42078. private _onPointerUpHandlerRef;
  42079. private _onResize;
  42080. /**
  42081. * Creates a new virtual joystick
  42082. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42083. */
  42084. constructor(leftJoystick?: boolean);
  42085. /**
  42086. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42087. * @param newJoystickSensibility defines the new sensibility
  42088. */
  42089. setJoystickSensibility(newJoystickSensibility: number): void;
  42090. private _onPointerDown;
  42091. private _onPointerMove;
  42092. private _onPointerUp;
  42093. /**
  42094. * Change the color of the virtual joystick
  42095. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42096. */
  42097. setJoystickColor(newColor: string): void;
  42098. /**
  42099. * Defines a callback to call when the joystick is touched
  42100. * @param action defines the callback
  42101. */
  42102. setActionOnTouch(action: () => any): void;
  42103. /**
  42104. * Defines which axis you'd like to control for left & right
  42105. * @param axis defines the axis to use
  42106. */
  42107. setAxisForLeftRight(axis: JoystickAxis): void;
  42108. /**
  42109. * Defines which axis you'd like to control for up & down
  42110. * @param axis defines the axis to use
  42111. */
  42112. setAxisForUpDown(axis: JoystickAxis): void;
  42113. private _drawVirtualJoystick;
  42114. /**
  42115. * Release internal HTML canvas
  42116. */
  42117. releaseCanvas(): void;
  42118. }
  42119. }
  42120. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42121. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42122. import { Nullable } from "babylonjs/types";
  42123. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42124. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42125. module "babylonjs/Cameras/freeCameraInputsManager" {
  42126. interface FreeCameraInputsManager {
  42127. /**
  42128. * Add virtual joystick input support to the input manager.
  42129. * @returns the current input manager
  42130. */
  42131. addVirtualJoystick(): FreeCameraInputsManager;
  42132. }
  42133. }
  42134. /**
  42135. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42137. */
  42138. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42139. /**
  42140. * Defines the camera the input is attached to.
  42141. */
  42142. camera: FreeCamera;
  42143. private _leftjoystick;
  42144. private _rightjoystick;
  42145. /**
  42146. * Gets the left stick of the virtual joystick.
  42147. * @returns The virtual Joystick
  42148. */
  42149. getLeftJoystick(): VirtualJoystick;
  42150. /**
  42151. * Gets the right stick of the virtual joystick.
  42152. * @returns The virtual Joystick
  42153. */
  42154. getRightJoystick(): VirtualJoystick;
  42155. /**
  42156. * Update the current camera state depending on the inputs that have been used this frame.
  42157. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42158. */
  42159. checkInputs(): void;
  42160. /**
  42161. * Attach the input controls to a specific dom element to get the input from.
  42162. * @param element Defines the element the controls should be listened from
  42163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42164. */
  42165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42166. /**
  42167. * Detach the current controls from the specified dom element.
  42168. * @param element Defines the element to stop listening the inputs from
  42169. */
  42170. detachControl(element: Nullable<HTMLElement>): void;
  42171. /**
  42172. * Gets the class name of the current intput.
  42173. * @returns the class name
  42174. */
  42175. getClassName(): string;
  42176. /**
  42177. * Get the friendly name associated with the input class.
  42178. * @returns the input friendly name
  42179. */
  42180. getSimpleName(): string;
  42181. }
  42182. }
  42183. declare module "babylonjs/Cameras/Inputs/index" {
  42184. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42185. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42186. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42187. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42188. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42189. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42190. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42191. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42192. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42193. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42194. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42195. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42196. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42197. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42198. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42199. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42200. }
  42201. declare module "babylonjs/Cameras/touchCamera" {
  42202. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42203. import { Scene } from "babylonjs/scene";
  42204. import { Vector3 } from "babylonjs/Maths/math.vector";
  42205. /**
  42206. * This represents a FPS type of camera controlled by touch.
  42207. * This is like a universal camera minus the Gamepad controls.
  42208. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42209. */
  42210. export class TouchCamera extends FreeCamera {
  42211. /**
  42212. * Defines the touch sensibility for rotation.
  42213. * The higher the faster.
  42214. */
  42215. get touchAngularSensibility(): number;
  42216. set touchAngularSensibility(value: number);
  42217. /**
  42218. * Defines the touch sensibility for move.
  42219. * The higher the faster.
  42220. */
  42221. get touchMoveSensibility(): number;
  42222. set touchMoveSensibility(value: number);
  42223. /**
  42224. * Instantiates a new touch camera.
  42225. * This represents a FPS type of camera controlled by touch.
  42226. * This is like a universal camera minus the Gamepad controls.
  42227. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42228. * @param name Define the name of the camera in the scene
  42229. * @param position Define the start position of the camera in the scene
  42230. * @param scene Define the scene the camera belongs to
  42231. */
  42232. constructor(name: string, position: Vector3, scene: Scene);
  42233. /**
  42234. * Gets the current object class name.
  42235. * @return the class name
  42236. */
  42237. getClassName(): string;
  42238. /** @hidden */
  42239. _setupInputs(): void;
  42240. }
  42241. }
  42242. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42244. import { Scene } from "babylonjs/scene";
  42245. import { Vector3 } from "babylonjs/Maths/math.vector";
  42246. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42247. import { Axis } from "babylonjs/Maths/math.axis";
  42248. /**
  42249. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42250. * being tilted forward or back and left or right.
  42251. */
  42252. export class DeviceOrientationCamera extends FreeCamera {
  42253. private _initialQuaternion;
  42254. private _quaternionCache;
  42255. private _tmpDragQuaternion;
  42256. private _disablePointerInputWhenUsingDeviceOrientation;
  42257. /**
  42258. * Creates a new device orientation camera
  42259. * @param name The name of the camera
  42260. * @param position The start position camera
  42261. * @param scene The scene the camera belongs to
  42262. */
  42263. constructor(name: string, position: Vector3, scene: Scene);
  42264. /**
  42265. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42266. */
  42267. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42268. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42269. private _dragFactor;
  42270. /**
  42271. * Enabled turning on the y axis when the orientation sensor is active
  42272. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42273. */
  42274. enableHorizontalDragging(dragFactor?: number): void;
  42275. /**
  42276. * Gets the current instance class name ("DeviceOrientationCamera").
  42277. * This helps avoiding instanceof at run time.
  42278. * @returns the class name
  42279. */
  42280. getClassName(): string;
  42281. /**
  42282. * @hidden
  42283. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42284. */
  42285. _checkInputs(): void;
  42286. /**
  42287. * Reset the camera to its default orientation on the specified axis only.
  42288. * @param axis The axis to reset
  42289. */
  42290. resetToCurrentRotation(axis?: Axis): void;
  42291. }
  42292. }
  42293. declare module "babylonjs/Gamepads/xboxGamepad" {
  42294. import { Observable } from "babylonjs/Misc/observable";
  42295. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42296. /**
  42297. * Defines supported buttons for XBox360 compatible gamepads
  42298. */
  42299. export enum Xbox360Button {
  42300. /** A */
  42301. A = 0,
  42302. /** B */
  42303. B = 1,
  42304. /** X */
  42305. X = 2,
  42306. /** Y */
  42307. Y = 3,
  42308. /** Start */
  42309. Start = 4,
  42310. /** Back */
  42311. Back = 5,
  42312. /** Left button */
  42313. LB = 6,
  42314. /** Right button */
  42315. RB = 7,
  42316. /** Left stick */
  42317. LeftStick = 8,
  42318. /** Right stick */
  42319. RightStick = 9
  42320. }
  42321. /** Defines values for XBox360 DPad */
  42322. export enum Xbox360Dpad {
  42323. /** Up */
  42324. Up = 0,
  42325. /** Down */
  42326. Down = 1,
  42327. /** Left */
  42328. Left = 2,
  42329. /** Right */
  42330. Right = 3
  42331. }
  42332. /**
  42333. * Defines a XBox360 gamepad
  42334. */
  42335. export class Xbox360Pad extends Gamepad {
  42336. private _leftTrigger;
  42337. private _rightTrigger;
  42338. private _onlefttriggerchanged;
  42339. private _onrighttriggerchanged;
  42340. private _onbuttondown;
  42341. private _onbuttonup;
  42342. private _ondpaddown;
  42343. private _ondpadup;
  42344. /** Observable raised when a button is pressed */
  42345. onButtonDownObservable: Observable<Xbox360Button>;
  42346. /** Observable raised when a button is released */
  42347. onButtonUpObservable: Observable<Xbox360Button>;
  42348. /** Observable raised when a pad is pressed */
  42349. onPadDownObservable: Observable<Xbox360Dpad>;
  42350. /** Observable raised when a pad is released */
  42351. onPadUpObservable: Observable<Xbox360Dpad>;
  42352. private _buttonA;
  42353. private _buttonB;
  42354. private _buttonX;
  42355. private _buttonY;
  42356. private _buttonBack;
  42357. private _buttonStart;
  42358. private _buttonLB;
  42359. private _buttonRB;
  42360. private _buttonLeftStick;
  42361. private _buttonRightStick;
  42362. private _dPadUp;
  42363. private _dPadDown;
  42364. private _dPadLeft;
  42365. private _dPadRight;
  42366. private _isXboxOnePad;
  42367. /**
  42368. * Creates a new XBox360 gamepad object
  42369. * @param id defines the id of this gamepad
  42370. * @param index defines its index
  42371. * @param gamepad defines the internal HTML gamepad object
  42372. * @param xboxOne defines if it is a XBox One gamepad
  42373. */
  42374. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42375. /**
  42376. * Defines the callback to call when left trigger is pressed
  42377. * @param callback defines the callback to use
  42378. */
  42379. onlefttriggerchanged(callback: (value: number) => void): void;
  42380. /**
  42381. * Defines the callback to call when right trigger is pressed
  42382. * @param callback defines the callback to use
  42383. */
  42384. onrighttriggerchanged(callback: (value: number) => void): void;
  42385. /**
  42386. * Gets the left trigger value
  42387. */
  42388. get leftTrigger(): number;
  42389. /**
  42390. * Sets the left trigger value
  42391. */
  42392. set leftTrigger(newValue: number);
  42393. /**
  42394. * Gets the right trigger value
  42395. */
  42396. get rightTrigger(): number;
  42397. /**
  42398. * Sets the right trigger value
  42399. */
  42400. set rightTrigger(newValue: number);
  42401. /**
  42402. * Defines the callback to call when a button is pressed
  42403. * @param callback defines the callback to use
  42404. */
  42405. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42406. /**
  42407. * Defines the callback to call when a button is released
  42408. * @param callback defines the callback to use
  42409. */
  42410. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42411. /**
  42412. * Defines the callback to call when a pad is pressed
  42413. * @param callback defines the callback to use
  42414. */
  42415. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42416. /**
  42417. * Defines the callback to call when a pad is released
  42418. * @param callback defines the callback to use
  42419. */
  42420. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42421. private _setButtonValue;
  42422. private _setDPadValue;
  42423. /**
  42424. * Gets the value of the `A` button
  42425. */
  42426. get buttonA(): number;
  42427. /**
  42428. * Sets the value of the `A` button
  42429. */
  42430. set buttonA(value: number);
  42431. /**
  42432. * Gets the value of the `B` button
  42433. */
  42434. get buttonB(): number;
  42435. /**
  42436. * Sets the value of the `B` button
  42437. */
  42438. set buttonB(value: number);
  42439. /**
  42440. * Gets the value of the `X` button
  42441. */
  42442. get buttonX(): number;
  42443. /**
  42444. * Sets the value of the `X` button
  42445. */
  42446. set buttonX(value: number);
  42447. /**
  42448. * Gets the value of the `Y` button
  42449. */
  42450. get buttonY(): number;
  42451. /**
  42452. * Sets the value of the `Y` button
  42453. */
  42454. set buttonY(value: number);
  42455. /**
  42456. * Gets the value of the `Start` button
  42457. */
  42458. get buttonStart(): number;
  42459. /**
  42460. * Sets the value of the `Start` button
  42461. */
  42462. set buttonStart(value: number);
  42463. /**
  42464. * Gets the value of the `Back` button
  42465. */
  42466. get buttonBack(): number;
  42467. /**
  42468. * Sets the value of the `Back` button
  42469. */
  42470. set buttonBack(value: number);
  42471. /**
  42472. * Gets the value of the `Left` button
  42473. */
  42474. get buttonLB(): number;
  42475. /**
  42476. * Sets the value of the `Left` button
  42477. */
  42478. set buttonLB(value: number);
  42479. /**
  42480. * Gets the value of the `Right` button
  42481. */
  42482. get buttonRB(): number;
  42483. /**
  42484. * Sets the value of the `Right` button
  42485. */
  42486. set buttonRB(value: number);
  42487. /**
  42488. * Gets the value of the Left joystick
  42489. */
  42490. get buttonLeftStick(): number;
  42491. /**
  42492. * Sets the value of the Left joystick
  42493. */
  42494. set buttonLeftStick(value: number);
  42495. /**
  42496. * Gets the value of the Right joystick
  42497. */
  42498. get buttonRightStick(): number;
  42499. /**
  42500. * Sets the value of the Right joystick
  42501. */
  42502. set buttonRightStick(value: number);
  42503. /**
  42504. * Gets the value of D-pad up
  42505. */
  42506. get dPadUp(): number;
  42507. /**
  42508. * Sets the value of D-pad up
  42509. */
  42510. set dPadUp(value: number);
  42511. /**
  42512. * Gets the value of D-pad down
  42513. */
  42514. get dPadDown(): number;
  42515. /**
  42516. * Sets the value of D-pad down
  42517. */
  42518. set dPadDown(value: number);
  42519. /**
  42520. * Gets the value of D-pad left
  42521. */
  42522. get dPadLeft(): number;
  42523. /**
  42524. * Sets the value of D-pad left
  42525. */
  42526. set dPadLeft(value: number);
  42527. /**
  42528. * Gets the value of D-pad right
  42529. */
  42530. get dPadRight(): number;
  42531. /**
  42532. * Sets the value of D-pad right
  42533. */
  42534. set dPadRight(value: number);
  42535. /**
  42536. * Force the gamepad to synchronize with device values
  42537. */
  42538. update(): void;
  42539. /**
  42540. * Disposes the gamepad
  42541. */
  42542. dispose(): void;
  42543. }
  42544. }
  42545. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42546. import { Observable } from "babylonjs/Misc/observable";
  42547. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42548. /**
  42549. * Defines supported buttons for DualShock compatible gamepads
  42550. */
  42551. export enum DualShockButton {
  42552. /** Cross */
  42553. Cross = 0,
  42554. /** Circle */
  42555. Circle = 1,
  42556. /** Square */
  42557. Square = 2,
  42558. /** Triangle */
  42559. Triangle = 3,
  42560. /** Options */
  42561. Options = 4,
  42562. /** Share */
  42563. Share = 5,
  42564. /** L1 */
  42565. L1 = 6,
  42566. /** R1 */
  42567. R1 = 7,
  42568. /** Left stick */
  42569. LeftStick = 8,
  42570. /** Right stick */
  42571. RightStick = 9
  42572. }
  42573. /** Defines values for DualShock DPad */
  42574. export enum DualShockDpad {
  42575. /** Up */
  42576. Up = 0,
  42577. /** Down */
  42578. Down = 1,
  42579. /** Left */
  42580. Left = 2,
  42581. /** Right */
  42582. Right = 3
  42583. }
  42584. /**
  42585. * Defines a DualShock gamepad
  42586. */
  42587. export class DualShockPad extends Gamepad {
  42588. private _leftTrigger;
  42589. private _rightTrigger;
  42590. private _onlefttriggerchanged;
  42591. private _onrighttriggerchanged;
  42592. private _onbuttondown;
  42593. private _onbuttonup;
  42594. private _ondpaddown;
  42595. private _ondpadup;
  42596. /** Observable raised when a button is pressed */
  42597. onButtonDownObservable: Observable<DualShockButton>;
  42598. /** Observable raised when a button is released */
  42599. onButtonUpObservable: Observable<DualShockButton>;
  42600. /** Observable raised when a pad is pressed */
  42601. onPadDownObservable: Observable<DualShockDpad>;
  42602. /** Observable raised when a pad is released */
  42603. onPadUpObservable: Observable<DualShockDpad>;
  42604. private _buttonCross;
  42605. private _buttonCircle;
  42606. private _buttonSquare;
  42607. private _buttonTriangle;
  42608. private _buttonShare;
  42609. private _buttonOptions;
  42610. private _buttonL1;
  42611. private _buttonR1;
  42612. private _buttonLeftStick;
  42613. private _buttonRightStick;
  42614. private _dPadUp;
  42615. private _dPadDown;
  42616. private _dPadLeft;
  42617. private _dPadRight;
  42618. /**
  42619. * Creates a new DualShock gamepad object
  42620. * @param id defines the id of this gamepad
  42621. * @param index defines its index
  42622. * @param gamepad defines the internal HTML gamepad object
  42623. */
  42624. constructor(id: string, index: number, gamepad: any);
  42625. /**
  42626. * Defines the callback to call when left trigger is pressed
  42627. * @param callback defines the callback to use
  42628. */
  42629. onlefttriggerchanged(callback: (value: number) => void): void;
  42630. /**
  42631. * Defines the callback to call when right trigger is pressed
  42632. * @param callback defines the callback to use
  42633. */
  42634. onrighttriggerchanged(callback: (value: number) => void): void;
  42635. /**
  42636. * Gets the left trigger value
  42637. */
  42638. get leftTrigger(): number;
  42639. /**
  42640. * Sets the left trigger value
  42641. */
  42642. set leftTrigger(newValue: number);
  42643. /**
  42644. * Gets the right trigger value
  42645. */
  42646. get rightTrigger(): number;
  42647. /**
  42648. * Sets the right trigger value
  42649. */
  42650. set rightTrigger(newValue: number);
  42651. /**
  42652. * Defines the callback to call when a button is pressed
  42653. * @param callback defines the callback to use
  42654. */
  42655. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42656. /**
  42657. * Defines the callback to call when a button is released
  42658. * @param callback defines the callback to use
  42659. */
  42660. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42661. /**
  42662. * Defines the callback to call when a pad is pressed
  42663. * @param callback defines the callback to use
  42664. */
  42665. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42666. /**
  42667. * Defines the callback to call when a pad is released
  42668. * @param callback defines the callback to use
  42669. */
  42670. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42671. private _setButtonValue;
  42672. private _setDPadValue;
  42673. /**
  42674. * Gets the value of the `Cross` button
  42675. */
  42676. get buttonCross(): number;
  42677. /**
  42678. * Sets the value of the `Cross` button
  42679. */
  42680. set buttonCross(value: number);
  42681. /**
  42682. * Gets the value of the `Circle` button
  42683. */
  42684. get buttonCircle(): number;
  42685. /**
  42686. * Sets the value of the `Circle` button
  42687. */
  42688. set buttonCircle(value: number);
  42689. /**
  42690. * Gets the value of the `Square` button
  42691. */
  42692. get buttonSquare(): number;
  42693. /**
  42694. * Sets the value of the `Square` button
  42695. */
  42696. set buttonSquare(value: number);
  42697. /**
  42698. * Gets the value of the `Triangle` button
  42699. */
  42700. get buttonTriangle(): number;
  42701. /**
  42702. * Sets the value of the `Triangle` button
  42703. */
  42704. set buttonTriangle(value: number);
  42705. /**
  42706. * Gets the value of the `Options` button
  42707. */
  42708. get buttonOptions(): number;
  42709. /**
  42710. * Sets the value of the `Options` button
  42711. */
  42712. set buttonOptions(value: number);
  42713. /**
  42714. * Gets the value of the `Share` button
  42715. */
  42716. get buttonShare(): number;
  42717. /**
  42718. * Sets the value of the `Share` button
  42719. */
  42720. set buttonShare(value: number);
  42721. /**
  42722. * Gets the value of the `L1` button
  42723. */
  42724. get buttonL1(): number;
  42725. /**
  42726. * Sets the value of the `L1` button
  42727. */
  42728. set buttonL1(value: number);
  42729. /**
  42730. * Gets the value of the `R1` button
  42731. */
  42732. get buttonR1(): number;
  42733. /**
  42734. * Sets the value of the `R1` button
  42735. */
  42736. set buttonR1(value: number);
  42737. /**
  42738. * Gets the value of the Left joystick
  42739. */
  42740. get buttonLeftStick(): number;
  42741. /**
  42742. * Sets the value of the Left joystick
  42743. */
  42744. set buttonLeftStick(value: number);
  42745. /**
  42746. * Gets the value of the Right joystick
  42747. */
  42748. get buttonRightStick(): number;
  42749. /**
  42750. * Sets the value of the Right joystick
  42751. */
  42752. set buttonRightStick(value: number);
  42753. /**
  42754. * Gets the value of D-pad up
  42755. */
  42756. get dPadUp(): number;
  42757. /**
  42758. * Sets the value of D-pad up
  42759. */
  42760. set dPadUp(value: number);
  42761. /**
  42762. * Gets the value of D-pad down
  42763. */
  42764. get dPadDown(): number;
  42765. /**
  42766. * Sets the value of D-pad down
  42767. */
  42768. set dPadDown(value: number);
  42769. /**
  42770. * Gets the value of D-pad left
  42771. */
  42772. get dPadLeft(): number;
  42773. /**
  42774. * Sets the value of D-pad left
  42775. */
  42776. set dPadLeft(value: number);
  42777. /**
  42778. * Gets the value of D-pad right
  42779. */
  42780. get dPadRight(): number;
  42781. /**
  42782. * Sets the value of D-pad right
  42783. */
  42784. set dPadRight(value: number);
  42785. /**
  42786. * Force the gamepad to synchronize with device values
  42787. */
  42788. update(): void;
  42789. /**
  42790. * Disposes the gamepad
  42791. */
  42792. dispose(): void;
  42793. }
  42794. }
  42795. declare module "babylonjs/Gamepads/gamepadManager" {
  42796. import { Observable } from "babylonjs/Misc/observable";
  42797. import { Nullable } from "babylonjs/types";
  42798. import { Scene } from "babylonjs/scene";
  42799. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42800. /**
  42801. * Manager for handling gamepads
  42802. */
  42803. export class GamepadManager {
  42804. private _scene?;
  42805. private _babylonGamepads;
  42806. private _oneGamepadConnected;
  42807. /** @hidden */
  42808. _isMonitoring: boolean;
  42809. private _gamepadEventSupported;
  42810. private _gamepadSupport?;
  42811. /**
  42812. * observable to be triggered when the gamepad controller has been connected
  42813. */
  42814. onGamepadConnectedObservable: Observable<Gamepad>;
  42815. /**
  42816. * observable to be triggered when the gamepad controller has been disconnected
  42817. */
  42818. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42819. private _onGamepadConnectedEvent;
  42820. private _onGamepadDisconnectedEvent;
  42821. /**
  42822. * Initializes the gamepad manager
  42823. * @param _scene BabylonJS scene
  42824. */
  42825. constructor(_scene?: Scene | undefined);
  42826. /**
  42827. * The gamepads in the game pad manager
  42828. */
  42829. get gamepads(): Gamepad[];
  42830. /**
  42831. * Get the gamepad controllers based on type
  42832. * @param type The type of gamepad controller
  42833. * @returns Nullable gamepad
  42834. */
  42835. getGamepadByType(type?: number): Nullable<Gamepad>;
  42836. /**
  42837. * Disposes the gamepad manager
  42838. */
  42839. dispose(): void;
  42840. private _addNewGamepad;
  42841. private _startMonitoringGamepads;
  42842. private _stopMonitoringGamepads;
  42843. /** @hidden */
  42844. _checkGamepadsStatus(): void;
  42845. private _updateGamepadObjects;
  42846. }
  42847. }
  42848. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42849. import { Nullable } from "babylonjs/types";
  42850. import { Scene } from "babylonjs/scene";
  42851. import { ISceneComponent } from "babylonjs/sceneComponent";
  42852. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42853. module "babylonjs/scene" {
  42854. interface Scene {
  42855. /** @hidden */
  42856. _gamepadManager: Nullable<GamepadManager>;
  42857. /**
  42858. * Gets the gamepad manager associated with the scene
  42859. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42860. */
  42861. gamepadManager: GamepadManager;
  42862. }
  42863. }
  42864. module "babylonjs/Cameras/freeCameraInputsManager" {
  42865. /**
  42866. * Interface representing a free camera inputs manager
  42867. */
  42868. interface FreeCameraInputsManager {
  42869. /**
  42870. * Adds gamepad input support to the FreeCameraInputsManager.
  42871. * @returns the FreeCameraInputsManager
  42872. */
  42873. addGamepad(): FreeCameraInputsManager;
  42874. }
  42875. }
  42876. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42877. /**
  42878. * Interface representing an arc rotate camera inputs manager
  42879. */
  42880. interface ArcRotateCameraInputsManager {
  42881. /**
  42882. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42883. * @returns the camera inputs manager
  42884. */
  42885. addGamepad(): ArcRotateCameraInputsManager;
  42886. }
  42887. }
  42888. /**
  42889. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42890. */
  42891. export class GamepadSystemSceneComponent implements ISceneComponent {
  42892. /**
  42893. * The component name helpfull to identify the component in the list of scene components.
  42894. */
  42895. readonly name: string;
  42896. /**
  42897. * The scene the component belongs to.
  42898. */
  42899. scene: Scene;
  42900. /**
  42901. * Creates a new instance of the component for the given scene
  42902. * @param scene Defines the scene to register the component in
  42903. */
  42904. constructor(scene: Scene);
  42905. /**
  42906. * Registers the component in a given scene
  42907. */
  42908. register(): void;
  42909. /**
  42910. * Rebuilds the elements related to this component in case of
  42911. * context lost for instance.
  42912. */
  42913. rebuild(): void;
  42914. /**
  42915. * Disposes the component and the associated ressources
  42916. */
  42917. dispose(): void;
  42918. private _beforeCameraUpdate;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/universalCamera" {
  42922. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42923. import { Scene } from "babylonjs/scene";
  42924. import { Vector3 } from "babylonjs/Maths/math.vector";
  42925. import "babylonjs/Gamepads/gamepadSceneComponent";
  42926. /**
  42927. * 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,
  42928. * which still works and will still be found in many Playgrounds.
  42929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42930. */
  42931. export class UniversalCamera extends TouchCamera {
  42932. /**
  42933. * Defines the gamepad rotation sensiblity.
  42934. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42935. */
  42936. get gamepadAngularSensibility(): number;
  42937. set gamepadAngularSensibility(value: number);
  42938. /**
  42939. * Defines the gamepad move sensiblity.
  42940. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42941. */
  42942. get gamepadMoveSensibility(): number;
  42943. set gamepadMoveSensibility(value: number);
  42944. /**
  42945. * 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,
  42946. * which still works and will still be found in many Playgrounds.
  42947. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42948. * @param name Define the name of the camera in the scene
  42949. * @param position Define the start position of the camera in the scene
  42950. * @param scene Define the scene the camera belongs to
  42951. */
  42952. constructor(name: string, position: Vector3, scene: Scene);
  42953. /**
  42954. * Gets the current object class name.
  42955. * @return the class name
  42956. */
  42957. getClassName(): string;
  42958. }
  42959. }
  42960. declare module "babylonjs/Cameras/gamepadCamera" {
  42961. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42962. import { Scene } from "babylonjs/scene";
  42963. import { Vector3 } from "babylonjs/Maths/math.vector";
  42964. /**
  42965. * This represents a FPS type of camera. This is only here for back compat purpose.
  42966. * Please use the UniversalCamera instead as both are identical.
  42967. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42968. */
  42969. export class GamepadCamera extends UniversalCamera {
  42970. /**
  42971. * Instantiates a new Gamepad Camera
  42972. * This represents a FPS type of camera. This is only here for back compat purpose.
  42973. * Please use the UniversalCamera instead as both are identical.
  42974. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42975. * @param name Define the name of the camera in the scene
  42976. * @param position Define the start position of the camera in the scene
  42977. * @param scene Define the scene the camera belongs to
  42978. */
  42979. constructor(name: string, position: Vector3, scene: Scene);
  42980. /**
  42981. * Gets the current object class name.
  42982. * @return the class name
  42983. */
  42984. getClassName(): string;
  42985. }
  42986. }
  42987. declare module "babylonjs/Shaders/pass.fragment" {
  42988. /** @hidden */
  42989. export var passPixelShader: {
  42990. name: string;
  42991. shader: string;
  42992. };
  42993. }
  42994. declare module "babylonjs/Shaders/passCube.fragment" {
  42995. /** @hidden */
  42996. export var passCubePixelShader: {
  42997. name: string;
  42998. shader: string;
  42999. };
  43000. }
  43001. declare module "babylonjs/PostProcesses/passPostProcess" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { Camera } from "babylonjs/Cameras/camera";
  43004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43005. import { Engine } from "babylonjs/Engines/engine";
  43006. import "babylonjs/Shaders/pass.fragment";
  43007. import "babylonjs/Shaders/passCube.fragment";
  43008. /**
  43009. * PassPostProcess which produces an output the same as it's input
  43010. */
  43011. export class PassPostProcess extends PostProcess {
  43012. /**
  43013. * Creates the PassPostProcess
  43014. * @param name The name of the effect.
  43015. * @param options The required width/height ratio to downsize to before computing the render pass.
  43016. * @param camera The camera to apply the render pass to.
  43017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43018. * @param engine The engine which the post process will be applied. (default: current engine)
  43019. * @param reusable If the post process can be reused on the same frame. (default: false)
  43020. * @param textureType The type of texture to be used when performing the post processing.
  43021. * @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)
  43022. */
  43023. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43024. }
  43025. /**
  43026. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43027. */
  43028. export class PassCubePostProcess extends PostProcess {
  43029. private _face;
  43030. /**
  43031. * Gets or sets the cube face to display.
  43032. * * 0 is +X
  43033. * * 1 is -X
  43034. * * 2 is +Y
  43035. * * 3 is -Y
  43036. * * 4 is +Z
  43037. * * 5 is -Z
  43038. */
  43039. get face(): number;
  43040. set face(value: number);
  43041. /**
  43042. * Creates the PassCubePostProcess
  43043. * @param name The name of the effect.
  43044. * @param options The required width/height ratio to downsize to before computing the render pass.
  43045. * @param camera The camera to apply the render pass to.
  43046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43047. * @param engine The engine which the post process will be applied. (default: current engine)
  43048. * @param reusable If the post process can be reused on the same frame. (default: false)
  43049. * @param textureType The type of texture to be used when performing the post processing.
  43050. * @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)
  43051. */
  43052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43053. }
  43054. }
  43055. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43056. /** @hidden */
  43057. export var anaglyphPixelShader: {
  43058. name: string;
  43059. shader: string;
  43060. };
  43061. }
  43062. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43063. import { Engine } from "babylonjs/Engines/engine";
  43064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43065. import { Camera } from "babylonjs/Cameras/camera";
  43066. import "babylonjs/Shaders/anaglyph.fragment";
  43067. /**
  43068. * Postprocess used to generate anaglyphic rendering
  43069. */
  43070. export class AnaglyphPostProcess extends PostProcess {
  43071. private _passedProcess;
  43072. /**
  43073. * Creates a new AnaglyphPostProcess
  43074. * @param name defines postprocess name
  43075. * @param options defines creation options or target ratio scale
  43076. * @param rigCameras defines cameras using this postprocess
  43077. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43078. * @param engine defines hosting engine
  43079. * @param reusable defines if the postprocess will be reused multiple times per frame
  43080. */
  43081. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43082. }
  43083. }
  43084. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43085. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43086. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43087. import { Scene } from "babylonjs/scene";
  43088. import { Vector3 } from "babylonjs/Maths/math.vector";
  43089. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43090. /**
  43091. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43092. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43093. */
  43094. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43095. /**
  43096. * Creates a new AnaglyphArcRotateCamera
  43097. * @param name defines camera name
  43098. * @param alpha defines alpha angle (in radians)
  43099. * @param beta defines beta angle (in radians)
  43100. * @param radius defines radius
  43101. * @param target defines camera target
  43102. * @param interaxialDistance defines distance between each color axis
  43103. * @param scene defines the hosting scene
  43104. */
  43105. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43106. /**
  43107. * Gets camera class name
  43108. * @returns AnaglyphArcRotateCamera
  43109. */
  43110. getClassName(): string;
  43111. }
  43112. }
  43113. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43114. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43115. import { Scene } from "babylonjs/scene";
  43116. import { Vector3 } from "babylonjs/Maths/math.vector";
  43117. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43118. /**
  43119. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43120. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43121. */
  43122. export class AnaglyphFreeCamera extends FreeCamera {
  43123. /**
  43124. * Creates a new AnaglyphFreeCamera
  43125. * @param name defines camera name
  43126. * @param position defines initial position
  43127. * @param interaxialDistance defines distance between each color axis
  43128. * @param scene defines the hosting scene
  43129. */
  43130. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43131. /**
  43132. * Gets camera class name
  43133. * @returns AnaglyphFreeCamera
  43134. */
  43135. getClassName(): string;
  43136. }
  43137. }
  43138. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43139. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43140. import { Scene } from "babylonjs/scene";
  43141. import { Vector3 } from "babylonjs/Maths/math.vector";
  43142. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43143. /**
  43144. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43145. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43146. */
  43147. export class AnaglyphGamepadCamera extends GamepadCamera {
  43148. /**
  43149. * Creates a new AnaglyphGamepadCamera
  43150. * @param name defines camera name
  43151. * @param position defines initial position
  43152. * @param interaxialDistance defines distance between each color axis
  43153. * @param scene defines the hosting scene
  43154. */
  43155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43156. /**
  43157. * Gets camera class name
  43158. * @returns AnaglyphGamepadCamera
  43159. */
  43160. getClassName(): string;
  43161. }
  43162. }
  43163. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43164. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43165. import { Scene } from "babylonjs/scene";
  43166. import { Vector3 } from "babylonjs/Maths/math.vector";
  43167. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43168. /**
  43169. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43171. */
  43172. export class AnaglyphUniversalCamera extends UniversalCamera {
  43173. /**
  43174. * Creates a new AnaglyphUniversalCamera
  43175. * @param name defines camera name
  43176. * @param position defines initial position
  43177. * @param interaxialDistance defines distance between each color axis
  43178. * @param scene defines the hosting scene
  43179. */
  43180. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43181. /**
  43182. * Gets camera class name
  43183. * @returns AnaglyphUniversalCamera
  43184. */
  43185. getClassName(): string;
  43186. }
  43187. }
  43188. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43189. /** @hidden */
  43190. export var stereoscopicInterlacePixelShader: {
  43191. name: string;
  43192. shader: string;
  43193. };
  43194. }
  43195. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43196. import { Camera } from "babylonjs/Cameras/camera";
  43197. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43198. import { Engine } from "babylonjs/Engines/engine";
  43199. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43200. /**
  43201. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43202. */
  43203. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43204. private _stepSize;
  43205. private _passedProcess;
  43206. /**
  43207. * Initializes a StereoscopicInterlacePostProcessI
  43208. * @param name The name of the effect.
  43209. * @param rigCameras The rig cameras to be appled to the post process
  43210. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43211. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43213. * @param engine The engine which the post process will be applied. (default: current engine)
  43214. * @param reusable If the post process can be reused on the same frame. (default: false)
  43215. */
  43216. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43217. }
  43218. /**
  43219. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43220. */
  43221. export class StereoscopicInterlacePostProcess extends PostProcess {
  43222. private _stepSize;
  43223. private _passedProcess;
  43224. /**
  43225. * Initializes a StereoscopicInterlacePostProcess
  43226. * @param name The name of the effect.
  43227. * @param rigCameras The rig cameras to be appled to the post process
  43228. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43230. * @param engine The engine which the post process will be applied. (default: current engine)
  43231. * @param reusable If the post process can be reused on the same frame. (default: false)
  43232. */
  43233. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43234. }
  43235. }
  43236. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43237. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43238. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43239. import { Scene } from "babylonjs/scene";
  43240. import { Vector3 } from "babylonjs/Maths/math.vector";
  43241. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43242. /**
  43243. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43244. * @see http://doc.babylonjs.com/features/cameras
  43245. */
  43246. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43247. /**
  43248. * Creates a new StereoscopicArcRotateCamera
  43249. * @param name defines camera name
  43250. * @param alpha defines alpha angle (in radians)
  43251. * @param beta defines beta angle (in radians)
  43252. * @param radius defines radius
  43253. * @param target defines camera target
  43254. * @param interaxialDistance defines distance between each color axis
  43255. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43256. * @param scene defines the hosting scene
  43257. */
  43258. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43259. /**
  43260. * Gets camera class name
  43261. * @returns StereoscopicArcRotateCamera
  43262. */
  43263. getClassName(): string;
  43264. }
  43265. }
  43266. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43267. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43268. import { Scene } from "babylonjs/scene";
  43269. import { Vector3 } from "babylonjs/Maths/math.vector";
  43270. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43271. /**
  43272. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43273. * @see http://doc.babylonjs.com/features/cameras
  43274. */
  43275. export class StereoscopicFreeCamera extends FreeCamera {
  43276. /**
  43277. * Creates a new StereoscopicFreeCamera
  43278. * @param name defines camera name
  43279. * @param position defines initial position
  43280. * @param interaxialDistance defines distance between each color axis
  43281. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43282. * @param scene defines the hosting scene
  43283. */
  43284. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43285. /**
  43286. * Gets camera class name
  43287. * @returns StereoscopicFreeCamera
  43288. */
  43289. getClassName(): string;
  43290. }
  43291. }
  43292. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43293. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43294. import { Scene } from "babylonjs/scene";
  43295. import { Vector3 } from "babylonjs/Maths/math.vector";
  43296. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43297. /**
  43298. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43299. * @see http://doc.babylonjs.com/features/cameras
  43300. */
  43301. export class StereoscopicGamepadCamera extends GamepadCamera {
  43302. /**
  43303. * Creates a new StereoscopicGamepadCamera
  43304. * @param name defines camera name
  43305. * @param position defines initial position
  43306. * @param interaxialDistance defines distance between each color axis
  43307. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43308. * @param scene defines the hosting scene
  43309. */
  43310. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43311. /**
  43312. * Gets camera class name
  43313. * @returns StereoscopicGamepadCamera
  43314. */
  43315. getClassName(): string;
  43316. }
  43317. }
  43318. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43319. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43320. import { Scene } from "babylonjs/scene";
  43321. import { Vector3 } from "babylonjs/Maths/math.vector";
  43322. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43323. /**
  43324. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43325. * @see http://doc.babylonjs.com/features/cameras
  43326. */
  43327. export class StereoscopicUniversalCamera extends UniversalCamera {
  43328. /**
  43329. * Creates a new StereoscopicUniversalCamera
  43330. * @param name defines camera name
  43331. * @param position defines initial position
  43332. * @param interaxialDistance defines distance between each color axis
  43333. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43334. * @param scene defines the hosting scene
  43335. */
  43336. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43337. /**
  43338. * Gets camera class name
  43339. * @returns StereoscopicUniversalCamera
  43340. */
  43341. getClassName(): string;
  43342. }
  43343. }
  43344. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43345. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43346. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43347. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43348. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43349. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43350. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43351. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43352. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43353. }
  43354. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43355. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43356. import { Scene } from "babylonjs/scene";
  43357. import { Vector3 } from "babylonjs/Maths/math.vector";
  43358. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43359. /**
  43360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43364. */
  43365. export class VirtualJoysticksCamera extends FreeCamera {
  43366. /**
  43367. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43371. * @param name Define the name of the camera in the scene
  43372. * @param position Define the start position of the camera in the scene
  43373. * @param scene Define the scene the camera belongs to
  43374. */
  43375. constructor(name: string, position: Vector3, scene: Scene);
  43376. /**
  43377. * Gets the current object class name.
  43378. * @return the class name
  43379. */
  43380. getClassName(): string;
  43381. }
  43382. }
  43383. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43384. import { Matrix } from "babylonjs/Maths/math.vector";
  43385. /**
  43386. * This represents all the required metrics to create a VR camera.
  43387. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43388. */
  43389. export class VRCameraMetrics {
  43390. /**
  43391. * Define the horizontal resolution off the screen.
  43392. */
  43393. hResolution: number;
  43394. /**
  43395. * Define the vertical resolution off the screen.
  43396. */
  43397. vResolution: number;
  43398. /**
  43399. * Define the horizontal screen size.
  43400. */
  43401. hScreenSize: number;
  43402. /**
  43403. * Define the vertical screen size.
  43404. */
  43405. vScreenSize: number;
  43406. /**
  43407. * Define the vertical screen center position.
  43408. */
  43409. vScreenCenter: number;
  43410. /**
  43411. * Define the distance of the eyes to the screen.
  43412. */
  43413. eyeToScreenDistance: number;
  43414. /**
  43415. * Define the distance between both lenses
  43416. */
  43417. lensSeparationDistance: number;
  43418. /**
  43419. * Define the distance between both viewer's eyes.
  43420. */
  43421. interpupillaryDistance: number;
  43422. /**
  43423. * Define the distortion factor of the VR postprocess.
  43424. * Please, touch with care.
  43425. */
  43426. distortionK: number[];
  43427. /**
  43428. * Define the chromatic aberration correction factors for the VR post process.
  43429. */
  43430. chromaAbCorrection: number[];
  43431. /**
  43432. * Define the scale factor of the post process.
  43433. * The smaller the better but the slower.
  43434. */
  43435. postProcessScaleFactor: number;
  43436. /**
  43437. * Define an offset for the lens center.
  43438. */
  43439. lensCenterOffset: number;
  43440. /**
  43441. * Define if the current vr camera should compensate the distortion of the lense or not.
  43442. */
  43443. compensateDistortion: boolean;
  43444. /**
  43445. * Defines if multiview should be enabled when rendering (Default: false)
  43446. */
  43447. multiviewEnabled: boolean;
  43448. /**
  43449. * Gets the rendering aspect ratio based on the provided resolutions.
  43450. */
  43451. get aspectRatio(): number;
  43452. /**
  43453. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43454. */
  43455. get aspectRatioFov(): number;
  43456. /**
  43457. * @hidden
  43458. */
  43459. get leftHMatrix(): Matrix;
  43460. /**
  43461. * @hidden
  43462. */
  43463. get rightHMatrix(): Matrix;
  43464. /**
  43465. * @hidden
  43466. */
  43467. get leftPreViewMatrix(): Matrix;
  43468. /**
  43469. * @hidden
  43470. */
  43471. get rightPreViewMatrix(): Matrix;
  43472. /**
  43473. * Get the default VRMetrics based on the most generic setup.
  43474. * @returns the default vr metrics
  43475. */
  43476. static GetDefault(): VRCameraMetrics;
  43477. }
  43478. }
  43479. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43480. /** @hidden */
  43481. export var vrDistortionCorrectionPixelShader: {
  43482. name: string;
  43483. shader: string;
  43484. };
  43485. }
  43486. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43487. import { Camera } from "babylonjs/Cameras/camera";
  43488. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43490. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43491. /**
  43492. * VRDistortionCorrectionPostProcess used for mobile VR
  43493. */
  43494. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43495. private _isRightEye;
  43496. private _distortionFactors;
  43497. private _postProcessScaleFactor;
  43498. private _lensCenterOffset;
  43499. private _scaleIn;
  43500. private _scaleFactor;
  43501. private _lensCenter;
  43502. /**
  43503. * Initializes the VRDistortionCorrectionPostProcess
  43504. * @param name The name of the effect.
  43505. * @param camera The camera to apply the render pass to.
  43506. * @param isRightEye If this is for the right eye distortion
  43507. * @param vrMetrics All the required metrics for the VR camera
  43508. */
  43509. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43510. }
  43511. }
  43512. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43513. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43514. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43515. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43516. import { Scene } from "babylonjs/scene";
  43517. import { Vector3 } from "babylonjs/Maths/math.vector";
  43518. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43519. import "babylonjs/Cameras/RigModes/vrRigMode";
  43520. /**
  43521. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43522. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43523. */
  43524. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43525. /**
  43526. * Creates a new VRDeviceOrientationArcRotateCamera
  43527. * @param name defines camera name
  43528. * @param alpha defines the camera rotation along the logitudinal axis
  43529. * @param beta defines the camera rotation along the latitudinal axis
  43530. * @param radius defines the camera distance from its target
  43531. * @param target defines the camera target
  43532. * @param scene defines the scene the camera belongs to
  43533. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43534. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43535. */
  43536. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43537. /**
  43538. * Gets camera class name
  43539. * @returns VRDeviceOrientationArcRotateCamera
  43540. */
  43541. getClassName(): string;
  43542. }
  43543. }
  43544. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43545. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43546. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { Vector3 } from "babylonjs/Maths/math.vector";
  43549. import "babylonjs/Cameras/RigModes/vrRigMode";
  43550. /**
  43551. * Camera used to simulate VR rendering (based on FreeCamera)
  43552. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43553. */
  43554. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43555. /**
  43556. * Creates a new VRDeviceOrientationFreeCamera
  43557. * @param name defines camera name
  43558. * @param position defines the start position of the camera
  43559. * @param scene defines the scene the camera belongs to
  43560. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43561. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43562. */
  43563. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43564. /**
  43565. * Gets camera class name
  43566. * @returns VRDeviceOrientationFreeCamera
  43567. */
  43568. getClassName(): string;
  43569. }
  43570. }
  43571. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43572. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43573. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43574. import { Scene } from "babylonjs/scene";
  43575. import { Vector3 } from "babylonjs/Maths/math.vector";
  43576. import "babylonjs/Gamepads/gamepadSceneComponent";
  43577. /**
  43578. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43579. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43580. */
  43581. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43582. /**
  43583. * Creates a new VRDeviceOrientationGamepadCamera
  43584. * @param name defines camera name
  43585. * @param position defines the start position of the camera
  43586. * @param scene defines the scene the camera belongs to
  43587. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43588. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43589. */
  43590. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43591. /**
  43592. * Gets camera class name
  43593. * @returns VRDeviceOrientationGamepadCamera
  43594. */
  43595. getClassName(): string;
  43596. }
  43597. }
  43598. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43599. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43601. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43602. /** @hidden */
  43603. export var imageProcessingPixelShader: {
  43604. name: string;
  43605. shader: string;
  43606. };
  43607. }
  43608. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43609. import { Nullable } from "babylonjs/types";
  43610. import { Color4 } from "babylonjs/Maths/math.color";
  43611. import { Camera } from "babylonjs/Cameras/camera";
  43612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43613. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43614. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43616. import { Engine } from "babylonjs/Engines/engine";
  43617. import "babylonjs/Shaders/imageProcessing.fragment";
  43618. import "babylonjs/Shaders/postprocess.vertex";
  43619. /**
  43620. * ImageProcessingPostProcess
  43621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43622. */
  43623. export class ImageProcessingPostProcess extends PostProcess {
  43624. /**
  43625. * Default configuration related to image processing available in the PBR Material.
  43626. */
  43627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43628. /**
  43629. * Gets the image processing configuration used either in this material.
  43630. */
  43631. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43632. /**
  43633. * Sets the Default image processing configuration used either in the this material.
  43634. *
  43635. * If sets to null, the scene one is in use.
  43636. */
  43637. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43638. /**
  43639. * Keep track of the image processing observer to allow dispose and replace.
  43640. */
  43641. private _imageProcessingObserver;
  43642. /**
  43643. * Attaches a new image processing configuration to the PBR Material.
  43644. * @param configuration
  43645. */
  43646. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43647. /**
  43648. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43649. */
  43650. get colorCurves(): Nullable<ColorCurves>;
  43651. /**
  43652. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43653. */
  43654. set colorCurves(value: Nullable<ColorCurves>);
  43655. /**
  43656. * Gets wether the color curves effect is enabled.
  43657. */
  43658. get colorCurvesEnabled(): boolean;
  43659. /**
  43660. * Sets wether the color curves effect is enabled.
  43661. */
  43662. set colorCurvesEnabled(value: boolean);
  43663. /**
  43664. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43665. */
  43666. get colorGradingTexture(): Nullable<BaseTexture>;
  43667. /**
  43668. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43669. */
  43670. set colorGradingTexture(value: Nullable<BaseTexture>);
  43671. /**
  43672. * Gets wether the color grading effect is enabled.
  43673. */
  43674. get colorGradingEnabled(): boolean;
  43675. /**
  43676. * Gets wether the color grading effect is enabled.
  43677. */
  43678. set colorGradingEnabled(value: boolean);
  43679. /**
  43680. * Gets exposure used in the effect.
  43681. */
  43682. get exposure(): number;
  43683. /**
  43684. * Sets exposure used in the effect.
  43685. */
  43686. set exposure(value: number);
  43687. /**
  43688. * Gets wether tonemapping is enabled or not.
  43689. */
  43690. get toneMappingEnabled(): boolean;
  43691. /**
  43692. * Sets wether tonemapping is enabled or not
  43693. */
  43694. set toneMappingEnabled(value: boolean);
  43695. /**
  43696. * Gets the type of tone mapping effect.
  43697. */
  43698. get toneMappingType(): number;
  43699. /**
  43700. * Sets the type of tone mapping effect.
  43701. */
  43702. set toneMappingType(value: number);
  43703. /**
  43704. * Gets contrast used in the effect.
  43705. */
  43706. get contrast(): number;
  43707. /**
  43708. * Sets contrast used in the effect.
  43709. */
  43710. set contrast(value: number);
  43711. /**
  43712. * Gets Vignette stretch size.
  43713. */
  43714. get vignetteStretch(): number;
  43715. /**
  43716. * Sets Vignette stretch size.
  43717. */
  43718. set vignetteStretch(value: number);
  43719. /**
  43720. * Gets Vignette centre X Offset.
  43721. */
  43722. get vignetteCentreX(): number;
  43723. /**
  43724. * Sets Vignette centre X Offset.
  43725. */
  43726. set vignetteCentreX(value: number);
  43727. /**
  43728. * Gets Vignette centre Y Offset.
  43729. */
  43730. get vignetteCentreY(): number;
  43731. /**
  43732. * Sets Vignette centre Y Offset.
  43733. */
  43734. set vignetteCentreY(value: number);
  43735. /**
  43736. * Gets Vignette weight or intensity of the vignette effect.
  43737. */
  43738. get vignetteWeight(): number;
  43739. /**
  43740. * Sets Vignette weight or intensity of the vignette effect.
  43741. */
  43742. set vignetteWeight(value: number);
  43743. /**
  43744. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43745. * if vignetteEnabled is set to true.
  43746. */
  43747. get vignetteColor(): Color4;
  43748. /**
  43749. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43750. * if vignetteEnabled is set to true.
  43751. */
  43752. set vignetteColor(value: Color4);
  43753. /**
  43754. * Gets Camera field of view used by the Vignette effect.
  43755. */
  43756. get vignetteCameraFov(): number;
  43757. /**
  43758. * Sets Camera field of view used by the Vignette effect.
  43759. */
  43760. set vignetteCameraFov(value: number);
  43761. /**
  43762. * Gets the vignette blend mode allowing different kind of effect.
  43763. */
  43764. get vignetteBlendMode(): number;
  43765. /**
  43766. * Sets the vignette blend mode allowing different kind of effect.
  43767. */
  43768. set vignetteBlendMode(value: number);
  43769. /**
  43770. * Gets wether the vignette effect is enabled.
  43771. */
  43772. get vignetteEnabled(): boolean;
  43773. /**
  43774. * Sets wether the vignette effect is enabled.
  43775. */
  43776. set vignetteEnabled(value: boolean);
  43777. private _fromLinearSpace;
  43778. /**
  43779. * Gets wether the input of the processing is in Gamma or Linear Space.
  43780. */
  43781. get fromLinearSpace(): boolean;
  43782. /**
  43783. * Sets wether the input of the processing is in Gamma or Linear Space.
  43784. */
  43785. set fromLinearSpace(value: boolean);
  43786. /**
  43787. * Defines cache preventing GC.
  43788. */
  43789. private _defines;
  43790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43791. /**
  43792. * "ImageProcessingPostProcess"
  43793. * @returns "ImageProcessingPostProcess"
  43794. */
  43795. getClassName(): string;
  43796. protected _updateParameters(): void;
  43797. dispose(camera?: Camera): void;
  43798. }
  43799. }
  43800. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43801. import { Scene } from "babylonjs/scene";
  43802. import { Color3 } from "babylonjs/Maths/math.color";
  43803. import { Mesh } from "babylonjs/Meshes/mesh";
  43804. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43805. import { Nullable } from "babylonjs/types";
  43806. /**
  43807. * Class containing static functions to help procedurally build meshes
  43808. */
  43809. export class GroundBuilder {
  43810. /**
  43811. * Creates a ground mesh
  43812. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43813. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43815. * @param name defines the name of the mesh
  43816. * @param options defines the options used to create the mesh
  43817. * @param scene defines the hosting scene
  43818. * @returns the ground mesh
  43819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43820. */
  43821. static CreateGround(name: string, options: {
  43822. width?: number;
  43823. height?: number;
  43824. subdivisions?: number;
  43825. subdivisionsX?: number;
  43826. subdivisionsY?: number;
  43827. updatable?: boolean;
  43828. }, scene: any): Mesh;
  43829. /**
  43830. * Creates a tiled ground mesh
  43831. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43832. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43833. * * 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
  43834. * * 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
  43835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43836. * @param name defines the name of the mesh
  43837. * @param options defines the options used to create the mesh
  43838. * @param scene defines the hosting scene
  43839. * @returns the tiled ground mesh
  43840. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43841. */
  43842. static CreateTiledGround(name: string, options: {
  43843. xmin: number;
  43844. zmin: number;
  43845. xmax: number;
  43846. zmax: number;
  43847. subdivisions?: {
  43848. w: number;
  43849. h: number;
  43850. };
  43851. precision?: {
  43852. w: number;
  43853. h: number;
  43854. };
  43855. updatable?: boolean;
  43856. }, scene?: Nullable<Scene>): Mesh;
  43857. /**
  43858. * Creates a ground mesh from a height map
  43859. * * The parameter `url` sets the URL of the height map image resource.
  43860. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43861. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43862. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43863. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43864. * * 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.
  43865. * * 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).
  43866. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43868. * @param name defines the name of the mesh
  43869. * @param url defines the url to the height map
  43870. * @param options defines the options used to create the mesh
  43871. * @param scene defines the hosting scene
  43872. * @returns the ground mesh
  43873. * @see https://doc.babylonjs.com/babylon101/height_map
  43874. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43875. */
  43876. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43877. width?: number;
  43878. height?: number;
  43879. subdivisions?: number;
  43880. minHeight?: number;
  43881. maxHeight?: number;
  43882. colorFilter?: Color3;
  43883. alphaFilter?: number;
  43884. updatable?: boolean;
  43885. onReady?: (mesh: GroundMesh) => void;
  43886. }, scene?: Nullable<Scene>): GroundMesh;
  43887. }
  43888. }
  43889. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43890. import { Vector4 } from "babylonjs/Maths/math.vector";
  43891. import { Mesh } from "babylonjs/Meshes/mesh";
  43892. /**
  43893. * Class containing static functions to help procedurally build meshes
  43894. */
  43895. export class TorusBuilder {
  43896. /**
  43897. * Creates a torus mesh
  43898. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43899. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43900. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43904. * @param name defines the name of the mesh
  43905. * @param options defines the options used to create the mesh
  43906. * @param scene defines the hosting scene
  43907. * @returns the torus mesh
  43908. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43909. */
  43910. static CreateTorus(name: string, options: {
  43911. diameter?: number;
  43912. thickness?: number;
  43913. tessellation?: number;
  43914. updatable?: boolean;
  43915. sideOrientation?: number;
  43916. frontUVs?: Vector4;
  43917. backUVs?: Vector4;
  43918. }, scene: any): Mesh;
  43919. }
  43920. }
  43921. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43922. import { Vector4 } from "babylonjs/Maths/math.vector";
  43923. import { Color4 } from "babylonjs/Maths/math.color";
  43924. import { Mesh } from "babylonjs/Meshes/mesh";
  43925. /**
  43926. * Class containing static functions to help procedurally build meshes
  43927. */
  43928. export class CylinderBuilder {
  43929. /**
  43930. * Creates a cylinder or a cone mesh
  43931. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43932. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43933. * * 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.
  43934. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43935. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43936. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43937. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43938. * * 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).
  43939. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43940. * * 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).
  43941. * * 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
  43942. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43943. * * 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
  43944. * * 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.
  43945. * * If `enclose` is false, a ring surface is one element.
  43946. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43947. * * 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
  43948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43951. * @param name defines the name of the mesh
  43952. * @param options defines the options used to create the mesh
  43953. * @param scene defines the hosting scene
  43954. * @returns the cylinder mesh
  43955. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43956. */
  43957. static CreateCylinder(name: string, options: {
  43958. height?: number;
  43959. diameterTop?: number;
  43960. diameterBottom?: number;
  43961. diameter?: number;
  43962. tessellation?: number;
  43963. subdivisions?: number;
  43964. arc?: number;
  43965. faceColors?: Color4[];
  43966. faceUV?: Vector4[];
  43967. updatable?: boolean;
  43968. hasRings?: boolean;
  43969. enclose?: boolean;
  43970. cap?: number;
  43971. sideOrientation?: number;
  43972. frontUVs?: Vector4;
  43973. backUVs?: Vector4;
  43974. }, scene: any): Mesh;
  43975. }
  43976. }
  43977. declare module "babylonjs/XR/webXRTypes" {
  43978. import { Nullable } from "babylonjs/types";
  43979. import { IDisposable } from "babylonjs/scene";
  43980. /**
  43981. * States of the webXR experience
  43982. */
  43983. export enum WebXRState {
  43984. /**
  43985. * Transitioning to being in XR mode
  43986. */
  43987. ENTERING_XR = 0,
  43988. /**
  43989. * Transitioning to non XR mode
  43990. */
  43991. EXITING_XR = 1,
  43992. /**
  43993. * In XR mode and presenting
  43994. */
  43995. IN_XR = 2,
  43996. /**
  43997. * Not entered XR mode
  43998. */
  43999. NOT_IN_XR = 3
  44000. }
  44001. /**
  44002. * Abstraction of the XR render target
  44003. */
  44004. export interface WebXRRenderTarget extends IDisposable {
  44005. /**
  44006. * xrpresent context of the canvas which can be used to display/mirror xr content
  44007. */
  44008. canvasContext: WebGLRenderingContext;
  44009. /**
  44010. * xr layer for the canvas
  44011. */
  44012. xrLayer: Nullable<XRWebGLLayer>;
  44013. /**
  44014. * Initializes the xr layer for the session
  44015. * @param xrSession xr session
  44016. * @returns a promise that will resolve once the XR Layer has been created
  44017. */
  44018. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44019. }
  44020. }
  44021. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44022. import { Nullable } from "babylonjs/types";
  44023. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44024. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44025. /**
  44026. * COnfiguration object for WebXR output canvas
  44027. */
  44028. export class WebXRManagedOutputCanvasOptions {
  44029. /**
  44030. * Options for this XR Layer output
  44031. */
  44032. canvasOptions?: XRWebGLLayerOptions;
  44033. /**
  44034. * CSS styling for a newly created canvas (if not provided)
  44035. */
  44036. newCanvasCssStyle?: string;
  44037. /**
  44038. * An optional canvas in case you wish to create it yourself and provide it here.
  44039. * If not provided, a new canvas will be created
  44040. */
  44041. canvasElement?: HTMLCanvasElement;
  44042. /**
  44043. * Get the default values of the configuration object
  44044. * @returns default values of this configuration object
  44045. */
  44046. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44047. }
  44048. /**
  44049. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44050. */
  44051. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44052. private _options;
  44053. private _engine;
  44054. private _canvas;
  44055. /**
  44056. * Rendering context of the canvas which can be used to display/mirror xr content
  44057. */
  44058. canvasContext: WebGLRenderingContext;
  44059. /**
  44060. * xr layer for the canvas
  44061. */
  44062. xrLayer: Nullable<XRWebGLLayer>;
  44063. /**
  44064. * Initializes the xr layer for the session
  44065. * @param xrSession xr session
  44066. * @returns a promise that will resolve once the XR Layer has been created
  44067. */
  44068. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44069. /**
  44070. * Initializes the canvas to be added/removed upon entering/exiting xr
  44071. * @param _xrSessionManager The XR Session manager
  44072. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44073. */
  44074. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44075. /**
  44076. * Disposes of the object
  44077. */
  44078. dispose(): void;
  44079. private _setManagedOutputCanvas;
  44080. private _addCanvas;
  44081. private _removeCanvas;
  44082. }
  44083. }
  44084. declare module "babylonjs/XR/webXRSessionManager" {
  44085. import { Observable } from "babylonjs/Misc/observable";
  44086. import { Nullable } from "babylonjs/types";
  44087. import { IDisposable, Scene } from "babylonjs/scene";
  44088. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44089. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44090. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44091. /**
  44092. * Manages an XRSession to work with Babylon's engine
  44093. * @see https://doc.babylonjs.com/how_to/webxr
  44094. */
  44095. export class WebXRSessionManager implements IDisposable {
  44096. /** The scene which the session should be created for */
  44097. scene: Scene;
  44098. /**
  44099. * Fires every time a new xrFrame arrives which can be used to update the camera
  44100. */
  44101. onXRFrameObservable: Observable<XRFrame>;
  44102. /**
  44103. * Fires when the xr session is ended either by the device or manually done
  44104. */
  44105. onXRSessionEnded: Observable<any>;
  44106. /**
  44107. * Fires when the xr session is ended either by the device or manually done
  44108. */
  44109. onXRSessionInit: Observable<XRSession>;
  44110. /**
  44111. * Fires when the reference space changed
  44112. */
  44113. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44114. /**
  44115. * Underlying xr session
  44116. */
  44117. session: XRSession;
  44118. /**
  44119. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44120. * or get the offset the player is currently at.
  44121. */
  44122. viewerReferenceSpace: XRReferenceSpace;
  44123. private _referenceSpace;
  44124. /**
  44125. * The current reference space used in this session. This reference space can constantly change!
  44126. * It is mainly used to offset the camera's position.
  44127. */
  44128. get referenceSpace(): XRReferenceSpace;
  44129. /**
  44130. * Set a new reference space and triggers the observable
  44131. */
  44132. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44133. /**
  44134. * The base reference space from which the session started. good if you want to reset your
  44135. * reference space
  44136. */
  44137. baseReferenceSpace: XRReferenceSpace;
  44138. /**
  44139. * Used just in case of a failure to initialize an immersive session.
  44140. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44141. */
  44142. defaultHeightCompensation: number;
  44143. /**
  44144. * Current XR frame
  44145. */
  44146. currentFrame: Nullable<XRFrame>;
  44147. /** WebXR timestamp updated every frame */
  44148. currentTimestamp: number;
  44149. private _xrNavigator;
  44150. private baseLayer;
  44151. private _rttProvider;
  44152. private _sessionEnded;
  44153. /**
  44154. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44155. * @param scene The scene which the session should be created for
  44156. */
  44157. constructor(
  44158. /** The scene which the session should be created for */
  44159. scene: Scene);
  44160. /**
  44161. * Initializes the manager
  44162. * After initialization enterXR can be called to start an XR session
  44163. * @returns Promise which resolves after it is initialized
  44164. */
  44165. initializeAsync(): Promise<void>;
  44166. /**
  44167. * Initializes an xr session
  44168. * @param xrSessionMode mode to initialize
  44169. * @param xrSessionInit defines optional and required values to pass to the session builder
  44170. * @returns a promise which will resolve once the session has been initialized
  44171. */
  44172. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44173. /**
  44174. * Sets the reference space on the xr session
  44175. * @param referenceSpaceType space to set
  44176. * @returns a promise that will resolve once the reference space has been set
  44177. */
  44178. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44179. /**
  44180. * Resets the reference space to the one started the session
  44181. */
  44182. resetReferenceSpace(): void;
  44183. /**
  44184. * Updates the render state of the session
  44185. * @param state state to set
  44186. * @returns a promise that resolves once the render state has been updated
  44187. */
  44188. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44189. /**
  44190. * Starts rendering to the xr layer
  44191. */
  44192. runXRRenderLoop(): void;
  44193. /**
  44194. * Gets the correct render target texture to be rendered this frame for this eye
  44195. * @param eye the eye for which to get the render target
  44196. * @returns the render target for the specified eye
  44197. */
  44198. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44199. /**
  44200. * Stops the xrSession and restores the renderloop
  44201. * @returns Promise which resolves after it exits XR
  44202. */
  44203. exitXRAsync(): Promise<void>;
  44204. /**
  44205. * Checks if a session would be supported for the creation options specified
  44206. * @param sessionMode session mode to check if supported eg. immersive-vr
  44207. * @returns A Promise that resolves to true if supported and false if not
  44208. */
  44209. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44210. /**
  44211. * Creates a WebXRRenderTarget object for the XR session
  44212. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44213. * @param options optional options to provide when creating a new render target
  44214. * @returns a WebXR render target to which the session can render
  44215. */
  44216. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44217. /**
  44218. * @hidden
  44219. * Converts the render layer of xrSession to a render target
  44220. * @param session session to create render target for
  44221. * @param scene scene the new render target should be created for
  44222. * @param baseLayer the webgl layer to create the render target for
  44223. */
  44224. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44225. /**
  44226. * Disposes of the session manager
  44227. */
  44228. dispose(): void;
  44229. /**
  44230. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44231. * @param sessionMode defines the session to test
  44232. * @returns a promise with boolean as final value
  44233. */
  44234. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44235. }
  44236. }
  44237. declare module "babylonjs/XR/webXRCamera" {
  44238. import { Scene } from "babylonjs/scene";
  44239. import { Camera } from "babylonjs/Cameras/camera";
  44240. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44241. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44242. /**
  44243. * WebXR Camera which holds the views for the xrSession
  44244. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44245. */
  44246. export class WebXRCamera extends FreeCamera {
  44247. private _xrSessionManager;
  44248. private _firstFrame;
  44249. private _referenceQuaternion;
  44250. private _referencedPosition;
  44251. private _xrInvPositionCache;
  44252. private _xrInvQuaternionCache;
  44253. /**
  44254. * Should position compensation execute on first frame.
  44255. * This is used when copying the position from a native (non XR) camera
  44256. */
  44257. compensateOnFirstFrame: boolean;
  44258. /**
  44259. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44260. * @param name the name of the camera
  44261. * @param scene the scene to add the camera to
  44262. * @param _xrSessionManager a constructed xr session manager
  44263. */
  44264. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44265. /**
  44266. * Return the user's height, unrelated to the current ground.
  44267. * This will be the y position of this camera, when ground level is 0.
  44268. */
  44269. get realWorldHeight(): number;
  44270. /** @hidden */
  44271. _updateForDualEyeDebugging(): void;
  44272. /**
  44273. * Sets this camera's transformation based on a non-vr camera
  44274. * @param otherCamera the non-vr camera to copy the transformation from
  44275. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44276. */
  44277. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44278. private _updateFromXRSession;
  44279. private _updateNumberOfRigCameras;
  44280. private _updateReferenceSpace;
  44281. private _updateReferenceSpaceOffset;
  44282. }
  44283. }
  44284. declare module "babylonjs/XR/webXRFeaturesManager" {
  44285. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44286. import { IDisposable } from "babylonjs/scene";
  44287. /**
  44288. * Defining the interface required for a (webxr) feature
  44289. */
  44290. export interface IWebXRFeature extends IDisposable {
  44291. /**
  44292. * Is this feature attached
  44293. */
  44294. attached: boolean;
  44295. /**
  44296. * Should auto-attach be disabled?
  44297. */
  44298. disableAutoAttach: boolean;
  44299. /**
  44300. * Attach the feature to the session
  44301. * Will usually be called by the features manager
  44302. *
  44303. * @param force should attachment be forced (even when already attached)
  44304. * @returns true if successful.
  44305. */
  44306. attach(force?: boolean): boolean;
  44307. /**
  44308. * Detach the feature from the session
  44309. * Will usually be called by the features manager
  44310. *
  44311. * @returns true if successful.
  44312. */
  44313. detach(): boolean;
  44314. }
  44315. /**
  44316. * A list of the currently available features without referencing them
  44317. */
  44318. export class WebXRFeatureName {
  44319. /**
  44320. * The name of the hit test feature
  44321. */
  44322. static HIT_TEST: string;
  44323. /**
  44324. * The name of the anchor system feature
  44325. */
  44326. static ANCHOR_SYSTEM: string;
  44327. /**
  44328. * The name of the background remover feature
  44329. */
  44330. static BACKGROUND_REMOVER: string;
  44331. /**
  44332. * The name of the pointer selection feature
  44333. */
  44334. static POINTER_SELECTION: string;
  44335. /**
  44336. * The name of the teleportation feature
  44337. */
  44338. static TELEPORTATION: string;
  44339. /**
  44340. * The name of the plane detection feature
  44341. */
  44342. static PLANE_DETECTION: string;
  44343. /**
  44344. * physics impostors for xr controllers feature
  44345. */
  44346. static PHYSICS_CONTROLLERS: string;
  44347. }
  44348. /**
  44349. * Defining the constructor of a feature. Used to register the modules.
  44350. */
  44351. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44352. /**
  44353. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44354. * It is mainly used in AR sessions.
  44355. *
  44356. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44357. */
  44358. export class WebXRFeaturesManager implements IDisposable {
  44359. private _xrSessionManager;
  44360. private static readonly _AvailableFeatures;
  44361. /**
  44362. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44363. * Mainly used internally.
  44364. *
  44365. * @param featureName the name of the feature to register
  44366. * @param constructorFunction the function used to construct the module
  44367. * @param version the (babylon) version of the module
  44368. * @param stable is that a stable version of this module
  44369. */
  44370. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44371. /**
  44372. * Returns a constructor of a specific feature.
  44373. *
  44374. * @param featureName the name of the feature to construct
  44375. * @param version the version of the feature to load
  44376. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44377. * @param options optional options provided to the module.
  44378. * @returns a function that, when called, will return a new instance of this feature
  44379. */
  44380. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44381. /**
  44382. * Return the latest unstable version of this feature
  44383. * @param featureName the name of the feature to search
  44384. * @returns the version number. if not found will return -1
  44385. */
  44386. static GetLatestVersionOfFeature(featureName: string): number;
  44387. /**
  44388. * Return the latest stable version of this feature
  44389. * @param featureName the name of the feature to search
  44390. * @returns the version number. if not found will return -1
  44391. */
  44392. static GetStableVersionOfFeature(featureName: string): number;
  44393. /**
  44394. * Can be used to return the list of features currently registered
  44395. *
  44396. * @returns an Array of available features
  44397. */
  44398. static GetAvailableFeatures(): string[];
  44399. /**
  44400. * Gets the versions available for a specific feature
  44401. * @param featureName the name of the feature
  44402. * @returns an array with the available versions
  44403. */
  44404. static GetAvailableVersions(featureName: string): string[];
  44405. private _features;
  44406. /**
  44407. * constructs a new features manages.
  44408. *
  44409. * @param _xrSessionManager an instance of WebXRSessionManager
  44410. */
  44411. constructor(_xrSessionManager: WebXRSessionManager);
  44412. /**
  44413. * 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.
  44414. * 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.
  44415. *
  44416. * @param featureName the name of the feature to load or the class of the feature
  44417. * @param version optional version to load. if not provided the latest version will be enabled
  44418. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44419. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44420. * @returns a new constructed feature or throws an error if feature not found.
  44421. */
  44422. enableFeature(featureName: string | {
  44423. Name: string;
  44424. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44425. /**
  44426. * Used to disable an already-enabled feature
  44427. * The feature will be disposed and will be recreated once enabled.
  44428. * @param featureName the feature to disable
  44429. * @returns true if disable was successful
  44430. */
  44431. disableFeature(featureName: string | {
  44432. Name: string;
  44433. }): boolean;
  44434. /**
  44435. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44436. * Can be used during a session to start a feature
  44437. * @param featureName the name of feature to attach
  44438. */
  44439. attachFeature(featureName: string): void;
  44440. /**
  44441. * Can be used inside a session or when the session ends to detach a specific feature
  44442. * @param featureName the name of the feature to detach
  44443. */
  44444. detachFeature(featureName: string): void;
  44445. /**
  44446. * Get the list of enabled features
  44447. * @returns an array of enabled features
  44448. */
  44449. getEnabledFeatures(): string[];
  44450. /**
  44451. * get the implementation of an enabled feature.
  44452. * @param featureName the name of the feature to load
  44453. * @returns the feature class, if found
  44454. */
  44455. getEnabledFeature(featureName: string): IWebXRFeature;
  44456. /**
  44457. * dispose this features manager
  44458. */
  44459. dispose(): void;
  44460. }
  44461. }
  44462. declare module "babylonjs/XR/webXRExperienceHelper" {
  44463. import { Observable } from "babylonjs/Misc/observable";
  44464. import { IDisposable, Scene } from "babylonjs/scene";
  44465. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44466. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44467. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44468. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44469. /**
  44470. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44471. * @see https://doc.babylonjs.com/how_to/webxr
  44472. */
  44473. export class WebXRExperienceHelper implements IDisposable {
  44474. private scene;
  44475. /**
  44476. * Camera used to render xr content
  44477. */
  44478. camera: WebXRCamera;
  44479. /**
  44480. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44481. */
  44482. state: WebXRState;
  44483. private _setState;
  44484. /**
  44485. * Fires when the state of the experience helper has changed
  44486. */
  44487. onStateChangedObservable: Observable<WebXRState>;
  44488. /**
  44489. * Observers registered here will be triggered after the camera's initial transformation is set
  44490. * This can be used to set a different ground level or an extra rotation.
  44491. *
  44492. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44493. * to the position set after this observable is done executing.
  44494. */
  44495. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44496. /** Session manager used to keep track of xr session */
  44497. sessionManager: WebXRSessionManager;
  44498. /** A features manager for this xr session */
  44499. featuresManager: WebXRFeaturesManager;
  44500. private _nonVRCamera;
  44501. private _originalSceneAutoClear;
  44502. private _supported;
  44503. /**
  44504. * Creates the experience helper
  44505. * @param scene the scene to attach the experience helper to
  44506. * @returns a promise for the experience helper
  44507. */
  44508. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44509. /**
  44510. * Creates a WebXRExperienceHelper
  44511. * @param scene The scene the helper should be created in
  44512. */
  44513. private constructor();
  44514. /**
  44515. * Exits XR mode and returns the scene to its original state
  44516. * @returns promise that resolves after xr mode has exited
  44517. */
  44518. exitXRAsync(): Promise<void>;
  44519. /**
  44520. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44521. * @param sessionMode options for the XR session
  44522. * @param referenceSpaceType frame of reference of the XR session
  44523. * @param renderTarget the output canvas that will be used to enter XR mode
  44524. * @returns promise that resolves after xr mode has entered
  44525. */
  44526. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44527. /**
  44528. * Disposes of the experience helper
  44529. */
  44530. dispose(): void;
  44531. private _nonXRToXRCamera;
  44532. }
  44533. }
  44534. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44535. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44536. import { Observable } from "babylonjs/Misc/observable";
  44537. import { IDisposable } from "babylonjs/scene";
  44538. /**
  44539. * X-Y values for axes in WebXR
  44540. */
  44541. export interface IWebXRMotionControllerAxesValue {
  44542. /**
  44543. * The value of the x axis
  44544. */
  44545. x: number;
  44546. /**
  44547. * The value of the y-axis
  44548. */
  44549. y: number;
  44550. }
  44551. /**
  44552. * changed / previous values for the values of this component
  44553. */
  44554. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44555. /**
  44556. * current (this frame) value
  44557. */
  44558. current: T;
  44559. /**
  44560. * previous (last change) value
  44561. */
  44562. previous: T;
  44563. }
  44564. /**
  44565. * Represents changes in the component between current frame and last values recorded
  44566. */
  44567. export interface IWebXRMotionControllerComponentChanges {
  44568. /**
  44569. * will be populated with previous and current values if touched changed
  44570. */
  44571. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44572. /**
  44573. * will be populated with previous and current values if pressed changed
  44574. */
  44575. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44576. /**
  44577. * will be populated with previous and current values if value changed
  44578. */
  44579. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44580. /**
  44581. * will be populated with previous and current values if axes changed
  44582. */
  44583. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44584. }
  44585. /**
  44586. * This class represents a single component (for example button or thumbstick) of a motion controller
  44587. */
  44588. export class WebXRControllerComponent implements IDisposable {
  44589. /**
  44590. * the id of this component
  44591. */
  44592. id: string;
  44593. /**
  44594. * the type of the component
  44595. */
  44596. type: MotionControllerComponentType;
  44597. private _buttonIndex;
  44598. private _axesIndices;
  44599. /**
  44600. * Thumbstick component type
  44601. */
  44602. static THUMBSTICK: MotionControllerComponentType;
  44603. /**
  44604. * Touchpad component type
  44605. */
  44606. static TOUCHPAD: MotionControllerComponentType;
  44607. /**
  44608. * trigger component type
  44609. */
  44610. static TRIGGER: MotionControllerComponentType;
  44611. /**
  44612. * squeeze component type
  44613. */
  44614. static SQUEEZE: MotionControllerComponentType;
  44615. /**
  44616. * button component type
  44617. */
  44618. static BUTTON: MotionControllerComponentType;
  44619. /**
  44620. * Observers registered here will be triggered when the state of a button changes
  44621. * State change is either pressed / touched / value
  44622. */
  44623. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44624. /**
  44625. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44626. * the axes data changes
  44627. */
  44628. onAxisValueChangedObservable: Observable<{
  44629. x: number;
  44630. y: number;
  44631. }>;
  44632. private _currentValue;
  44633. private _touched;
  44634. private _pressed;
  44635. private _axes;
  44636. private _changes;
  44637. private _hasChanges;
  44638. /**
  44639. * Return whether or not the component changed the last frame
  44640. */
  44641. get hasChanges(): boolean;
  44642. /**
  44643. * Creates a new component for a motion controller.
  44644. * It is created by the motion controller itself
  44645. *
  44646. * @param id the id of this component
  44647. * @param type the type of the component
  44648. * @param _buttonIndex index in the buttons array of the gamepad
  44649. * @param _axesIndices indices of the values in the axes array of the gamepad
  44650. */
  44651. constructor(
  44652. /**
  44653. * the id of this component
  44654. */
  44655. id: string,
  44656. /**
  44657. * the type of the component
  44658. */
  44659. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44660. /**
  44661. * Get the current value of this component
  44662. */
  44663. get value(): number;
  44664. /**
  44665. * is the button currently pressed
  44666. */
  44667. get pressed(): boolean;
  44668. /**
  44669. * is the button currently touched
  44670. */
  44671. get touched(): boolean;
  44672. /**
  44673. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44674. */
  44675. get axes(): IWebXRMotionControllerAxesValue;
  44676. /**
  44677. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44678. */
  44679. get changes(): IWebXRMotionControllerComponentChanges;
  44680. /**
  44681. * Is this component a button (hence - pressable)
  44682. * @returns true if can be pressed
  44683. */
  44684. isButton(): boolean;
  44685. /**
  44686. * Are there axes correlating to this component
  44687. * @return true is axes data is available
  44688. */
  44689. isAxes(): boolean;
  44690. /**
  44691. * update this component using the gamepad object it is in. Called on every frame
  44692. * @param nativeController the native gamepad controller object
  44693. */
  44694. update(nativeController: IMinimalMotionControllerObject): void;
  44695. /**
  44696. * Dispose this component
  44697. */
  44698. dispose(): void;
  44699. }
  44700. }
  44701. declare module "babylonjs/Loading/sceneLoader" {
  44702. import { Observable } from "babylonjs/Misc/observable";
  44703. import { Nullable } from "babylonjs/types";
  44704. import { Scene } from "babylonjs/scene";
  44705. import { Engine } from "babylonjs/Engines/engine";
  44706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44707. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44708. import { AssetContainer } from "babylonjs/assetContainer";
  44709. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44710. import { Skeleton } from "babylonjs/Bones/skeleton";
  44711. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44712. import { WebRequest } from "babylonjs/Misc/webRequest";
  44713. /**
  44714. * Class used to represent data loading progression
  44715. */
  44716. export class SceneLoaderProgressEvent {
  44717. /** defines if data length to load can be evaluated */
  44718. readonly lengthComputable: boolean;
  44719. /** defines the loaded data length */
  44720. readonly loaded: number;
  44721. /** defines the data length to load */
  44722. readonly total: number;
  44723. /**
  44724. * Create a new progress event
  44725. * @param lengthComputable defines if data length to load can be evaluated
  44726. * @param loaded defines the loaded data length
  44727. * @param total defines the data length to load
  44728. */
  44729. constructor(
  44730. /** defines if data length to load can be evaluated */
  44731. lengthComputable: boolean,
  44732. /** defines the loaded data length */
  44733. loaded: number,
  44734. /** defines the data length to load */
  44735. total: number);
  44736. /**
  44737. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44738. * @param event defines the source event
  44739. * @returns a new SceneLoaderProgressEvent
  44740. */
  44741. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44742. }
  44743. /**
  44744. * Interface used by SceneLoader plugins to define supported file extensions
  44745. */
  44746. export interface ISceneLoaderPluginExtensions {
  44747. /**
  44748. * Defines the list of supported extensions
  44749. */
  44750. [extension: string]: {
  44751. isBinary: boolean;
  44752. };
  44753. }
  44754. /**
  44755. * Interface used by SceneLoader plugin factory
  44756. */
  44757. export interface ISceneLoaderPluginFactory {
  44758. /**
  44759. * Defines the name of the factory
  44760. */
  44761. name: string;
  44762. /**
  44763. * Function called to create a new plugin
  44764. * @return the new plugin
  44765. */
  44766. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44767. /**
  44768. * The callback that returns true if the data can be directly loaded.
  44769. * @param data string containing the file data
  44770. * @returns if the data can be loaded directly
  44771. */
  44772. canDirectLoad?(data: string): boolean;
  44773. }
  44774. /**
  44775. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44776. */
  44777. export interface ISceneLoaderPluginBase {
  44778. /**
  44779. * The friendly name of this plugin.
  44780. */
  44781. name: string;
  44782. /**
  44783. * The file extensions supported by this plugin.
  44784. */
  44785. extensions: string | ISceneLoaderPluginExtensions;
  44786. /**
  44787. * The callback called when loading from a url.
  44788. * @param scene scene loading this url
  44789. * @param url url to load
  44790. * @param onSuccess callback called when the file successfully loads
  44791. * @param onProgress callback called while file is loading (if the server supports this mode)
  44792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44793. * @param onError callback called when the file fails to load
  44794. * @returns a file request object
  44795. */
  44796. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44797. /**
  44798. * The callback called when loading from a file object.
  44799. * @param scene scene loading this file
  44800. * @param file defines the file to load
  44801. * @param onSuccess defines the callback to call when data is loaded
  44802. * @param onProgress defines the callback to call during loading process
  44803. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44804. * @param onError defines the callback to call when an error occurs
  44805. * @returns a file request object
  44806. */
  44807. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44808. /**
  44809. * The callback that returns true if the data can be directly loaded.
  44810. * @param data string containing the file data
  44811. * @returns if the data can be loaded directly
  44812. */
  44813. canDirectLoad?(data: string): boolean;
  44814. /**
  44815. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44816. * @param scene scene loading this data
  44817. * @param data string containing the data
  44818. * @returns data to pass to the plugin
  44819. */
  44820. directLoad?(scene: Scene, data: string): any;
  44821. /**
  44822. * The callback that allows custom handling of the root url based on the response url.
  44823. * @param rootUrl the original root url
  44824. * @param responseURL the response url if available
  44825. * @returns the new root url
  44826. */
  44827. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44828. }
  44829. /**
  44830. * Interface used to define a SceneLoader plugin
  44831. */
  44832. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44833. /**
  44834. * Import meshes into a scene.
  44835. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44836. * @param scene The scene to import into
  44837. * @param data The data to import
  44838. * @param rootUrl The root url for scene and resources
  44839. * @param meshes The meshes array to import into
  44840. * @param particleSystems The particle systems array to import into
  44841. * @param skeletons The skeletons array to import into
  44842. * @param onError The callback when import fails
  44843. * @returns True if successful or false otherwise
  44844. */
  44845. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44846. /**
  44847. * Load into a scene.
  44848. * @param scene The scene to load into
  44849. * @param data The data to import
  44850. * @param rootUrl The root url for scene and resources
  44851. * @param onError The callback when import fails
  44852. * @returns True if successful or false otherwise
  44853. */
  44854. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44855. /**
  44856. * Load into an asset container.
  44857. * @param scene The scene to load into
  44858. * @param data The data to import
  44859. * @param rootUrl The root url for scene and resources
  44860. * @param onError The callback when import fails
  44861. * @returns The loaded asset container
  44862. */
  44863. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44864. }
  44865. /**
  44866. * Interface used to define an async SceneLoader plugin
  44867. */
  44868. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44869. /**
  44870. * Import meshes into a scene.
  44871. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44872. * @param scene The scene to import into
  44873. * @param data The data to import
  44874. * @param rootUrl The root url for scene and resources
  44875. * @param onProgress The callback when the load progresses
  44876. * @param fileName Defines the name of the file to load
  44877. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44878. */
  44879. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44880. meshes: AbstractMesh[];
  44881. particleSystems: IParticleSystem[];
  44882. skeletons: Skeleton[];
  44883. animationGroups: AnimationGroup[];
  44884. }>;
  44885. /**
  44886. * Load into a scene.
  44887. * @param scene The scene to load into
  44888. * @param data The data to import
  44889. * @param rootUrl The root url for scene and resources
  44890. * @param onProgress The callback when the load progresses
  44891. * @param fileName Defines the name of the file to load
  44892. * @returns Nothing
  44893. */
  44894. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44895. /**
  44896. * Load into an asset container.
  44897. * @param scene The scene to load into
  44898. * @param data The data to import
  44899. * @param rootUrl The root url for scene and resources
  44900. * @param onProgress The callback when the load progresses
  44901. * @param fileName Defines the name of the file to load
  44902. * @returns The loaded asset container
  44903. */
  44904. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44905. }
  44906. /**
  44907. * Mode that determines how to handle old animation groups before loading new ones.
  44908. */
  44909. export enum SceneLoaderAnimationGroupLoadingMode {
  44910. /**
  44911. * Reset all old animations to initial state then dispose them.
  44912. */
  44913. Clean = 0,
  44914. /**
  44915. * Stop all old animations.
  44916. */
  44917. Stop = 1,
  44918. /**
  44919. * Restart old animations from first frame.
  44920. */
  44921. Sync = 2,
  44922. /**
  44923. * Old animations remains untouched.
  44924. */
  44925. NoSync = 3
  44926. }
  44927. /**
  44928. * Class used to load scene from various file formats using registered plugins
  44929. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44930. */
  44931. export class SceneLoader {
  44932. /**
  44933. * No logging while loading
  44934. */
  44935. static readonly NO_LOGGING: number;
  44936. /**
  44937. * Minimal logging while loading
  44938. */
  44939. static readonly MINIMAL_LOGGING: number;
  44940. /**
  44941. * Summary logging while loading
  44942. */
  44943. static readonly SUMMARY_LOGGING: number;
  44944. /**
  44945. * Detailled logging while loading
  44946. */
  44947. static readonly DETAILED_LOGGING: number;
  44948. /**
  44949. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44950. */
  44951. static get ForceFullSceneLoadingForIncremental(): boolean;
  44952. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44953. /**
  44954. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44955. */
  44956. static get ShowLoadingScreen(): boolean;
  44957. static set ShowLoadingScreen(value: boolean);
  44958. /**
  44959. * Defines the current logging level (while loading the scene)
  44960. * @ignorenaming
  44961. */
  44962. static get loggingLevel(): number;
  44963. static set loggingLevel(value: number);
  44964. /**
  44965. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44966. */
  44967. static get CleanBoneMatrixWeights(): boolean;
  44968. static set CleanBoneMatrixWeights(value: boolean);
  44969. /**
  44970. * Event raised when a plugin is used to load a scene
  44971. */
  44972. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44973. private static _registeredPlugins;
  44974. private static _getDefaultPlugin;
  44975. private static _getPluginForExtension;
  44976. private static _getPluginForDirectLoad;
  44977. private static _getPluginForFilename;
  44978. private static _getDirectLoad;
  44979. private static _loadData;
  44980. private static _getFileInfo;
  44981. /**
  44982. * Gets a plugin that can load the given extension
  44983. * @param extension defines the extension to load
  44984. * @returns a plugin or null if none works
  44985. */
  44986. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44987. /**
  44988. * Gets a boolean indicating that the given extension can be loaded
  44989. * @param extension defines the extension to load
  44990. * @returns true if the extension is supported
  44991. */
  44992. static IsPluginForExtensionAvailable(extension: string): boolean;
  44993. /**
  44994. * Adds a new plugin to the list of registered plugins
  44995. * @param plugin defines the plugin to add
  44996. */
  44997. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44998. /**
  44999. * Import meshes into a scene
  45000. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45001. * @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)
  45002. * @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)
  45003. * @param scene the instance of BABYLON.Scene to append to
  45004. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45005. * @param onProgress a callback with a progress event for each file being loaded
  45006. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45007. * @param pluginExtension the extension used to determine the plugin
  45008. * @returns The loaded plugin
  45009. */
  45010. 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>;
  45011. /**
  45012. * Import meshes into a scene
  45013. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45014. * @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)
  45015. * @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)
  45016. * @param scene the instance of BABYLON.Scene to append to
  45017. * @param onProgress a callback with a progress event for each file being loaded
  45018. * @param pluginExtension the extension used to determine the plugin
  45019. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45020. */
  45021. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45022. meshes: AbstractMesh[];
  45023. particleSystems: IParticleSystem[];
  45024. skeletons: Skeleton[];
  45025. animationGroups: AnimationGroup[];
  45026. }>;
  45027. /**
  45028. * Load a scene
  45029. * @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)
  45030. * @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)
  45031. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45032. * @param onSuccess a callback with the scene when import succeeds
  45033. * @param onProgress a callback with a progress event for each file being loaded
  45034. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45035. * @param pluginExtension the extension used to determine the plugin
  45036. * @returns The loaded plugin
  45037. */
  45038. 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>;
  45039. /**
  45040. * Load a scene
  45041. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45042. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45043. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45044. * @param onProgress a callback with a progress event for each file being loaded
  45045. * @param pluginExtension the extension used to determine the plugin
  45046. * @returns The loaded scene
  45047. */
  45048. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45049. /**
  45050. * Append a scene
  45051. * @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)
  45052. * @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)
  45053. * @param scene is the instance of BABYLON.Scene to append to
  45054. * @param onSuccess a callback with the scene when import succeeds
  45055. * @param onProgress a callback with a progress event for each file being loaded
  45056. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45057. * @param pluginExtension the extension used to determine the plugin
  45058. * @returns The loaded plugin
  45059. */
  45060. 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>;
  45061. /**
  45062. * Append a scene
  45063. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45064. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  45065. * @param scene is the instance of BABYLON.Scene to append to
  45066. * @param onProgress a callback with a progress event for each file being loaded
  45067. * @param pluginExtension the extension used to determine the plugin
  45068. * @returns The given scene
  45069. */
  45070. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45071. /**
  45072. * Load a scene into an asset container
  45073. * @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)
  45074. * @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)
  45075. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45076. * @param onSuccess a callback with the scene when import succeeds
  45077. * @param onProgress a callback with a progress event for each file being loaded
  45078. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45079. * @param pluginExtension the extension used to determine the plugin
  45080. * @returns The loaded plugin
  45081. */
  45082. 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>;
  45083. /**
  45084. * Load a scene into an asset container
  45085. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  45086. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  45087. * @param scene is the instance of Scene to append to
  45088. * @param onProgress a callback with a progress event for each file being loaded
  45089. * @param pluginExtension the extension used to determine the plugin
  45090. * @returns The loaded asset container
  45091. */
  45092. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45093. /**
  45094. * Import animations from a file into a scene
  45095. * @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)
  45096. * @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)
  45097. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45098. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45099. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45100. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45101. * @param onSuccess a callback with the scene when import succeeds
  45102. * @param onProgress a callback with a progress event for each file being loaded
  45103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45104. */
  45105. 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;
  45106. /**
  45107. * Import animations from a file into a scene
  45108. * @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)
  45109. * @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)
  45110. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45111. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45112. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45113. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45114. * @param onSuccess a callback with the scene when import succeeds
  45115. * @param onProgress a callback with a progress event for each file being loaded
  45116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45117. * @returns the updated scene with imported animations
  45118. */
  45119. 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>;
  45120. }
  45121. }
  45122. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45123. import { IDisposable, Scene } from "babylonjs/scene";
  45124. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45125. import { Observable } from "babylonjs/Misc/observable";
  45126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45127. import { Nullable } from "babylonjs/types";
  45128. /**
  45129. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45130. */
  45131. export type MotionControllerHandness = "none" | "left" | "right";
  45132. /**
  45133. * The type of components available in motion controllers.
  45134. * This is not the name of the component.
  45135. */
  45136. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45137. /**
  45138. * The state of a controller component
  45139. */
  45140. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45141. /**
  45142. * The schema of motion controller layout.
  45143. * No object will be initialized using this interface
  45144. * This is used just to define the profile.
  45145. */
  45146. export interface IMotionControllerLayout {
  45147. /**
  45148. * Defines the main button component id
  45149. */
  45150. selectComponentId: string;
  45151. /**
  45152. * Available components (unsorted)
  45153. */
  45154. components: {
  45155. /**
  45156. * A map of component Ids
  45157. */
  45158. [componentId: string]: {
  45159. /**
  45160. * The type of input the component outputs
  45161. */
  45162. type: MotionControllerComponentType;
  45163. /**
  45164. * The indices of this component in the gamepad object
  45165. */
  45166. gamepadIndices: {
  45167. /**
  45168. * Index of button
  45169. */
  45170. button?: number;
  45171. /**
  45172. * If available, index of x-axis
  45173. */
  45174. xAxis?: number;
  45175. /**
  45176. * If available, index of y-axis
  45177. */
  45178. yAxis?: number;
  45179. };
  45180. /**
  45181. * The mesh's root node name
  45182. */
  45183. rootNodeName: string;
  45184. /**
  45185. * Animation definitions for this model
  45186. */
  45187. visualResponses: {
  45188. [stateKey: string]: {
  45189. /**
  45190. * What property will be animated
  45191. */
  45192. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45193. /**
  45194. * What states influence this visual reponse
  45195. */
  45196. states: MotionControllerComponentStateType[];
  45197. /**
  45198. * Type of animation - movement or visibility
  45199. */
  45200. valueNodeProperty: "transform" | "visibility";
  45201. /**
  45202. * Base node name to move. Its position will be calculated according to the min and max nodes
  45203. */
  45204. valueNodeName?: string;
  45205. /**
  45206. * Minimum movement node
  45207. */
  45208. minNodeName?: string;
  45209. /**
  45210. * Max movement node
  45211. */
  45212. maxNodeName?: string;
  45213. };
  45214. };
  45215. /**
  45216. * If touch enabled, what is the name of node to display user feedback
  45217. */
  45218. touchPointNodeName?: string;
  45219. };
  45220. };
  45221. /**
  45222. * Is it xr standard mapping or not
  45223. */
  45224. gamepadMapping: "" | "xr-standard";
  45225. /**
  45226. * Base root node of this entire model
  45227. */
  45228. rootNodeName: string;
  45229. /**
  45230. * Path to load the assets. Usually relative to the base path
  45231. */
  45232. assetPath: string;
  45233. }
  45234. /**
  45235. * A definition for the layout map in the input profile
  45236. */
  45237. export interface IMotionControllerLayoutMap {
  45238. /**
  45239. * Layouts with handness type as a key
  45240. */
  45241. [handness: string]: IMotionControllerLayout;
  45242. }
  45243. /**
  45244. * The XR Input profile schema
  45245. * Profiles can be found here:
  45246. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45247. */
  45248. export interface IMotionControllerProfile {
  45249. /**
  45250. * The id of this profile
  45251. * correlates to the profile(s) in the xrInput.profiles array
  45252. */
  45253. profileId: string;
  45254. /**
  45255. * fallback profiles for this profileId
  45256. */
  45257. fallbackProfileIds: string[];
  45258. /**
  45259. * The layout map, with handness as key
  45260. */
  45261. layouts: IMotionControllerLayoutMap;
  45262. }
  45263. /**
  45264. * A helper-interface for the 3 meshes needed for controller button animation
  45265. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45266. */
  45267. export interface IMotionControllerButtonMeshMap {
  45268. /**
  45269. * The mesh that will be changed when value changes
  45270. */
  45271. valueMesh: AbstractMesh;
  45272. /**
  45273. * the mesh that defines the pressed value mesh position.
  45274. * This is used to find the max-position of this button
  45275. */
  45276. pressedMesh: AbstractMesh;
  45277. /**
  45278. * the mesh that defines the unpressed value mesh position.
  45279. * This is used to find the min (or initial) position of this button
  45280. */
  45281. unpressedMesh: AbstractMesh;
  45282. }
  45283. /**
  45284. * A helper-interface for the 3 meshes needed for controller axis animation.
  45285. * This will be expanded when touchpad animations are fully supported
  45286. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45287. */
  45288. export interface IMotionControllerMeshMap {
  45289. /**
  45290. * The mesh that will be changed when axis value changes
  45291. */
  45292. valueMesh: AbstractMesh;
  45293. /**
  45294. * the mesh that defines the minimum value mesh position.
  45295. */
  45296. minMesh?: AbstractMesh;
  45297. /**
  45298. * the mesh that defines the maximum value mesh position.
  45299. */
  45300. maxMesh?: AbstractMesh;
  45301. }
  45302. /**
  45303. * The elements needed for change-detection of the gamepad objects in motion controllers
  45304. */
  45305. export interface IMinimalMotionControllerObject {
  45306. /**
  45307. * An array of available buttons
  45308. */
  45309. buttons: Array<{
  45310. /**
  45311. * Value of the button/trigger
  45312. */
  45313. value: number;
  45314. /**
  45315. * If the button/trigger is currently touched
  45316. */
  45317. touched: boolean;
  45318. /**
  45319. * If the button/trigger is currently pressed
  45320. */
  45321. pressed: boolean;
  45322. }>;
  45323. /**
  45324. * Available axes of this controller
  45325. */
  45326. axes: number[];
  45327. }
  45328. /**
  45329. * An Abstract Motion controller
  45330. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45331. * Each component has an observable to check for changes in value and state
  45332. */
  45333. export abstract class WebXRAbstractMotionController implements IDisposable {
  45334. protected scene: Scene;
  45335. protected layout: IMotionControllerLayout;
  45336. /**
  45337. * The gamepad object correlating to this controller
  45338. */
  45339. gamepadObject: IMinimalMotionControllerObject;
  45340. /**
  45341. * handness (left/right/none) of this controller
  45342. */
  45343. handness: MotionControllerHandness;
  45344. /**
  45345. * The profile id of this motion controller
  45346. */
  45347. abstract profileId: string;
  45348. /**
  45349. * A map of components (WebXRControllerComponent) in this motion controller
  45350. * Components have a ComponentType and can also have both button and axis definitions
  45351. */
  45352. readonly components: {
  45353. [id: string]: WebXRControllerComponent;
  45354. };
  45355. /**
  45356. * Observers registered here will be triggered when the model of this controller is done loading
  45357. */
  45358. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45359. /**
  45360. * The root mesh of the model. It is null if the model was not yet initialized
  45361. */
  45362. rootMesh: Nullable<AbstractMesh>;
  45363. /**
  45364. * Disable the model's animation. Can be set at any time.
  45365. */
  45366. disableAnimation: boolean;
  45367. private _modelReady;
  45368. /**
  45369. * constructs a new abstract motion controller
  45370. * @param scene the scene to which the model of the controller will be added
  45371. * @param layout The profile layout to load
  45372. * @param gamepadObject The gamepad object correlating to this controller
  45373. * @param handness handness (left/right/none) of this controller
  45374. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45375. */
  45376. constructor(scene: Scene, layout: IMotionControllerLayout,
  45377. /**
  45378. * The gamepad object correlating to this controller
  45379. */
  45380. gamepadObject: IMinimalMotionControllerObject,
  45381. /**
  45382. * handness (left/right/none) of this controller
  45383. */
  45384. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45385. private _initComponent;
  45386. /**
  45387. * Update this model using the current XRFrame
  45388. * @param xrFrame the current xr frame to use and update the model
  45389. */
  45390. updateFromXRFrame(xrFrame: XRFrame): void;
  45391. /**
  45392. * Get the list of components available in this motion controller
  45393. * @returns an array of strings correlating to available components
  45394. */
  45395. getComponentIds(): string[];
  45396. /**
  45397. * Get the main (Select) component of this controller as defined in the layout
  45398. * @returns the main component of this controller
  45399. */
  45400. getMainComponent(): WebXRControllerComponent;
  45401. /**
  45402. * get a component based an its component id as defined in layout.components
  45403. * @param id the id of the component
  45404. * @returns the component correlates to the id or undefined if not found
  45405. */
  45406. getComponent(id: string): WebXRControllerComponent;
  45407. /**
  45408. * Get the first component of specific type
  45409. * @param type type of component to find
  45410. * @return a controller component or null if not found
  45411. */
  45412. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45413. /**
  45414. * Returns all components of specific type
  45415. * @param type the type to search for
  45416. * @return an array of components with this type
  45417. */
  45418. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45419. /**
  45420. * Loads the model correlating to this controller
  45421. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45422. * @returns A promise fulfilled with the result of the model loading
  45423. */
  45424. loadModel(): Promise<boolean>;
  45425. /**
  45426. * Update the model itself with the current frame data
  45427. * @param xrFrame the frame to use for updating the model mesh
  45428. */
  45429. protected updateModel(xrFrame: XRFrame): void;
  45430. /**
  45431. * Moves the axis on the controller mesh based on its current state
  45432. * @param axis the index of the axis
  45433. * @param axisValue the value of the axis which determines the meshes new position
  45434. * @hidden
  45435. */
  45436. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45437. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45438. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45439. private _getGenericFilenameAndPath;
  45440. private _getGenericParentMesh;
  45441. /**
  45442. * Get the filename and path for this controller's model
  45443. * @returns a map of filename and path
  45444. */
  45445. protected abstract _getFilenameAndPath(): {
  45446. filename: string;
  45447. path: string;
  45448. };
  45449. /**
  45450. * This function will be called after the model was successfully loaded and can be used
  45451. * for mesh transformations before it is available for the user
  45452. * @param meshes the loaded meshes
  45453. */
  45454. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45455. /**
  45456. * Set the root mesh for this controller. Important for the WebXR controller class
  45457. * @param meshes the loaded meshes
  45458. */
  45459. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45460. /**
  45461. * A function executed each frame that updates the mesh (if needed)
  45462. * @param xrFrame the current xrFrame
  45463. */
  45464. protected abstract _updateModel(xrFrame: XRFrame): void;
  45465. /**
  45466. * This function is called before the mesh is loaded. It checks for loading constraints.
  45467. * For example, this function can check if the GLB loader is available
  45468. * If this function returns false, the generic controller will be loaded instead
  45469. * @returns Is the client ready to load the mesh
  45470. */
  45471. protected abstract _getModelLoadingConstraints(): boolean;
  45472. /**
  45473. * Dispose this controller, the model mesh and all its components
  45474. */
  45475. dispose(): void;
  45476. }
  45477. }
  45478. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45479. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45481. import { Scene } from "babylonjs/scene";
  45482. /**
  45483. * A generic trigger-only motion controller for WebXR
  45484. */
  45485. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45486. /**
  45487. * Static version of the profile id of this controller
  45488. */
  45489. static ProfileId: string;
  45490. profileId: string;
  45491. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45492. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45493. protected _updateModel(): void;
  45494. protected _getFilenameAndPath(): {
  45495. filename: string;
  45496. path: string;
  45497. };
  45498. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45499. protected _getModelLoadingConstraints(): boolean;
  45500. }
  45501. }
  45502. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45503. import { Vector4 } from "babylonjs/Maths/math.vector";
  45504. import { Mesh } from "babylonjs/Meshes/mesh";
  45505. import { Scene } from "babylonjs/scene";
  45506. import { Nullable } from "babylonjs/types";
  45507. /**
  45508. * Class containing static functions to help procedurally build meshes
  45509. */
  45510. export class SphereBuilder {
  45511. /**
  45512. * Creates a sphere mesh
  45513. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45514. * * 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`)
  45515. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45516. * * 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
  45517. * * 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)
  45518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45521. * @param name defines the name of the mesh
  45522. * @param options defines the options used to create the mesh
  45523. * @param scene defines the hosting scene
  45524. * @returns the sphere mesh
  45525. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45526. */
  45527. static CreateSphere(name: string, options: {
  45528. segments?: number;
  45529. diameter?: number;
  45530. diameterX?: number;
  45531. diameterY?: number;
  45532. diameterZ?: number;
  45533. arc?: number;
  45534. slice?: number;
  45535. sideOrientation?: number;
  45536. frontUVs?: Vector4;
  45537. backUVs?: Vector4;
  45538. updatable?: boolean;
  45539. }, scene?: Nullable<Scene>): Mesh;
  45540. }
  45541. }
  45542. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45544. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45545. import { Scene } from "babylonjs/scene";
  45546. /**
  45547. * A profiled motion controller has its profile loaded from an online repository.
  45548. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45549. */
  45550. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45551. private _repositoryUrl;
  45552. /**
  45553. * The profile ID of this controller. Will be populated when the controller initializes.
  45554. */
  45555. profileId: string;
  45556. private _buttonMeshMapping;
  45557. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45558. protected _getFilenameAndPath(): {
  45559. filename: string;
  45560. path: string;
  45561. };
  45562. private _touchDots;
  45563. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45564. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45565. protected _updateModel(_xrFrame: XRFrame): void;
  45566. protected _getModelLoadingConstraints(): boolean;
  45567. dispose(): void;
  45568. }
  45569. }
  45570. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45571. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45572. import { Scene } from "babylonjs/scene";
  45573. /**
  45574. * A construction function type to create a new controller based on an xrInput object
  45575. */
  45576. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45577. /**
  45578. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45579. *
  45580. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45581. * it should be replaced with auto-loaded controllers.
  45582. *
  45583. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45584. */
  45585. export class WebXRMotionControllerManager {
  45586. /**
  45587. * The base URL of the online controller repository. Can be changed at any time.
  45588. */
  45589. static BaseRepositoryUrl: string;
  45590. /**
  45591. * Use the online repository, or use only locally-defined controllers
  45592. */
  45593. static UseOnlineRepository: boolean;
  45594. /**
  45595. * Which repository gets priority - local or online
  45596. */
  45597. static PrioritizeOnlineRepository: boolean;
  45598. private static _AvailableControllers;
  45599. private static _Fallbacks;
  45600. /**
  45601. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45602. *
  45603. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45604. *
  45605. * @param type the profile type to register
  45606. * @param constructFunction the function to be called when loading this profile
  45607. */
  45608. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45609. /**
  45610. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45611. * The order of search:
  45612. *
  45613. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45614. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45615. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45616. * 4) return the generic trigger controller if none were found
  45617. *
  45618. * @param xrInput the xrInput to which a new controller is initialized
  45619. * @param scene the scene to which the model will be added
  45620. * @param forceProfile force a certain profile for this controller
  45621. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45622. */
  45623. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45624. private static _LoadProfilesFromAvailableControllers;
  45625. private static _ProfilesList;
  45626. private static _ProfileLoadingPromises;
  45627. private static _LoadProfileFromRepository;
  45628. /**
  45629. * Clear the cache used for profile loading and reload when requested again
  45630. */
  45631. static ClearProfilesCache(): void;
  45632. /**
  45633. * Will update the list of profiles available in the repository
  45634. * @return a promise that resolves to a map of profiles available online
  45635. */
  45636. static UpdateProfilesList(): Promise<{
  45637. [profile: string]: string;
  45638. }>;
  45639. /**
  45640. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45641. * @param profileId the profile to which a fallback needs to be found
  45642. * @return an array with corresponding fallback profiles
  45643. */
  45644. static FindFallbackWithProfileId(profileId: string): string[];
  45645. /**
  45646. * Register a fallback to a specific profile.
  45647. * @param profileId the profileId that will receive the fallbacks
  45648. * @param fallbacks A list of fallback profiles
  45649. */
  45650. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45651. /**
  45652. * Register the default fallbacks.
  45653. * This function is called automatically when this file is imported.
  45654. */
  45655. static DefaultFallbacks(): void;
  45656. }
  45657. }
  45658. declare module "babylonjs/XR/webXRInputSource" {
  45659. import { Observable } from "babylonjs/Misc/observable";
  45660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45661. import { Ray } from "babylonjs/Culling/ray";
  45662. import { Scene } from "babylonjs/scene";
  45663. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45664. /**
  45665. * Configuration options for the WebXR controller creation
  45666. */
  45667. export interface IWebXRControllerOptions {
  45668. /**
  45669. * Force a specific controller type for this controller.
  45670. * This can be used when creating your own profile or when testing different controllers
  45671. */
  45672. forceControllerProfile?: string;
  45673. /**
  45674. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45675. */
  45676. doNotLoadControllerMesh?: boolean;
  45677. /**
  45678. * Should the controller mesh be animated when a user interacts with it
  45679. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45680. */
  45681. disableMotionControllerAnimation?: boolean;
  45682. }
  45683. /**
  45684. * Represents an XR controller
  45685. */
  45686. export class WebXRInputSource {
  45687. private _scene;
  45688. /** The underlying input source for the controller */
  45689. inputSource: XRInputSource;
  45690. private _options;
  45691. /**
  45692. * 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
  45693. */
  45694. grip?: AbstractMesh;
  45695. /**
  45696. * Pointer which can be used to select objects or attach a visible laser to
  45697. */
  45698. pointer: AbstractMesh;
  45699. /**
  45700. * If available, this is the gamepad object related to this controller.
  45701. * Using this object it is possible to get click events and trackpad changes of the
  45702. * webxr controller that is currently being used.
  45703. */
  45704. motionController?: WebXRAbstractMotionController;
  45705. /**
  45706. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45707. */
  45708. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45709. /**
  45710. * Will be triggered when the mesh associated with the motion controller is done loading.
  45711. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45712. * A shortened version of controller -> motion controller -> on mesh loaded.
  45713. */
  45714. onMeshLoadedObservable: Observable<AbstractMesh>;
  45715. /**
  45716. * Event that fires when the controller is removed/disposed.
  45717. * The object provided as event data is this controller, after associated assets were disposed.
  45718. * uniqueId is still available.
  45719. */
  45720. onDisposeObservable: Observable<WebXRInputSource>;
  45721. private _tmpQuaternion;
  45722. private _tmpVector;
  45723. private _uniqueId;
  45724. /**
  45725. * Creates the controller
  45726. * @see https://doc.babylonjs.com/how_to/webxr
  45727. * @param _scene the scene which the controller should be associated to
  45728. * @param inputSource the underlying input source for the controller
  45729. * @param _options options for this controller creation
  45730. */
  45731. constructor(_scene: Scene,
  45732. /** The underlying input source for the controller */
  45733. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45734. /**
  45735. * Get this controllers unique id
  45736. */
  45737. get uniqueId(): string;
  45738. /**
  45739. * Updates the controller pose based on the given XRFrame
  45740. * @param xrFrame xr frame to update the pose with
  45741. * @param referenceSpace reference space to use
  45742. */
  45743. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45744. /**
  45745. * Gets a world space ray coming from the pointer or grip
  45746. * @param result the resulting ray
  45747. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45748. */
  45749. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45750. /**
  45751. * Disposes of the object
  45752. */
  45753. dispose(): void;
  45754. }
  45755. }
  45756. declare module "babylonjs/XR/webXRInput" {
  45757. import { Observable } from "babylonjs/Misc/observable";
  45758. import { IDisposable } from "babylonjs/scene";
  45759. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45760. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45761. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45762. /**
  45763. * The schema for initialization options of the XR Input class
  45764. */
  45765. export interface IWebXRInputOptions {
  45766. /**
  45767. * If set to true no model will be automatically loaded
  45768. */
  45769. doNotLoadControllerMeshes?: boolean;
  45770. /**
  45771. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45772. * If not found, the xr input profile data will be used.
  45773. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45774. */
  45775. forceInputProfile?: string;
  45776. /**
  45777. * Do not send a request to the controlle repository to load the profile.
  45778. *
  45779. * Instead, use the controllers available in babylon itself.
  45780. */
  45781. disableOnlineControllerRepository?: boolean;
  45782. /**
  45783. * A custom URL for the controllers repository
  45784. */
  45785. customControllersRepositoryURL?: string;
  45786. /**
  45787. * Should the controller model's components not move according to the user input
  45788. */
  45789. disableControllerAnimation?: boolean;
  45790. }
  45791. /**
  45792. * XR input used to track XR inputs such as controllers/rays
  45793. */
  45794. export class WebXRInput implements IDisposable {
  45795. /**
  45796. * the xr session manager for this session
  45797. */
  45798. xrSessionManager: WebXRSessionManager;
  45799. /**
  45800. * the WebXR camera for this session. Mainly used for teleportation
  45801. */
  45802. xrCamera: WebXRCamera;
  45803. private readonly options;
  45804. /**
  45805. * XR controllers being tracked
  45806. */
  45807. controllers: Array<WebXRInputSource>;
  45808. private _frameObserver;
  45809. private _sessionEndedObserver;
  45810. private _sessionInitObserver;
  45811. /**
  45812. * Event when a controller has been connected/added
  45813. */
  45814. onControllerAddedObservable: Observable<WebXRInputSource>;
  45815. /**
  45816. * Event when a controller has been removed/disconnected
  45817. */
  45818. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45819. /**
  45820. * Initializes the WebXRInput
  45821. * @param xrSessionManager the xr session manager for this session
  45822. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45823. * @param options = initialization options for this xr input
  45824. */
  45825. constructor(
  45826. /**
  45827. * the xr session manager for this session
  45828. */
  45829. xrSessionManager: WebXRSessionManager,
  45830. /**
  45831. * the WebXR camera for this session. Mainly used for teleportation
  45832. */
  45833. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45834. private _onInputSourcesChange;
  45835. private _addAndRemoveControllers;
  45836. /**
  45837. * Disposes of the object
  45838. */
  45839. dispose(): void;
  45840. }
  45841. }
  45842. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45843. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45844. import { Observable, EventState } from "babylonjs/Misc/observable";
  45845. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45846. /**
  45847. * This is the base class for all WebXR features.
  45848. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45849. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45850. */
  45851. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45852. protected _xrSessionManager: WebXRSessionManager;
  45853. /**
  45854. * Construct a new (abstract) webxr feature
  45855. * @param _xrSessionManager the xr session manager for this feature
  45856. */
  45857. constructor(_xrSessionManager: WebXRSessionManager);
  45858. private _attached;
  45859. private _removeOnDetach;
  45860. /**
  45861. * Is this feature attached
  45862. */
  45863. get attached(): boolean;
  45864. /**
  45865. * Should auto-attach be disabled?
  45866. */
  45867. disableAutoAttach: boolean;
  45868. /**
  45869. * attach this feature
  45870. *
  45871. * @param force should attachment be forced (even when already attached)
  45872. * @returns true if successful, false is failed or already attached
  45873. */
  45874. attach(force?: boolean): boolean;
  45875. /**
  45876. * detach this feature.
  45877. *
  45878. * @returns true if successful, false if failed or already detached
  45879. */
  45880. detach(): boolean;
  45881. /**
  45882. * Dispose this feature and all of the resources attached
  45883. */
  45884. dispose(): void;
  45885. /**
  45886. * Code in this function will be executed on each xrFrame received from the browser.
  45887. * This function will not execute after the feature is detached.
  45888. * @param _xrFrame the current frame
  45889. */
  45890. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45891. /**
  45892. * This is used to register callbacks that will automatically be removed when detach is called.
  45893. * @param observable the observable to which the observer will be attached
  45894. * @param callback the callback to register
  45895. */
  45896. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45897. }
  45898. }
  45899. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45900. import { IDisposable, Scene } from "babylonjs/scene";
  45901. import { Nullable } from "babylonjs/types";
  45902. import { Observable } from "babylonjs/Misc/observable";
  45903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45904. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45905. import { Camera } from "babylonjs/Cameras/camera";
  45906. /**
  45907. * Renders a layer on top of an existing scene
  45908. */
  45909. export class UtilityLayerRenderer implements IDisposable {
  45910. /** the original scene that will be rendered on top of */
  45911. originalScene: Scene;
  45912. private _pointerCaptures;
  45913. private _lastPointerEvents;
  45914. private static _DefaultUtilityLayer;
  45915. private static _DefaultKeepDepthUtilityLayer;
  45916. private _sharedGizmoLight;
  45917. private _renderCamera;
  45918. /**
  45919. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45920. * @returns the camera that is used when rendering the utility layer
  45921. */
  45922. getRenderCamera(): Camera;
  45923. /**
  45924. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45925. * @param cam the camera that should be used when rendering the utility layer
  45926. */
  45927. setRenderCamera(cam: Nullable<Camera>): void;
  45928. /**
  45929. * @hidden
  45930. * Light which used by gizmos to get light shading
  45931. */
  45932. _getSharedGizmoLight(): HemisphericLight;
  45933. /**
  45934. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45935. */
  45936. pickUtilitySceneFirst: boolean;
  45937. /**
  45938. * 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)
  45939. */
  45940. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45941. /**
  45942. * 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)
  45943. */
  45944. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45945. /**
  45946. * The scene that is rendered on top of the original scene
  45947. */
  45948. utilityLayerScene: Scene;
  45949. /**
  45950. * If the utility layer should automatically be rendered on top of existing scene
  45951. */
  45952. shouldRender: boolean;
  45953. /**
  45954. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45955. */
  45956. onlyCheckPointerDownEvents: boolean;
  45957. /**
  45958. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45959. */
  45960. processAllEvents: boolean;
  45961. /**
  45962. * Observable raised when the pointer move from the utility layer scene to the main scene
  45963. */
  45964. onPointerOutObservable: Observable<number>;
  45965. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45966. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45967. private _afterRenderObserver;
  45968. private _sceneDisposeObserver;
  45969. private _originalPointerObserver;
  45970. /**
  45971. * Instantiates a UtilityLayerRenderer
  45972. * @param originalScene the original scene that will be rendered on top of
  45973. * @param handleEvents boolean indicating if the utility layer should handle events
  45974. */
  45975. constructor(
  45976. /** the original scene that will be rendered on top of */
  45977. originalScene: Scene, handleEvents?: boolean);
  45978. private _notifyObservers;
  45979. /**
  45980. * Renders the utility layers scene on top of the original scene
  45981. */
  45982. render(): void;
  45983. /**
  45984. * Disposes of the renderer
  45985. */
  45986. dispose(): void;
  45987. private _updateCamera;
  45988. }
  45989. }
  45990. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45991. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45992. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45993. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45994. import { Scene } from "babylonjs/scene";
  45995. import { Nullable } from "babylonjs/types";
  45996. import { Color3 } from "babylonjs/Maths/math.color";
  45997. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45998. /**
  45999. * Options interface for the pointer selection module
  46000. */
  46001. export interface IWebXRControllerPointerSelectionOptions {
  46002. /**
  46003. * the xr input to use with this pointer selection
  46004. */
  46005. xrInput: WebXRInput;
  46006. /**
  46007. * Different button type to use instead of the main component
  46008. */
  46009. overrideButtonId?: string;
  46010. /**
  46011. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46012. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46013. * 3000 means 3 seconds between pointing at something and selecting it
  46014. */
  46015. timeToSelect?: number;
  46016. /**
  46017. * 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)
  46018. * If not disabled, the last picked point will be used to execute a pointer up event
  46019. * If disabled, pointer up event will be triggered right after the pointer down event.
  46020. * Used in screen and gaze target ray mode only
  46021. */
  46022. disablePointerUpOnTouchOut: boolean;
  46023. /**
  46024. * For gaze mode (time to select instead of press)
  46025. */
  46026. forceGazeMode: boolean;
  46027. /**
  46028. * 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
  46029. * to start a new countdown to the pointer down event.
  46030. * Defaults to 1.
  46031. */
  46032. gazeModePointerMovedFactor?: number;
  46033. /**
  46034. * Should meshes created here be added to a utility layer or the main scene
  46035. */
  46036. useUtilityLayer?: boolean;
  46037. /**
  46038. * if provided, this scene will be used to render meshes.
  46039. */
  46040. customUtilityLayerScene?: Scene;
  46041. }
  46042. /**
  46043. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46044. */
  46045. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46046. private readonly _options;
  46047. /**
  46048. * The module's name
  46049. */
  46050. static readonly Name: string;
  46051. /**
  46052. * The (Babylon) version of this module.
  46053. * This is an integer representing the implementation version.
  46054. * This number does not correspond to the webxr specs version
  46055. */
  46056. static readonly Version: number;
  46057. /**
  46058. * This color will be set to the laser pointer when selection is triggered
  46059. */
  46060. laserPointerPickedColor: Color3;
  46061. /**
  46062. * This color will be applied to the selection ring when selection is triggered
  46063. */
  46064. selectionMeshPickedColor: Color3;
  46065. /**
  46066. * default color of the selection ring
  46067. */
  46068. selectionMeshDefaultColor: Color3;
  46069. /**
  46070. * Default color of the laser pointer
  46071. */
  46072. lasterPointerDefaultColor: Color3;
  46073. /**
  46074. * Should the laser pointer be displayed
  46075. */
  46076. displayLaserPointer: boolean;
  46077. /**
  46078. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46079. */
  46080. displaySelectionMesh: boolean;
  46081. /**
  46082. * Disable lighting on the laser pointer (so it will always be visible)
  46083. */
  46084. disablePointerLighting: boolean;
  46085. /**
  46086. * Disable lighting on the selection mesh (so it will always be visible)
  46087. */
  46088. disableSelectionMeshLighting: boolean;
  46089. private static _idCounter;
  46090. private _tmpRay;
  46091. private _controllers;
  46092. private _scene;
  46093. /**
  46094. * constructs a new background remover module
  46095. * @param _xrSessionManager the session manager for this module
  46096. * @param _options read-only options to be used in this module
  46097. */
  46098. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46099. /**
  46100. * attach this feature
  46101. * Will usually be called by the features manager
  46102. *
  46103. * @returns true if successful.
  46104. */
  46105. attach(): boolean;
  46106. /**
  46107. * detach this feature.
  46108. * Will usually be called by the features manager
  46109. *
  46110. * @returns true if successful.
  46111. */
  46112. detach(): boolean;
  46113. /**
  46114. * Get the xr controller that correlates to the pointer id in the pointer event
  46115. *
  46116. * @param id the pointer id to search for
  46117. * @returns the controller that correlates to this id or null if not found
  46118. */
  46119. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46120. protected _onXRFrame(_xrFrame: XRFrame): void;
  46121. private _attachController;
  46122. private _attachScreenRayMode;
  46123. private _attachGazeMode;
  46124. private _tmpVectorForPickCompare;
  46125. private _pickingMoved;
  46126. private _attachTrackedPointerRayMode;
  46127. private _detachController;
  46128. private _generateNewMeshPair;
  46129. private _convertNormalToDirectionOfRay;
  46130. private _updatePointerDistance;
  46131. }
  46132. }
  46133. declare module "babylonjs/XR/webXREnterExitUI" {
  46134. import { Nullable } from "babylonjs/types";
  46135. import { Observable } from "babylonjs/Misc/observable";
  46136. import { IDisposable, Scene } from "babylonjs/scene";
  46137. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46138. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46139. /**
  46140. * Button which can be used to enter a different mode of XR
  46141. */
  46142. export class WebXREnterExitUIButton {
  46143. /** button element */
  46144. element: HTMLElement;
  46145. /** XR initialization options for the button */
  46146. sessionMode: XRSessionMode;
  46147. /** Reference space type */
  46148. referenceSpaceType: XRReferenceSpaceType;
  46149. /**
  46150. * Creates a WebXREnterExitUIButton
  46151. * @param element button element
  46152. * @param sessionMode XR initialization session mode
  46153. * @param referenceSpaceType the type of reference space to be used
  46154. */
  46155. constructor(
  46156. /** button element */
  46157. element: HTMLElement,
  46158. /** XR initialization options for the button */
  46159. sessionMode: XRSessionMode,
  46160. /** Reference space type */
  46161. referenceSpaceType: XRReferenceSpaceType);
  46162. /**
  46163. * Overwritable function which can be used to update the button's visuals when the state changes
  46164. * @param activeButton the current active button in the UI
  46165. */
  46166. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46167. }
  46168. /**
  46169. * Options to create the webXR UI
  46170. */
  46171. export class WebXREnterExitUIOptions {
  46172. /**
  46173. * Context to enter xr with
  46174. */
  46175. renderTarget?: Nullable<WebXRRenderTarget>;
  46176. /**
  46177. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46178. */
  46179. customButtons?: Array<WebXREnterExitUIButton>;
  46180. /**
  46181. * A session mode to use when creating the default button.
  46182. * Default is immersive-vr
  46183. */
  46184. sessionMode?: XRSessionMode;
  46185. /**
  46186. * A reference space type to use when creating the default button.
  46187. * Default is local-floor
  46188. */
  46189. referenceSpaceType?: XRReferenceSpaceType;
  46190. }
  46191. /**
  46192. * UI to allow the user to enter/exit XR mode
  46193. */
  46194. export class WebXREnterExitUI implements IDisposable {
  46195. private scene;
  46196. /** version of the options passed to this UI */
  46197. options: WebXREnterExitUIOptions;
  46198. private _overlay;
  46199. private _buttons;
  46200. private _activeButton;
  46201. /**
  46202. * Fired every time the active button is changed.
  46203. *
  46204. * When xr is entered via a button that launches xr that button will be the callback parameter
  46205. *
  46206. * When exiting xr the callback parameter will be null)
  46207. */
  46208. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46209. /**
  46210. * Creates UI to allow the user to enter/exit XR mode
  46211. * @param scene the scene to add the ui to
  46212. * @param helper the xr experience helper to enter/exit xr with
  46213. * @param options options to configure the UI
  46214. * @returns the created ui
  46215. */
  46216. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46217. /**
  46218. *
  46219. * @param scene babylon scene object to use
  46220. * @param options (read-only) version of the options passed to this UI
  46221. */
  46222. private constructor();
  46223. private _updateButtons;
  46224. /**
  46225. * Disposes of the object
  46226. */
  46227. dispose(): void;
  46228. }
  46229. }
  46230. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46231. import { Vector3 } from "babylonjs/Maths/math.vector";
  46232. import { Color4 } from "babylonjs/Maths/math.color";
  46233. import { Nullable } from "babylonjs/types";
  46234. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46235. import { Scene } from "babylonjs/scene";
  46236. /**
  46237. * Class containing static functions to help procedurally build meshes
  46238. */
  46239. export class LinesBuilder {
  46240. /**
  46241. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46242. * * 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
  46243. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46244. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46245. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46246. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46247. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46248. * * 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
  46249. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46252. * @param name defines the name of the new line system
  46253. * @param options defines the options used to create the line system
  46254. * @param scene defines the hosting scene
  46255. * @returns a new line system mesh
  46256. */
  46257. static CreateLineSystem(name: string, options: {
  46258. lines: Vector3[][];
  46259. updatable?: boolean;
  46260. instance?: Nullable<LinesMesh>;
  46261. colors?: Nullable<Color4[][]>;
  46262. useVertexAlpha?: boolean;
  46263. }, scene: Nullable<Scene>): LinesMesh;
  46264. /**
  46265. * Creates a line mesh
  46266. * 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
  46267. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46268. * * The parameter `points` is an array successive Vector3
  46269. * * 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
  46270. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46271. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46272. * * When updating an instance, remember that only point positions can change, not the number of points
  46273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46274. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46275. * @param name defines the name of the new line system
  46276. * @param options defines the options used to create the line system
  46277. * @param scene defines the hosting scene
  46278. * @returns a new line mesh
  46279. */
  46280. static CreateLines(name: string, options: {
  46281. points: Vector3[];
  46282. updatable?: boolean;
  46283. instance?: Nullable<LinesMesh>;
  46284. colors?: Color4[];
  46285. useVertexAlpha?: boolean;
  46286. }, scene?: Nullable<Scene>): LinesMesh;
  46287. /**
  46288. * Creates a dashed line mesh
  46289. * * 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
  46290. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46291. * * The parameter `points` is an array successive Vector3
  46292. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46293. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46294. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46295. * * 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
  46296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46297. * * When updating an instance, remember that only point positions can change, not the number of points
  46298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46299. * @param name defines the name of the mesh
  46300. * @param options defines the options used to create the mesh
  46301. * @param scene defines the hosting scene
  46302. * @returns the dashed line mesh
  46303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46304. */
  46305. static CreateDashedLines(name: string, options: {
  46306. points: Vector3[];
  46307. dashSize?: number;
  46308. gapSize?: number;
  46309. dashNb?: number;
  46310. updatable?: boolean;
  46311. instance?: LinesMesh;
  46312. useVertexAlpha?: boolean;
  46313. }, scene?: Nullable<Scene>): LinesMesh;
  46314. }
  46315. }
  46316. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46317. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46318. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46319. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46321. import { Material } from "babylonjs/Materials/material";
  46322. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46323. import { Scene } from "babylonjs/scene";
  46324. /**
  46325. * The options container for the teleportation module
  46326. */
  46327. export interface IWebXRTeleportationOptions {
  46328. /**
  46329. * Babylon XR Input class for controller
  46330. */
  46331. xrInput: WebXRInput;
  46332. /**
  46333. * A list of meshes to use as floor meshes.
  46334. * Meshes can be added and removed after initializing the feature using the
  46335. * addFloorMesh and removeFloorMesh functions
  46336. * If empty, rotation will still work
  46337. */
  46338. floorMeshes?: AbstractMesh[];
  46339. /**
  46340. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46341. * If you want to support rotation, make sure your mesh has a direction indicator.
  46342. *
  46343. * When left untouched, the default mesh will be initialized.
  46344. */
  46345. teleportationTargetMesh?: AbstractMesh;
  46346. /**
  46347. * Values to configure the default target mesh
  46348. */
  46349. defaultTargetMeshOptions?: {
  46350. /**
  46351. * Fill color of the teleportation area
  46352. */
  46353. teleportationFillColor?: string;
  46354. /**
  46355. * Border color for the teleportation area
  46356. */
  46357. teleportationBorderColor?: string;
  46358. /**
  46359. * Disable the mesh's animation sequence
  46360. */
  46361. disableAnimation?: boolean;
  46362. /**
  46363. * Disable lighting on the material or the ring and arrow
  46364. */
  46365. disableLighting?: boolean;
  46366. /**
  46367. * Override the default material of the torus and arrow
  46368. */
  46369. torusArrowMaterial?: Material;
  46370. };
  46371. /**
  46372. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46373. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46374. */
  46375. useMainComponentOnly?: boolean;
  46376. /**
  46377. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46378. */
  46379. timeToTeleport?: number;
  46380. /**
  46381. * Should meshes created here be added to a utility layer or the main scene
  46382. */
  46383. useUtilityLayer?: boolean;
  46384. /**
  46385. * if provided, this scene will be used to render meshes.
  46386. */
  46387. customUtilityLayerScene?: Scene;
  46388. }
  46389. /**
  46390. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46391. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  46392. * the input of the attached controllers.
  46393. */
  46394. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46395. private _options;
  46396. /**
  46397. * The module's name
  46398. */
  46399. static readonly Name: string;
  46400. /**
  46401. * The (Babylon) version of this module.
  46402. * This is an integer representing the implementation version.
  46403. * This number does not correspond to the webxr specs version
  46404. */
  46405. static readonly Version: number;
  46406. /**
  46407. * Is rotation enabled when moving forward?
  46408. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46409. */
  46410. rotationEnabled: boolean;
  46411. /**
  46412. * Should the module support parabolic ray on top of direct ray
  46413. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46414. * Very helpful when moving between floors / different heights
  46415. */
  46416. parabolicRayEnabled: boolean;
  46417. /**
  46418. * The distance from the user to the inspection point in the direction of the controller
  46419. * A higher number will allow the user to move further
  46420. * defaults to 5 (meters, in xr units)
  46421. */
  46422. parabolicCheckRadius: number;
  46423. /**
  46424. * How much rotation should be applied when rotating right and left
  46425. */
  46426. rotationAngle: number;
  46427. /**
  46428. * Is movement backwards enabled
  46429. */
  46430. backwardsMovementEnabled: boolean;
  46431. /**
  46432. * Distance to travel when moving backwards
  46433. */
  46434. backwardsTeleportationDistance: number;
  46435. /**
  46436. * Add a new mesh to the floor meshes array
  46437. * @param mesh the mesh to use as floor mesh
  46438. */
  46439. addFloorMesh(mesh: AbstractMesh): void;
  46440. /**
  46441. * Remove a mesh from the floor meshes array
  46442. * @param mesh the mesh to remove
  46443. */
  46444. removeFloorMesh(mesh: AbstractMesh): void;
  46445. /**
  46446. * Remove a mesh from the floor meshes array using its name
  46447. * @param name the mesh name to remove
  46448. */
  46449. removeFloorMeshByName(name: string): void;
  46450. private _tmpRay;
  46451. private _tmpVector;
  46452. private _floorMeshes;
  46453. private _controllers;
  46454. /**
  46455. * constructs a new anchor system
  46456. * @param _xrSessionManager an instance of WebXRSessionManager
  46457. * @param _options configuration object for this feature
  46458. */
  46459. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46460. private _selectionFeature;
  46461. /**
  46462. * This function sets a selection feature that will be disabled when
  46463. * the forward ray is shown and will be reattached when hidden.
  46464. * This is used to remove the selection rays when moving.
  46465. * @param selectionFeature the feature to disable when forward movement is enabled
  46466. */
  46467. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46468. attach(): boolean;
  46469. detach(): boolean;
  46470. dispose(): void;
  46471. protected _onXRFrame(_xrFrame: XRFrame): void;
  46472. private _currentTeleportationControllerId;
  46473. private _attachController;
  46474. private _teleportForward;
  46475. private _detachController;
  46476. private createDefaultTargetMesh;
  46477. private setTargetMeshVisibility;
  46478. private setTargetMeshPosition;
  46479. private _quadraticBezierCurve;
  46480. private _showParabolicPath;
  46481. }
  46482. }
  46483. declare module "babylonjs/XR/webXRDefaultExperience" {
  46484. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46485. import { Scene } from "babylonjs/scene";
  46486. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46487. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46488. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46489. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46491. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46492. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46493. /**
  46494. * Options for the default xr helper
  46495. */
  46496. export class WebXRDefaultExperienceOptions {
  46497. /**
  46498. * Floor meshes that will be used for teleporting
  46499. */
  46500. floorMeshes?: Array<AbstractMesh>;
  46501. /**
  46502. * Enable or disable default UI to enter XR
  46503. */
  46504. disableDefaultUI?: boolean;
  46505. /**
  46506. * optional configuration for the output canvas
  46507. */
  46508. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46509. /**
  46510. * optional UI options. This can be used among other to change session mode and reference space type
  46511. */
  46512. uiOptions?: WebXREnterExitUIOptions;
  46513. /**
  46514. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46515. */
  46516. inputOptions?: IWebXRInputOptions;
  46517. /**
  46518. * Should teleportation not initialize. defaults to false.
  46519. */
  46520. disableTeleportation?: boolean;
  46521. /**
  46522. * If set to true, the first frame will not be used to reset position
  46523. * The first frame is mainly used when copying transformation from the old camera
  46524. * Mainly used in AR
  46525. */
  46526. ignoreNativeCameraTransformation?: boolean;
  46527. /**
  46528. * When loading teleportation and pointer select, use stable versions instead of latest.
  46529. */
  46530. useStablePlugins?: boolean;
  46531. }
  46532. /**
  46533. * Default experience which provides a similar setup to the previous webVRExperience
  46534. */
  46535. export class WebXRDefaultExperience {
  46536. /**
  46537. * Base experience
  46538. */
  46539. baseExperience: WebXRExperienceHelper;
  46540. /**
  46541. * Input experience extension
  46542. */
  46543. input: WebXRInput;
  46544. /**
  46545. * Enables laser pointer and selection
  46546. */
  46547. pointerSelection: WebXRControllerPointerSelection;
  46548. /**
  46549. * Enables teleportation
  46550. */
  46551. teleportation: WebXRMotionControllerTeleportation;
  46552. /**
  46553. * Enables ui for entering/exiting xr
  46554. */
  46555. enterExitUI: WebXREnterExitUI;
  46556. /**
  46557. * Default target xr should render to
  46558. */
  46559. renderTarget: WebXRRenderTarget;
  46560. /**
  46561. * Creates the default xr experience
  46562. * @param scene scene
  46563. * @param options options for basic configuration
  46564. * @returns resulting WebXRDefaultExperience
  46565. */
  46566. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46567. private constructor();
  46568. /**
  46569. * DIsposes of the experience helper
  46570. */
  46571. dispose(): void;
  46572. }
  46573. }
  46574. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46575. import { Observable } from "babylonjs/Misc/observable";
  46576. import { Nullable } from "babylonjs/types";
  46577. import { Camera } from "babylonjs/Cameras/camera";
  46578. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46579. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46580. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46581. import { Scene } from "babylonjs/scene";
  46582. import { Vector3 } from "babylonjs/Maths/math.vector";
  46583. import { Color3 } from "babylonjs/Maths/math.color";
  46584. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46586. import { Mesh } from "babylonjs/Meshes/mesh";
  46587. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46588. import { EasingFunction } from "babylonjs/Animations/easing";
  46589. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46590. import "babylonjs/Meshes/Builders/groundBuilder";
  46591. import "babylonjs/Meshes/Builders/torusBuilder";
  46592. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46593. import "babylonjs/Gamepads/gamepadSceneComponent";
  46594. import "babylonjs/Animations/animatable";
  46595. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46596. /**
  46597. * Options to modify the vr teleportation behavior.
  46598. */
  46599. export interface VRTeleportationOptions {
  46600. /**
  46601. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46602. */
  46603. floorMeshName?: string;
  46604. /**
  46605. * A list of meshes to be used as the teleportation floor. (default: empty)
  46606. */
  46607. floorMeshes?: Mesh[];
  46608. /**
  46609. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46610. */
  46611. teleportationMode?: number;
  46612. /**
  46613. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46614. */
  46615. teleportationTime?: number;
  46616. /**
  46617. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46618. */
  46619. teleportationSpeed?: number;
  46620. /**
  46621. * The easing function used in the animation or null for Linear. (default CircleEase)
  46622. */
  46623. easingFunction?: EasingFunction;
  46624. }
  46625. /**
  46626. * Options to modify the vr experience helper's behavior.
  46627. */
  46628. export interface VRExperienceHelperOptions extends WebVROptions {
  46629. /**
  46630. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46631. */
  46632. createDeviceOrientationCamera?: boolean;
  46633. /**
  46634. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46635. */
  46636. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46637. /**
  46638. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46639. */
  46640. laserToggle?: boolean;
  46641. /**
  46642. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46643. */
  46644. floorMeshes?: Mesh[];
  46645. /**
  46646. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46647. */
  46648. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46649. /**
  46650. * Defines if WebXR should be used instead of WebVR (if available)
  46651. */
  46652. useXR?: boolean;
  46653. }
  46654. /**
  46655. * Event containing information after VR has been entered
  46656. */
  46657. export class OnAfterEnteringVRObservableEvent {
  46658. /**
  46659. * If entering vr was successful
  46660. */
  46661. success: boolean;
  46662. }
  46663. /**
  46664. * Helps to quickly add VR support to an existing scene.
  46665. * See http://doc.babylonjs.com/how_to/webvr_helper
  46666. */
  46667. export class VRExperienceHelper {
  46668. /** Options to modify the vr experience helper's behavior. */
  46669. webVROptions: VRExperienceHelperOptions;
  46670. private _scene;
  46671. private _position;
  46672. private _btnVR;
  46673. private _btnVRDisplayed;
  46674. private _webVRsupported;
  46675. private _webVRready;
  46676. private _webVRrequesting;
  46677. private _webVRpresenting;
  46678. private _hasEnteredVR;
  46679. private _fullscreenVRpresenting;
  46680. private _inputElement;
  46681. private _webVRCamera;
  46682. private _vrDeviceOrientationCamera;
  46683. private _deviceOrientationCamera;
  46684. private _existingCamera;
  46685. private _onKeyDown;
  46686. private _onVrDisplayPresentChange;
  46687. private _onVRDisplayChanged;
  46688. private _onVRRequestPresentStart;
  46689. private _onVRRequestPresentComplete;
  46690. /**
  46691. * 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)
  46692. */
  46693. enableGazeEvenWhenNoPointerLock: boolean;
  46694. /**
  46695. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46696. */
  46697. exitVROnDoubleTap: boolean;
  46698. /**
  46699. * Observable raised right before entering VR.
  46700. */
  46701. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46702. /**
  46703. * Observable raised when entering VR has completed.
  46704. */
  46705. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46706. /**
  46707. * Observable raised when exiting VR.
  46708. */
  46709. onExitingVRObservable: Observable<VRExperienceHelper>;
  46710. /**
  46711. * Observable raised when controller mesh is loaded.
  46712. */
  46713. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46714. /** Return this.onEnteringVRObservable
  46715. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46716. */
  46717. get onEnteringVR(): Observable<VRExperienceHelper>;
  46718. /** Return this.onExitingVRObservable
  46719. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46720. */
  46721. get onExitingVR(): Observable<VRExperienceHelper>;
  46722. /** Return this.onControllerMeshLoadedObservable
  46723. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46724. */
  46725. get onControllerMeshLoaded(): Observable<WebVRController>;
  46726. private _rayLength;
  46727. private _useCustomVRButton;
  46728. private _teleportationRequested;
  46729. private _teleportActive;
  46730. private _floorMeshName;
  46731. private _floorMeshesCollection;
  46732. private _teleportationMode;
  46733. private _teleportationTime;
  46734. private _teleportationSpeed;
  46735. private _teleportationEasing;
  46736. private _rotationAllowed;
  46737. private _teleportBackwardsVector;
  46738. private _teleportationTarget;
  46739. private _isDefaultTeleportationTarget;
  46740. private _postProcessMove;
  46741. private _teleportationFillColor;
  46742. private _teleportationBorderColor;
  46743. private _rotationAngle;
  46744. private _haloCenter;
  46745. private _cameraGazer;
  46746. private _padSensibilityUp;
  46747. private _padSensibilityDown;
  46748. private _leftController;
  46749. private _rightController;
  46750. private _gazeColor;
  46751. private _laserColor;
  46752. private _pickedLaserColor;
  46753. private _pickedGazeColor;
  46754. /**
  46755. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46756. */
  46757. onNewMeshSelected: Observable<AbstractMesh>;
  46758. /**
  46759. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46760. * This observable will provide the mesh and the controller used to select the mesh
  46761. */
  46762. onMeshSelectedWithController: Observable<{
  46763. mesh: AbstractMesh;
  46764. controller: WebVRController;
  46765. }>;
  46766. /**
  46767. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46768. */
  46769. onNewMeshPicked: Observable<PickingInfo>;
  46770. private _circleEase;
  46771. /**
  46772. * Observable raised before camera teleportation
  46773. */
  46774. onBeforeCameraTeleport: Observable<Vector3>;
  46775. /**
  46776. * Observable raised after camera teleportation
  46777. */
  46778. onAfterCameraTeleport: Observable<Vector3>;
  46779. /**
  46780. * Observable raised when current selected mesh gets unselected
  46781. */
  46782. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46783. private _raySelectionPredicate;
  46784. /**
  46785. * To be optionaly changed by user to define custom ray selection
  46786. */
  46787. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46788. /**
  46789. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46790. */
  46791. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46792. /**
  46793. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46794. */
  46795. teleportationEnabled: boolean;
  46796. private _defaultHeight;
  46797. private _teleportationInitialized;
  46798. private _interactionsEnabled;
  46799. private _interactionsRequested;
  46800. private _displayGaze;
  46801. private _displayLaserPointer;
  46802. /**
  46803. * The mesh used to display where the user is going to teleport.
  46804. */
  46805. get teleportationTarget(): Mesh;
  46806. /**
  46807. * Sets the mesh to be used to display where the user is going to teleport.
  46808. */
  46809. set teleportationTarget(value: Mesh);
  46810. /**
  46811. * 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
  46812. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46813. * See http://doc.babylonjs.com/resources/baking_transformations
  46814. */
  46815. get gazeTrackerMesh(): Mesh;
  46816. set gazeTrackerMesh(value: Mesh);
  46817. /**
  46818. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46819. */
  46820. updateGazeTrackerScale: boolean;
  46821. /**
  46822. * If the gaze trackers color should be updated when selecting meshes
  46823. */
  46824. updateGazeTrackerColor: boolean;
  46825. /**
  46826. * If the controller laser color should be updated when selecting meshes
  46827. */
  46828. updateControllerLaserColor: boolean;
  46829. /**
  46830. * The gaze tracking mesh corresponding to the left controller
  46831. */
  46832. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46833. /**
  46834. * The gaze tracking mesh corresponding to the right controller
  46835. */
  46836. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46837. /**
  46838. * If the ray of the gaze should be displayed.
  46839. */
  46840. get displayGaze(): boolean;
  46841. /**
  46842. * Sets if the ray of the gaze should be displayed.
  46843. */
  46844. set displayGaze(value: boolean);
  46845. /**
  46846. * If the ray of the LaserPointer should be displayed.
  46847. */
  46848. get displayLaserPointer(): boolean;
  46849. /**
  46850. * Sets if the ray of the LaserPointer should be displayed.
  46851. */
  46852. set displayLaserPointer(value: boolean);
  46853. /**
  46854. * The deviceOrientationCamera used as the camera when not in VR.
  46855. */
  46856. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46857. /**
  46858. * Based on the current WebVR support, returns the current VR camera used.
  46859. */
  46860. get currentVRCamera(): Nullable<Camera>;
  46861. /**
  46862. * The webVRCamera which is used when in VR.
  46863. */
  46864. get webVRCamera(): WebVRFreeCamera;
  46865. /**
  46866. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46867. */
  46868. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46869. /**
  46870. * The html button that is used to trigger entering into VR.
  46871. */
  46872. get vrButton(): Nullable<HTMLButtonElement>;
  46873. private get _teleportationRequestInitiated();
  46874. /**
  46875. * Defines whether or not Pointer lock should be requested when switching to
  46876. * full screen.
  46877. */
  46878. requestPointerLockOnFullScreen: boolean;
  46879. /**
  46880. * If asking to force XR, this will be populated with the default xr experience
  46881. */
  46882. xr: WebXRDefaultExperience;
  46883. /**
  46884. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46885. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46886. */
  46887. xrTestDone: boolean;
  46888. /**
  46889. * Instantiates a VRExperienceHelper.
  46890. * Helps to quickly add VR support to an existing scene.
  46891. * @param scene The scene the VRExperienceHelper belongs to.
  46892. * @param webVROptions Options to modify the vr experience helper's behavior.
  46893. */
  46894. constructor(scene: Scene,
  46895. /** Options to modify the vr experience helper's behavior. */
  46896. webVROptions?: VRExperienceHelperOptions);
  46897. private completeVRInit;
  46898. private _onDefaultMeshLoaded;
  46899. private _onResize;
  46900. private _onFullscreenChange;
  46901. /**
  46902. * Gets a value indicating if we are currently in VR mode.
  46903. */
  46904. get isInVRMode(): boolean;
  46905. private onVrDisplayPresentChange;
  46906. private onVRDisplayChanged;
  46907. private moveButtonToBottomRight;
  46908. private displayVRButton;
  46909. private updateButtonVisibility;
  46910. private _cachedAngularSensibility;
  46911. /**
  46912. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46913. * Otherwise, will use the fullscreen API.
  46914. */
  46915. enterVR(): void;
  46916. /**
  46917. * Attempt to exit VR, or fullscreen.
  46918. */
  46919. exitVR(): void;
  46920. /**
  46921. * The position of the vr experience helper.
  46922. */
  46923. get position(): Vector3;
  46924. /**
  46925. * Sets the position of the vr experience helper.
  46926. */
  46927. set position(value: Vector3);
  46928. /**
  46929. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46930. */
  46931. enableInteractions(): void;
  46932. private get _noControllerIsActive();
  46933. private beforeRender;
  46934. private _isTeleportationFloor;
  46935. /**
  46936. * Adds a floor mesh to be used for teleportation.
  46937. * @param floorMesh the mesh to be used for teleportation.
  46938. */
  46939. addFloorMesh(floorMesh: Mesh): void;
  46940. /**
  46941. * Removes a floor mesh from being used for teleportation.
  46942. * @param floorMesh the mesh to be removed.
  46943. */
  46944. removeFloorMesh(floorMesh: Mesh): void;
  46945. /**
  46946. * Enables interactions and teleportation using the VR controllers and gaze.
  46947. * @param vrTeleportationOptions options to modify teleportation behavior.
  46948. */
  46949. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46950. private _onNewGamepadConnected;
  46951. private _tryEnableInteractionOnController;
  46952. private _onNewGamepadDisconnected;
  46953. private _enableInteractionOnController;
  46954. private _checkTeleportWithRay;
  46955. private _checkRotate;
  46956. private _checkTeleportBackwards;
  46957. private _enableTeleportationOnController;
  46958. private _createTeleportationCircles;
  46959. private _displayTeleportationTarget;
  46960. private _hideTeleportationTarget;
  46961. private _rotateCamera;
  46962. private _moveTeleportationSelectorTo;
  46963. private _workingVector;
  46964. private _workingQuaternion;
  46965. private _workingMatrix;
  46966. /**
  46967. * Time Constant Teleportation Mode
  46968. */
  46969. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46970. /**
  46971. * Speed Constant Teleportation Mode
  46972. */
  46973. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46974. /**
  46975. * Teleports the users feet to the desired location
  46976. * @param location The location where the user's feet should be placed
  46977. */
  46978. teleportCamera(location: Vector3): void;
  46979. private _convertNormalToDirectionOfRay;
  46980. private _castRayAndSelectObject;
  46981. private _notifySelectedMeshUnselected;
  46982. /**
  46983. * Permanently set new colors for the laser pointer
  46984. * @param color the new laser color
  46985. * @param pickedColor the new laser color when picked mesh detected
  46986. */
  46987. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46988. /**
  46989. * Set lighting enabled / disabled on the laser pointer of both controllers
  46990. * @param enabled should the lighting be enabled on the laser pointer
  46991. */
  46992. setLaserLightingState(enabled?: boolean): void;
  46993. /**
  46994. * Permanently set new colors for the gaze pointer
  46995. * @param color the new gaze color
  46996. * @param pickedColor the new gaze color when picked mesh detected
  46997. */
  46998. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46999. /**
  47000. * Sets the color of the laser ray from the vr controllers.
  47001. * @param color new color for the ray.
  47002. */
  47003. changeLaserColor(color: Color3): void;
  47004. /**
  47005. * Sets the color of the ray from the vr headsets gaze.
  47006. * @param color new color for the ray.
  47007. */
  47008. changeGazeColor(color: Color3): void;
  47009. /**
  47010. * Exits VR and disposes of the vr experience helper
  47011. */
  47012. dispose(): void;
  47013. /**
  47014. * Gets the name of the VRExperienceHelper class
  47015. * @returns "VRExperienceHelper"
  47016. */
  47017. getClassName(): string;
  47018. }
  47019. }
  47020. declare module "babylonjs/Cameras/VR/index" {
  47021. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47022. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47023. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47024. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47025. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47026. export * from "babylonjs/Cameras/VR/webVRCamera";
  47027. }
  47028. declare module "babylonjs/Cameras/RigModes/index" {
  47029. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47030. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47031. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47032. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47033. }
  47034. declare module "babylonjs/Cameras/index" {
  47035. export * from "babylonjs/Cameras/Inputs/index";
  47036. export * from "babylonjs/Cameras/cameraInputsManager";
  47037. export * from "babylonjs/Cameras/camera";
  47038. export * from "babylonjs/Cameras/targetCamera";
  47039. export * from "babylonjs/Cameras/freeCamera";
  47040. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47041. export * from "babylonjs/Cameras/touchCamera";
  47042. export * from "babylonjs/Cameras/arcRotateCamera";
  47043. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47044. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47045. export * from "babylonjs/Cameras/flyCamera";
  47046. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47047. export * from "babylonjs/Cameras/followCamera";
  47048. export * from "babylonjs/Cameras/followCameraInputsManager";
  47049. export * from "babylonjs/Cameras/gamepadCamera";
  47050. export * from "babylonjs/Cameras/Stereoscopic/index";
  47051. export * from "babylonjs/Cameras/universalCamera";
  47052. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47053. export * from "babylonjs/Cameras/VR/index";
  47054. export * from "babylonjs/Cameras/RigModes/index";
  47055. }
  47056. declare module "babylonjs/Collisions/index" {
  47057. export * from "babylonjs/Collisions/collider";
  47058. export * from "babylonjs/Collisions/collisionCoordinator";
  47059. export * from "babylonjs/Collisions/pickingInfo";
  47060. export * from "babylonjs/Collisions/intersectionInfo";
  47061. export * from "babylonjs/Collisions/meshCollisionData";
  47062. }
  47063. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47064. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47065. import { Vector3 } from "babylonjs/Maths/math.vector";
  47066. import { Ray } from "babylonjs/Culling/ray";
  47067. import { Plane } from "babylonjs/Maths/math.plane";
  47068. /**
  47069. * Contains an array of blocks representing the octree
  47070. */
  47071. export interface IOctreeContainer<T> {
  47072. /**
  47073. * Blocks within the octree
  47074. */
  47075. blocks: Array<OctreeBlock<T>>;
  47076. }
  47077. /**
  47078. * Class used to store a cell in an octree
  47079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47080. */
  47081. export class OctreeBlock<T> {
  47082. /**
  47083. * Gets the content of the current block
  47084. */
  47085. entries: T[];
  47086. /**
  47087. * Gets the list of block children
  47088. */
  47089. blocks: Array<OctreeBlock<T>>;
  47090. private _depth;
  47091. private _maxDepth;
  47092. private _capacity;
  47093. private _minPoint;
  47094. private _maxPoint;
  47095. private _boundingVectors;
  47096. private _creationFunc;
  47097. /**
  47098. * Creates a new block
  47099. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47100. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47101. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47102. * @param depth defines the current depth of this block in the octree
  47103. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47104. * @param creationFunc defines a callback to call when an element is added to the block
  47105. */
  47106. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47107. /**
  47108. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47109. */
  47110. get capacity(): number;
  47111. /**
  47112. * Gets the minimum vector (in world space) of the block's bounding box
  47113. */
  47114. get minPoint(): Vector3;
  47115. /**
  47116. * Gets the maximum vector (in world space) of the block's bounding box
  47117. */
  47118. get maxPoint(): Vector3;
  47119. /**
  47120. * Add a new element to this block
  47121. * @param entry defines the element to add
  47122. */
  47123. addEntry(entry: T): void;
  47124. /**
  47125. * Remove an element from this block
  47126. * @param entry defines the element to remove
  47127. */
  47128. removeEntry(entry: T): void;
  47129. /**
  47130. * Add an array of elements to this block
  47131. * @param entries defines the array of elements to add
  47132. */
  47133. addEntries(entries: T[]): void;
  47134. /**
  47135. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47136. * @param frustumPlanes defines the frustum planes to test
  47137. * @param selection defines the array to store current content if selection is positive
  47138. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47139. */
  47140. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47141. /**
  47142. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47143. * @param sphereCenter defines the bounding sphere center
  47144. * @param sphereRadius defines the bounding sphere radius
  47145. * @param selection defines the array to store current content if selection is positive
  47146. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47147. */
  47148. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47149. /**
  47150. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47151. * @param ray defines the ray to test with
  47152. * @param selection defines the array to store current content if selection is positive
  47153. */
  47154. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47155. /**
  47156. * Subdivide the content into child blocks (this block will then be empty)
  47157. */
  47158. createInnerBlocks(): void;
  47159. /**
  47160. * @hidden
  47161. */
  47162. 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;
  47163. }
  47164. }
  47165. declare module "babylonjs/Culling/Octrees/octree" {
  47166. import { SmartArray } from "babylonjs/Misc/smartArray";
  47167. import { Vector3 } from "babylonjs/Maths/math.vector";
  47168. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47170. import { Ray } from "babylonjs/Culling/ray";
  47171. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47172. import { Plane } from "babylonjs/Maths/math.plane";
  47173. /**
  47174. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47176. */
  47177. export class Octree<T> {
  47178. /** 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.) */
  47179. maxDepth: number;
  47180. /**
  47181. * Blocks within the octree containing objects
  47182. */
  47183. blocks: Array<OctreeBlock<T>>;
  47184. /**
  47185. * Content stored in the octree
  47186. */
  47187. dynamicContent: T[];
  47188. private _maxBlockCapacity;
  47189. private _selectionContent;
  47190. private _creationFunc;
  47191. /**
  47192. * Creates a octree
  47193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47194. * @param creationFunc function to be used to instatiate the octree
  47195. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47196. * @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.)
  47197. */
  47198. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47199. /** 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.) */
  47200. maxDepth?: number);
  47201. /**
  47202. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47203. * @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);
  47204. * @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);
  47205. * @param entries meshes to be added to the octree blocks
  47206. */
  47207. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47208. /**
  47209. * Adds a mesh to the octree
  47210. * @param entry Mesh to add to the octree
  47211. */
  47212. addMesh(entry: T): void;
  47213. /**
  47214. * Remove an element from the octree
  47215. * @param entry defines the element to remove
  47216. */
  47217. removeMesh(entry: T): void;
  47218. /**
  47219. * Selects an array of meshes within the frustum
  47220. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47221. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47222. * @returns array of meshes within the frustum
  47223. */
  47224. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47225. /**
  47226. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47227. * @param sphereCenter defines the bounding sphere center
  47228. * @param sphereRadius defines the bounding sphere radius
  47229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47230. * @returns an array of objects that intersect the sphere
  47231. */
  47232. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47233. /**
  47234. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47235. * @param ray defines the ray to test with
  47236. * @returns array of intersected objects
  47237. */
  47238. intersectsRay(ray: Ray): SmartArray<T>;
  47239. /**
  47240. * Adds a mesh into the octree block if it intersects the block
  47241. */
  47242. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47243. /**
  47244. * Adds a submesh into the octree block if it intersects the block
  47245. */
  47246. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47250. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47251. import { Scene } from "babylonjs/scene";
  47252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47254. import { Ray } from "babylonjs/Culling/ray";
  47255. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47256. import { Collider } from "babylonjs/Collisions/collider";
  47257. module "babylonjs/scene" {
  47258. interface Scene {
  47259. /**
  47260. * @hidden
  47261. * Backing Filed
  47262. */
  47263. _selectionOctree: Octree<AbstractMesh>;
  47264. /**
  47265. * Gets the octree used to boost mesh selection (picking)
  47266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47267. */
  47268. selectionOctree: Octree<AbstractMesh>;
  47269. /**
  47270. * Creates or updates the octree used to boost selection (picking)
  47271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47272. * @param maxCapacity defines the maximum capacity per leaf
  47273. * @param maxDepth defines the maximum depth of the octree
  47274. * @returns an octree of AbstractMesh
  47275. */
  47276. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47277. }
  47278. }
  47279. module "babylonjs/Meshes/abstractMesh" {
  47280. interface AbstractMesh {
  47281. /**
  47282. * @hidden
  47283. * Backing Field
  47284. */
  47285. _submeshesOctree: Octree<SubMesh>;
  47286. /**
  47287. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47288. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47289. * @param maxCapacity defines the maximum size of each block (64 by default)
  47290. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47291. * @returns the new octree
  47292. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47294. */
  47295. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47296. }
  47297. }
  47298. /**
  47299. * Defines the octree scene component responsible to manage any octrees
  47300. * in a given scene.
  47301. */
  47302. export class OctreeSceneComponent {
  47303. /**
  47304. * The component name help to identify the component in the list of scene components.
  47305. */
  47306. readonly name: string;
  47307. /**
  47308. * The scene the component belongs to.
  47309. */
  47310. scene: Scene;
  47311. /**
  47312. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47313. */
  47314. readonly checksIsEnabled: boolean;
  47315. /**
  47316. * Creates a new instance of the component for the given scene
  47317. * @param scene Defines the scene to register the component in
  47318. */
  47319. constructor(scene: Scene);
  47320. /**
  47321. * Registers the component in a given scene
  47322. */
  47323. register(): void;
  47324. /**
  47325. * Return the list of active meshes
  47326. * @returns the list of active meshes
  47327. */
  47328. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47329. /**
  47330. * Return the list of active sub meshes
  47331. * @param mesh The mesh to get the candidates sub meshes from
  47332. * @returns the list of active sub meshes
  47333. */
  47334. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47335. private _tempRay;
  47336. /**
  47337. * Return the list of sub meshes intersecting with a given local ray
  47338. * @param mesh defines the mesh to find the submesh for
  47339. * @param localRay defines the ray in local space
  47340. * @returns the list of intersecting sub meshes
  47341. */
  47342. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47343. /**
  47344. * Return the list of sub meshes colliding with a collider
  47345. * @param mesh defines the mesh to find the submesh for
  47346. * @param collider defines the collider to evaluate the collision against
  47347. * @returns the list of colliding sub meshes
  47348. */
  47349. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47350. /**
  47351. * Rebuilds the elements related to this component in case of
  47352. * context lost for instance.
  47353. */
  47354. rebuild(): void;
  47355. /**
  47356. * Disposes the component and the associated ressources.
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Culling/Octrees/index" {
  47362. export * from "babylonjs/Culling/Octrees/octree";
  47363. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47364. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47365. }
  47366. declare module "babylonjs/Culling/index" {
  47367. export * from "babylonjs/Culling/boundingBox";
  47368. export * from "babylonjs/Culling/boundingInfo";
  47369. export * from "babylonjs/Culling/boundingSphere";
  47370. export * from "babylonjs/Culling/Octrees/index";
  47371. export * from "babylonjs/Culling/ray";
  47372. }
  47373. declare module "babylonjs/Gizmos/gizmo" {
  47374. import { Nullable } from "babylonjs/types";
  47375. import { IDisposable } from "babylonjs/scene";
  47376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47377. import { Mesh } from "babylonjs/Meshes/mesh";
  47378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47379. /**
  47380. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47381. */
  47382. export class Gizmo implements IDisposable {
  47383. /** The utility layer the gizmo will be added to */
  47384. gizmoLayer: UtilityLayerRenderer;
  47385. /**
  47386. * The root mesh of the gizmo
  47387. */
  47388. _rootMesh: Mesh;
  47389. private _attachedMesh;
  47390. /**
  47391. * Ratio for the scale of the gizmo (Default: 1)
  47392. */
  47393. scaleRatio: number;
  47394. /**
  47395. * If a custom mesh has been set (Default: false)
  47396. */
  47397. protected _customMeshSet: boolean;
  47398. /**
  47399. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47400. * * When set, interactions will be enabled
  47401. */
  47402. get attachedMesh(): Nullable<AbstractMesh>;
  47403. set attachedMesh(value: Nullable<AbstractMesh>);
  47404. /**
  47405. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47406. * @param mesh The mesh to replace the default mesh of the gizmo
  47407. */
  47408. setCustomMesh(mesh: Mesh): void;
  47409. /**
  47410. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47411. */
  47412. updateGizmoRotationToMatchAttachedMesh: boolean;
  47413. /**
  47414. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47415. */
  47416. updateGizmoPositionToMatchAttachedMesh: boolean;
  47417. /**
  47418. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47419. */
  47420. updateScale: boolean;
  47421. protected _interactionsEnabled: boolean;
  47422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47423. private _beforeRenderObserver;
  47424. private _tempVector;
  47425. /**
  47426. * Creates a gizmo
  47427. * @param gizmoLayer The utility layer the gizmo will be added to
  47428. */
  47429. constructor(
  47430. /** The utility layer the gizmo will be added to */
  47431. gizmoLayer?: UtilityLayerRenderer);
  47432. /**
  47433. * Updates the gizmo to match the attached mesh's position/rotation
  47434. */
  47435. protected _update(): void;
  47436. /**
  47437. * Disposes of the gizmo
  47438. */
  47439. dispose(): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47443. import { Observable } from "babylonjs/Misc/observable";
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Vector3 } from "babylonjs/Maths/math.vector";
  47446. import { Color3 } from "babylonjs/Maths/math.color";
  47447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47449. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47452. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47453. import { Scene } from "babylonjs/scene";
  47454. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47455. /**
  47456. * Single plane drag gizmo
  47457. */
  47458. export class PlaneDragGizmo extends Gizmo {
  47459. /**
  47460. * Drag behavior responsible for the gizmos dragging interactions
  47461. */
  47462. dragBehavior: PointerDragBehavior;
  47463. private _pointerObserver;
  47464. /**
  47465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47466. */
  47467. snapDistance: number;
  47468. /**
  47469. * Event that fires each time the gizmo snaps to a new location.
  47470. * * snapDistance is the the change in distance
  47471. */
  47472. onSnapObservable: Observable<{
  47473. snapDistance: number;
  47474. }>;
  47475. private _plane;
  47476. private _coloredMaterial;
  47477. private _hoverMaterial;
  47478. private _isEnabled;
  47479. private _parent;
  47480. /** @hidden */
  47481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47482. /** @hidden */
  47483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47484. /**
  47485. * Creates a PlaneDragGizmo
  47486. * @param gizmoLayer The utility layer the gizmo will be added to
  47487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47488. * @param color The color of the gizmo
  47489. */
  47490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47492. /**
  47493. * If the gizmo is enabled
  47494. */
  47495. set isEnabled(value: boolean);
  47496. get isEnabled(): boolean;
  47497. /**
  47498. * Disposes of the gizmo
  47499. */
  47500. dispose(): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Gizmos/positionGizmo" {
  47504. import { Observable } from "babylonjs/Misc/observable";
  47505. import { Nullable } from "babylonjs/types";
  47506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47509. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47510. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47512. /**
  47513. * Gizmo that enables dragging a mesh along 3 axis
  47514. */
  47515. export class PositionGizmo extends Gizmo {
  47516. /**
  47517. * Internal gizmo used for interactions on the x axis
  47518. */
  47519. xGizmo: AxisDragGizmo;
  47520. /**
  47521. * Internal gizmo used for interactions on the y axis
  47522. */
  47523. yGizmo: AxisDragGizmo;
  47524. /**
  47525. * Internal gizmo used for interactions on the z axis
  47526. */
  47527. zGizmo: AxisDragGizmo;
  47528. /**
  47529. * Internal gizmo used for interactions on the yz plane
  47530. */
  47531. xPlaneGizmo: PlaneDragGizmo;
  47532. /**
  47533. * Internal gizmo used for interactions on the xz plane
  47534. */
  47535. yPlaneGizmo: PlaneDragGizmo;
  47536. /**
  47537. * Internal gizmo used for interactions on the xy plane
  47538. */
  47539. zPlaneGizmo: PlaneDragGizmo;
  47540. /**
  47541. * private variables
  47542. */
  47543. private _meshAttached;
  47544. private _updateGizmoRotationToMatchAttachedMesh;
  47545. private _snapDistance;
  47546. private _scaleRatio;
  47547. /** Fires an event when any of it's sub gizmos are dragged */
  47548. onDragStartObservable: Observable<unknown>;
  47549. /** Fires an event when any of it's sub gizmos are released from dragging */
  47550. onDragEndObservable: Observable<unknown>;
  47551. /**
  47552. * If set to true, planar drag is enabled
  47553. */
  47554. private _planarGizmoEnabled;
  47555. get attachedMesh(): Nullable<AbstractMesh>;
  47556. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47557. /**
  47558. * Creates a PositionGizmo
  47559. * @param gizmoLayer The utility layer the gizmo will be added to
  47560. */
  47561. constructor(gizmoLayer?: UtilityLayerRenderer);
  47562. /**
  47563. * If the planar drag gizmo is enabled
  47564. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47565. */
  47566. set planarGizmoEnabled(value: boolean);
  47567. get planarGizmoEnabled(): boolean;
  47568. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47569. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47570. /**
  47571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47572. */
  47573. set snapDistance(value: number);
  47574. get snapDistance(): number;
  47575. /**
  47576. * Ratio for the scale of the gizmo (Default: 1)
  47577. */
  47578. set scaleRatio(value: number);
  47579. get scaleRatio(): number;
  47580. /**
  47581. * Disposes of the gizmo
  47582. */
  47583. dispose(): void;
  47584. /**
  47585. * CustomMeshes are not supported by this gizmo
  47586. * @param mesh The mesh to replace the default mesh of the gizmo
  47587. */
  47588. setCustomMesh(mesh: Mesh): void;
  47589. }
  47590. }
  47591. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47592. import { Observable } from "babylonjs/Misc/observable";
  47593. import { Nullable } from "babylonjs/types";
  47594. import { Vector3 } from "babylonjs/Maths/math.vector";
  47595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47597. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47598. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47600. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47601. import { Scene } from "babylonjs/scene";
  47602. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47603. import { Color3 } from "babylonjs/Maths/math.color";
  47604. /**
  47605. * Single axis drag gizmo
  47606. */
  47607. export class AxisDragGizmo extends Gizmo {
  47608. /**
  47609. * Drag behavior responsible for the gizmos dragging interactions
  47610. */
  47611. dragBehavior: PointerDragBehavior;
  47612. private _pointerObserver;
  47613. /**
  47614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47615. */
  47616. snapDistance: number;
  47617. /**
  47618. * Event that fires each time the gizmo snaps to a new location.
  47619. * * snapDistance is the the change in distance
  47620. */
  47621. onSnapObservable: Observable<{
  47622. snapDistance: number;
  47623. }>;
  47624. private _isEnabled;
  47625. private _parent;
  47626. private _arrow;
  47627. private _coloredMaterial;
  47628. private _hoverMaterial;
  47629. /** @hidden */
  47630. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47631. /** @hidden */
  47632. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47633. /**
  47634. * Creates an AxisDragGizmo
  47635. * @param gizmoLayer The utility layer the gizmo will be added to
  47636. * @param dragAxis The axis which the gizmo will be able to drag on
  47637. * @param color The color of the gizmo
  47638. */
  47639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47641. /**
  47642. * If the gizmo is enabled
  47643. */
  47644. set isEnabled(value: boolean);
  47645. get isEnabled(): boolean;
  47646. /**
  47647. * Disposes of the gizmo
  47648. */
  47649. dispose(): void;
  47650. }
  47651. }
  47652. declare module "babylonjs/Debug/axesViewer" {
  47653. import { Vector3 } from "babylonjs/Maths/math.vector";
  47654. import { Nullable } from "babylonjs/types";
  47655. import { Scene } from "babylonjs/scene";
  47656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47657. /**
  47658. * The Axes viewer will show 3 axes in a specific point in space
  47659. */
  47660. export class AxesViewer {
  47661. private _xAxis;
  47662. private _yAxis;
  47663. private _zAxis;
  47664. private _scaleLinesFactor;
  47665. private _instanced;
  47666. /**
  47667. * Gets the hosting scene
  47668. */
  47669. scene: Scene;
  47670. /**
  47671. * Gets or sets a number used to scale line length
  47672. */
  47673. scaleLines: number;
  47674. /** Gets the node hierarchy used to render x-axis */
  47675. get xAxis(): TransformNode;
  47676. /** Gets the node hierarchy used to render y-axis */
  47677. get yAxis(): TransformNode;
  47678. /** Gets the node hierarchy used to render z-axis */
  47679. get zAxis(): TransformNode;
  47680. /**
  47681. * Creates a new AxesViewer
  47682. * @param scene defines the hosting scene
  47683. * @param scaleLines defines a number used to scale line length (1 by default)
  47684. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47685. * @param xAxis defines the node hierarchy used to render the x-axis
  47686. * @param yAxis defines the node hierarchy used to render the y-axis
  47687. * @param zAxis defines the node hierarchy used to render the z-axis
  47688. */
  47689. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47690. /**
  47691. * Force the viewer to update
  47692. * @param position defines the position of the viewer
  47693. * @param xaxis defines the x axis of the viewer
  47694. * @param yaxis defines the y axis of the viewer
  47695. * @param zaxis defines the z axis of the viewer
  47696. */
  47697. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47698. /**
  47699. * Creates an instance of this axes viewer.
  47700. * @returns a new axes viewer with instanced meshes
  47701. */
  47702. createInstance(): AxesViewer;
  47703. /** Releases resources */
  47704. dispose(): void;
  47705. private static _SetRenderingGroupId;
  47706. }
  47707. }
  47708. declare module "babylonjs/Debug/boneAxesViewer" {
  47709. import { Nullable } from "babylonjs/types";
  47710. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47711. import { Vector3 } from "babylonjs/Maths/math.vector";
  47712. import { Mesh } from "babylonjs/Meshes/mesh";
  47713. import { Bone } from "babylonjs/Bones/bone";
  47714. import { Scene } from "babylonjs/scene";
  47715. /**
  47716. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47717. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47718. */
  47719. export class BoneAxesViewer extends AxesViewer {
  47720. /**
  47721. * Gets or sets the target mesh where to display the axes viewer
  47722. */
  47723. mesh: Nullable<Mesh>;
  47724. /**
  47725. * Gets or sets the target bone where to display the axes viewer
  47726. */
  47727. bone: Nullable<Bone>;
  47728. /** Gets current position */
  47729. pos: Vector3;
  47730. /** Gets direction of X axis */
  47731. xaxis: Vector3;
  47732. /** Gets direction of Y axis */
  47733. yaxis: Vector3;
  47734. /** Gets direction of Z axis */
  47735. zaxis: Vector3;
  47736. /**
  47737. * Creates a new BoneAxesViewer
  47738. * @param scene defines the hosting scene
  47739. * @param bone defines the target bone
  47740. * @param mesh defines the target mesh
  47741. * @param scaleLines defines a scaling factor for line length (1 by default)
  47742. */
  47743. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47744. /**
  47745. * Force the viewer to update
  47746. */
  47747. update(): void;
  47748. /** Releases resources */
  47749. dispose(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Debug/debugLayer" {
  47753. import { Scene } from "babylonjs/scene";
  47754. /**
  47755. * Interface used to define scene explorer extensibility option
  47756. */
  47757. export interface IExplorerExtensibilityOption {
  47758. /**
  47759. * Define the option label
  47760. */
  47761. label: string;
  47762. /**
  47763. * Defines the action to execute on click
  47764. */
  47765. action: (entity: any) => void;
  47766. }
  47767. /**
  47768. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47769. */
  47770. export interface IExplorerExtensibilityGroup {
  47771. /**
  47772. * Defines a predicate to test if a given type mut be extended
  47773. */
  47774. predicate: (entity: any) => boolean;
  47775. /**
  47776. * Gets the list of options added to a type
  47777. */
  47778. entries: IExplorerExtensibilityOption[];
  47779. }
  47780. /**
  47781. * Interface used to define the options to use to create the Inspector
  47782. */
  47783. export interface IInspectorOptions {
  47784. /**
  47785. * Display in overlay mode (default: false)
  47786. */
  47787. overlay?: boolean;
  47788. /**
  47789. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47790. */
  47791. globalRoot?: HTMLElement;
  47792. /**
  47793. * Display the Scene explorer
  47794. */
  47795. showExplorer?: boolean;
  47796. /**
  47797. * Display the property inspector
  47798. */
  47799. showInspector?: boolean;
  47800. /**
  47801. * Display in embed mode (both panes on the right)
  47802. */
  47803. embedMode?: boolean;
  47804. /**
  47805. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47806. */
  47807. handleResize?: boolean;
  47808. /**
  47809. * Allow the panes to popup (default: true)
  47810. */
  47811. enablePopup?: boolean;
  47812. /**
  47813. * Allow the panes to be closed by users (default: true)
  47814. */
  47815. enableClose?: boolean;
  47816. /**
  47817. * Optional list of extensibility entries
  47818. */
  47819. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47820. /**
  47821. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47822. */
  47823. inspectorURL?: string;
  47824. /**
  47825. * Optional initial tab (default to DebugLayerTab.Properties)
  47826. */
  47827. initialTab?: DebugLayerTab;
  47828. }
  47829. module "babylonjs/scene" {
  47830. interface Scene {
  47831. /**
  47832. * @hidden
  47833. * Backing field
  47834. */
  47835. _debugLayer: DebugLayer;
  47836. /**
  47837. * Gets the debug layer (aka Inspector) associated with the scene
  47838. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47839. */
  47840. debugLayer: DebugLayer;
  47841. }
  47842. }
  47843. /**
  47844. * Enum of inspector action tab
  47845. */
  47846. export enum DebugLayerTab {
  47847. /**
  47848. * Properties tag (default)
  47849. */
  47850. Properties = 0,
  47851. /**
  47852. * Debug tab
  47853. */
  47854. Debug = 1,
  47855. /**
  47856. * Statistics tab
  47857. */
  47858. Statistics = 2,
  47859. /**
  47860. * Tools tab
  47861. */
  47862. Tools = 3,
  47863. /**
  47864. * Settings tab
  47865. */
  47866. Settings = 4
  47867. }
  47868. /**
  47869. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47870. * what is happening in your scene
  47871. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47872. */
  47873. export class DebugLayer {
  47874. /**
  47875. * Define the url to get the inspector script from.
  47876. * By default it uses the babylonjs CDN.
  47877. * @ignoreNaming
  47878. */
  47879. static InspectorURL: string;
  47880. private _scene;
  47881. private BJSINSPECTOR;
  47882. private _onPropertyChangedObservable?;
  47883. /**
  47884. * Observable triggered when a property is changed through the inspector.
  47885. */
  47886. get onPropertyChangedObservable(): any;
  47887. /**
  47888. * Instantiates a new debug layer.
  47889. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47890. * what is happening in your scene
  47891. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47892. * @param scene Defines the scene to inspect
  47893. */
  47894. constructor(scene: Scene);
  47895. /** Creates the inspector window. */
  47896. private _createInspector;
  47897. /**
  47898. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47899. * @param entity defines the entity to select
  47900. * @param lineContainerTitle defines the specific block to highlight
  47901. */
  47902. select(entity: any, lineContainerTitle?: string): void;
  47903. /** Get the inspector from bundle or global */
  47904. private _getGlobalInspector;
  47905. /**
  47906. * Get if the inspector is visible or not.
  47907. * @returns true if visible otherwise, false
  47908. */
  47909. isVisible(): boolean;
  47910. /**
  47911. * Hide the inspector and close its window.
  47912. */
  47913. hide(): void;
  47914. /**
  47915. * Launch the debugLayer.
  47916. * @param config Define the configuration of the inspector
  47917. * @return a promise fulfilled when the debug layer is visible
  47918. */
  47919. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47920. }
  47921. }
  47922. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47923. import { Nullable } from "babylonjs/types";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector4 } from "babylonjs/Maths/math.vector";
  47926. import { Color4 } from "babylonjs/Maths/math.color";
  47927. import { Mesh } from "babylonjs/Meshes/mesh";
  47928. /**
  47929. * Class containing static functions to help procedurally build meshes
  47930. */
  47931. export class BoxBuilder {
  47932. /**
  47933. * Creates a box mesh
  47934. * * The parameter `size` sets the size (float) of each box side (default 1)
  47935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47936. * * 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)
  47937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47942. * @param name defines the name of the mesh
  47943. * @param options defines the options used to create the mesh
  47944. * @param scene defines the hosting scene
  47945. * @returns the box mesh
  47946. */
  47947. static CreateBox(name: string, options: {
  47948. size?: number;
  47949. width?: number;
  47950. height?: number;
  47951. depth?: number;
  47952. faceUV?: Vector4[];
  47953. faceColors?: Color4[];
  47954. sideOrientation?: number;
  47955. frontUVs?: Vector4;
  47956. backUVs?: Vector4;
  47957. wrap?: boolean;
  47958. topBaseAt?: number;
  47959. bottomBaseAt?: number;
  47960. updatable?: boolean;
  47961. }, scene?: Nullable<Scene>): Mesh;
  47962. }
  47963. }
  47964. declare module "babylonjs/Debug/physicsViewer" {
  47965. import { Nullable } from "babylonjs/types";
  47966. import { Scene } from "babylonjs/scene";
  47967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47968. import { Mesh } from "babylonjs/Meshes/mesh";
  47969. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47970. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47971. /**
  47972. * Used to show the physics impostor around the specific mesh
  47973. */
  47974. export class PhysicsViewer {
  47975. /** @hidden */
  47976. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47977. /** @hidden */
  47978. protected _meshes: Array<Nullable<AbstractMesh>>;
  47979. /** @hidden */
  47980. protected _scene: Nullable<Scene>;
  47981. /** @hidden */
  47982. protected _numMeshes: number;
  47983. /** @hidden */
  47984. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47985. private _renderFunction;
  47986. private _utilityLayer;
  47987. private _debugBoxMesh;
  47988. private _debugSphereMesh;
  47989. private _debugCylinderMesh;
  47990. private _debugMaterial;
  47991. private _debugMeshMeshes;
  47992. /**
  47993. * Creates a new PhysicsViewer
  47994. * @param scene defines the hosting scene
  47995. */
  47996. constructor(scene: Scene);
  47997. /** @hidden */
  47998. protected _updateDebugMeshes(): void;
  47999. /**
  48000. * Renders a specified physic impostor
  48001. * @param impostor defines the impostor to render
  48002. * @param targetMesh defines the mesh represented by the impostor
  48003. * @returns the new debug mesh used to render the impostor
  48004. */
  48005. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48006. /**
  48007. * Hides a specified physic impostor
  48008. * @param impostor defines the impostor to hide
  48009. */
  48010. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48011. private _getDebugMaterial;
  48012. private _getDebugBoxMesh;
  48013. private _getDebugSphereMesh;
  48014. private _getDebugCylinderMesh;
  48015. private _getDebugMeshMesh;
  48016. private _getDebugMesh;
  48017. /** Releases all resources */
  48018. dispose(): void;
  48019. }
  48020. }
  48021. declare module "babylonjs/Debug/rayHelper" {
  48022. import { Nullable } from "babylonjs/types";
  48023. import { Ray } from "babylonjs/Culling/ray";
  48024. import { Vector3 } from "babylonjs/Maths/math.vector";
  48025. import { Color3 } from "babylonjs/Maths/math.color";
  48026. import { Scene } from "babylonjs/scene";
  48027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48028. import "babylonjs/Meshes/Builders/linesBuilder";
  48029. /**
  48030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48031. * in order to better appreciate the issue one might have.
  48032. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48033. */
  48034. export class RayHelper {
  48035. /**
  48036. * Defines the ray we are currently tryin to visualize.
  48037. */
  48038. ray: Nullable<Ray>;
  48039. private _renderPoints;
  48040. private _renderLine;
  48041. private _renderFunction;
  48042. private _scene;
  48043. private _updateToMeshFunction;
  48044. private _attachedToMesh;
  48045. private _meshSpaceDirection;
  48046. private _meshSpaceOrigin;
  48047. /**
  48048. * Helper function to create a colored helper in a scene in one line.
  48049. * @param ray Defines the ray we are currently tryin to visualize
  48050. * @param scene Defines the scene the ray is used in
  48051. * @param color Defines the color we want to see the ray in
  48052. * @returns The newly created ray helper.
  48053. */
  48054. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48055. /**
  48056. * Instantiate a new ray helper.
  48057. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48058. * in order to better appreciate the issue one might have.
  48059. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48060. * @param ray Defines the ray we are currently tryin to visualize
  48061. */
  48062. constructor(ray: Ray);
  48063. /**
  48064. * Shows the ray we are willing to debug.
  48065. * @param scene Defines the scene the ray needs to be rendered in
  48066. * @param color Defines the color the ray needs to be rendered in
  48067. */
  48068. show(scene: Scene, color?: Color3): void;
  48069. /**
  48070. * Hides the ray we are debugging.
  48071. */
  48072. hide(): void;
  48073. private _render;
  48074. /**
  48075. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48076. * @param mesh Defines the mesh we want the helper attached to
  48077. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48078. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48079. * @param length Defines the length of the ray
  48080. */
  48081. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48082. /**
  48083. * Detach the ray helper from the mesh it has previously been attached to.
  48084. */
  48085. detachFromMesh(): void;
  48086. private _updateToMesh;
  48087. /**
  48088. * Dispose the helper and release its associated resources.
  48089. */
  48090. dispose(): void;
  48091. }
  48092. }
  48093. declare module "babylonjs/Debug/skeletonViewer" {
  48094. import { Color3 } from "babylonjs/Maths/math.color";
  48095. import { Scene } from "babylonjs/scene";
  48096. import { Nullable } from "babylonjs/types";
  48097. import { Skeleton } from "babylonjs/Bones/skeleton";
  48098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48099. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48100. /**
  48101. * Class used to render a debug view of a given skeleton
  48102. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48103. */
  48104. export class SkeletonViewer {
  48105. /** defines the skeleton to render */
  48106. skeleton: Skeleton;
  48107. /** defines the mesh attached to the skeleton */
  48108. mesh: AbstractMesh;
  48109. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48110. autoUpdateBonesMatrices: boolean;
  48111. /** defines the rendering group id to use with the viewer */
  48112. renderingGroupId: number;
  48113. /** Gets or sets the color used to render the skeleton */
  48114. color: Color3;
  48115. private _scene;
  48116. private _debugLines;
  48117. private _debugMesh;
  48118. private _isEnabled;
  48119. private _renderFunction;
  48120. private _utilityLayer;
  48121. /**
  48122. * Returns the mesh used to render the bones
  48123. */
  48124. get debugMesh(): Nullable<LinesMesh>;
  48125. /**
  48126. * Creates a new SkeletonViewer
  48127. * @param skeleton defines the skeleton to render
  48128. * @param mesh defines the mesh attached to the skeleton
  48129. * @param scene defines the hosting scene
  48130. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48131. * @param renderingGroupId defines the rendering group id to use with the viewer
  48132. */
  48133. constructor(
  48134. /** defines the skeleton to render */
  48135. skeleton: Skeleton,
  48136. /** defines the mesh attached to the skeleton */
  48137. mesh: AbstractMesh, scene: Scene,
  48138. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48139. autoUpdateBonesMatrices?: boolean,
  48140. /** defines the rendering group id to use with the viewer */
  48141. renderingGroupId?: number);
  48142. /** Gets or sets a boolean indicating if the viewer is enabled */
  48143. set isEnabled(value: boolean);
  48144. get isEnabled(): boolean;
  48145. private _getBonePosition;
  48146. private _getLinesForBonesWithLength;
  48147. private _getLinesForBonesNoLength;
  48148. /** Update the viewer to sync with current skeleton state */
  48149. update(): void;
  48150. /** Release associated resources */
  48151. dispose(): void;
  48152. }
  48153. }
  48154. declare module "babylonjs/Debug/index" {
  48155. export * from "babylonjs/Debug/axesViewer";
  48156. export * from "babylonjs/Debug/boneAxesViewer";
  48157. export * from "babylonjs/Debug/debugLayer";
  48158. export * from "babylonjs/Debug/physicsViewer";
  48159. export * from "babylonjs/Debug/rayHelper";
  48160. export * from "babylonjs/Debug/skeletonViewer";
  48161. }
  48162. declare module "babylonjs/Engines/nullEngine" {
  48163. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48164. import { Scene } from "babylonjs/scene";
  48165. import { Engine } from "babylonjs/Engines/engine";
  48166. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48167. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48168. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48169. import { Effect } from "babylonjs/Materials/effect";
  48170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48171. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48172. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48173. /**
  48174. * Options to create the null engine
  48175. */
  48176. export class NullEngineOptions {
  48177. /**
  48178. * Render width (Default: 512)
  48179. */
  48180. renderWidth: number;
  48181. /**
  48182. * Render height (Default: 256)
  48183. */
  48184. renderHeight: number;
  48185. /**
  48186. * Texture size (Default: 512)
  48187. */
  48188. textureSize: number;
  48189. /**
  48190. * If delta time between frames should be constant
  48191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48192. */
  48193. deterministicLockstep: boolean;
  48194. /**
  48195. * Maximum about of steps between frames (Default: 4)
  48196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48197. */
  48198. lockstepMaxSteps: number;
  48199. }
  48200. /**
  48201. * The null engine class provides support for headless version of babylon.js.
  48202. * This can be used in server side scenario or for testing purposes
  48203. */
  48204. export class NullEngine extends Engine {
  48205. private _options;
  48206. /**
  48207. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48209. * @returns true if engine is in deterministic lock step mode
  48210. */
  48211. isDeterministicLockStep(): boolean;
  48212. /**
  48213. * Gets the max steps when engine is running in deterministic lock step
  48214. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48215. * @returns the max steps
  48216. */
  48217. getLockstepMaxSteps(): number;
  48218. /**
  48219. * Gets the current hardware scaling level.
  48220. * By default the hardware scaling level is computed from the window device ratio.
  48221. * 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.
  48222. * @returns a number indicating the current hardware scaling level
  48223. */
  48224. getHardwareScalingLevel(): number;
  48225. constructor(options?: NullEngineOptions);
  48226. /**
  48227. * Creates a vertex buffer
  48228. * @param vertices the data for the vertex buffer
  48229. * @returns the new WebGL static buffer
  48230. */
  48231. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48232. /**
  48233. * Creates a new index buffer
  48234. * @param indices defines the content of the index buffer
  48235. * @param updatable defines if the index buffer must be updatable
  48236. * @returns a new webGL buffer
  48237. */
  48238. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48239. /**
  48240. * Clear the current render buffer or the current render target (if any is set up)
  48241. * @param color defines the color to use
  48242. * @param backBuffer defines if the back buffer must be cleared
  48243. * @param depth defines if the depth buffer must be cleared
  48244. * @param stencil defines if the stencil buffer must be cleared
  48245. */
  48246. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48247. /**
  48248. * Gets the current render width
  48249. * @param useScreen defines if screen size must be used (or the current render target if any)
  48250. * @returns a number defining the current render width
  48251. */
  48252. getRenderWidth(useScreen?: boolean): number;
  48253. /**
  48254. * Gets the current render height
  48255. * @param useScreen defines if screen size must be used (or the current render target if any)
  48256. * @returns a number defining the current render height
  48257. */
  48258. getRenderHeight(useScreen?: boolean): number;
  48259. /**
  48260. * Set the WebGL's viewport
  48261. * @param viewport defines the viewport element to be used
  48262. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48263. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48264. */
  48265. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48267. /**
  48268. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48269. * @param pipelineContext defines the pipeline context to use
  48270. * @param uniformsNames defines the list of uniform names
  48271. * @returns an array of webGL uniform locations
  48272. */
  48273. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48274. /**
  48275. * Gets the lsit of active attributes for a given webGL program
  48276. * @param pipelineContext defines the pipeline context to use
  48277. * @param attributesNames defines the list of attribute names to get
  48278. * @returns an array of indices indicating the offset of each attribute
  48279. */
  48280. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48281. /**
  48282. * Binds an effect to the webGL context
  48283. * @param effect defines the effect to bind
  48284. */
  48285. bindSamplers(effect: Effect): void;
  48286. /**
  48287. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48288. * @param effect defines the effect to activate
  48289. */
  48290. enableEffect(effect: Effect): void;
  48291. /**
  48292. * Set various states to the webGL context
  48293. * @param culling defines backface culling state
  48294. * @param zOffset defines the value to apply to zOffset (0 by default)
  48295. * @param force defines if states must be applied even if cache is up to date
  48296. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48297. */
  48298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48299. /**
  48300. * Set the value of an uniform to an array of int32
  48301. * @param uniform defines the webGL uniform location where to store the value
  48302. * @param array defines the array of int32 to store
  48303. */
  48304. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48305. /**
  48306. * Set the value of an uniform to an array of int32 (stored as vec2)
  48307. * @param uniform defines the webGL uniform location where to store the value
  48308. * @param array defines the array of int32 to store
  48309. */
  48310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48311. /**
  48312. * Set the value of an uniform to an array of int32 (stored as vec3)
  48313. * @param uniform defines the webGL uniform location where to store the value
  48314. * @param array defines the array of int32 to store
  48315. */
  48316. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48317. /**
  48318. * Set the value of an uniform to an array of int32 (stored as vec4)
  48319. * @param uniform defines the webGL uniform location where to store the value
  48320. * @param array defines the array of int32 to store
  48321. */
  48322. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48323. /**
  48324. * Set the value of an uniform to an array of float32
  48325. * @param uniform defines the webGL uniform location where to store the value
  48326. * @param array defines the array of float32 to store
  48327. */
  48328. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48329. /**
  48330. * Set the value of an uniform to an array of float32 (stored as vec2)
  48331. * @param uniform defines the webGL uniform location where to store the value
  48332. * @param array defines the array of float32 to store
  48333. */
  48334. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48335. /**
  48336. * Set the value of an uniform to an array of float32 (stored as vec3)
  48337. * @param uniform defines the webGL uniform location where to store the value
  48338. * @param array defines the array of float32 to store
  48339. */
  48340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48341. /**
  48342. * Set the value of an uniform to an array of float32 (stored as vec4)
  48343. * @param uniform defines the webGL uniform location where to store the value
  48344. * @param array defines the array of float32 to store
  48345. */
  48346. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48347. /**
  48348. * Set the value of an uniform to an array of number
  48349. * @param uniform defines the webGL uniform location where to store the value
  48350. * @param array defines the array of number to store
  48351. */
  48352. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48353. /**
  48354. * Set the value of an uniform to an array of number (stored as vec2)
  48355. * @param uniform defines the webGL uniform location where to store the value
  48356. * @param array defines the array of number to store
  48357. */
  48358. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48359. /**
  48360. * Set the value of an uniform to an array of number (stored as vec3)
  48361. * @param uniform defines the webGL uniform location where to store the value
  48362. * @param array defines the array of number to store
  48363. */
  48364. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48365. /**
  48366. * Set the value of an uniform to an array of number (stored as vec4)
  48367. * @param uniform defines the webGL uniform location where to store the value
  48368. * @param array defines the array of number to store
  48369. */
  48370. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48371. /**
  48372. * Set the value of an uniform to an array of float32 (stored as matrices)
  48373. * @param uniform defines the webGL uniform location where to store the value
  48374. * @param matrices defines the array of float32 to store
  48375. */
  48376. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48377. /**
  48378. * Set the value of an uniform to a matrix (3x3)
  48379. * @param uniform defines the webGL uniform location where to store the value
  48380. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48381. */
  48382. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48383. /**
  48384. * Set the value of an uniform to a matrix (2x2)
  48385. * @param uniform defines the webGL uniform location where to store the value
  48386. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48387. */
  48388. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48389. /**
  48390. * Set the value of an uniform to a number (float)
  48391. * @param uniform defines the webGL uniform location where to store the value
  48392. * @param value defines the float number to store
  48393. */
  48394. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48395. /**
  48396. * Set the value of an uniform to a vec2
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param x defines the 1st component of the value
  48399. * @param y defines the 2nd component of the value
  48400. */
  48401. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48402. /**
  48403. * Set the value of an uniform to a vec3
  48404. * @param uniform defines the webGL uniform location where to store the value
  48405. * @param x defines the 1st component of the value
  48406. * @param y defines the 2nd component of the value
  48407. * @param z defines the 3rd component of the value
  48408. */
  48409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48410. /**
  48411. * Set the value of an uniform to a boolean
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param bool defines the boolean to store
  48414. */
  48415. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48416. /**
  48417. * Set the value of an uniform to a vec4
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param x defines the 1st component of the value
  48420. * @param y defines the 2nd component of the value
  48421. * @param z defines the 3rd component of the value
  48422. * @param w defines the 4th component of the value
  48423. */
  48424. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48425. /**
  48426. * Sets the current alpha mode
  48427. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48428. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48430. */
  48431. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48432. /**
  48433. * Bind webGl buffers directly to the webGL context
  48434. * @param vertexBuffers defines the vertex buffer to bind
  48435. * @param indexBuffer defines the index buffer to bind
  48436. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48437. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48438. * @param effect defines the effect associated with the vertex buffer
  48439. */
  48440. bindBuffers(vertexBuffers: {
  48441. [key: string]: VertexBuffer;
  48442. }, indexBuffer: DataBuffer, effect: Effect): void;
  48443. /**
  48444. * Force the entire cache to be cleared
  48445. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48446. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48447. */
  48448. wipeCaches(bruteForce?: boolean): void;
  48449. /**
  48450. * Send a draw order
  48451. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48452. * @param indexStart defines the starting index
  48453. * @param indexCount defines the number of index to draw
  48454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48455. */
  48456. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48457. /**
  48458. * Draw a list of indexed primitives
  48459. * @param fillMode defines the primitive to use
  48460. * @param indexStart defines the starting index
  48461. * @param indexCount defines the number of index to draw
  48462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48463. */
  48464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48465. /**
  48466. * Draw a list of unindexed primitives
  48467. * @param fillMode defines the primitive to use
  48468. * @param verticesStart defines the index of first vertex to draw
  48469. * @param verticesCount defines the count of vertices to draw
  48470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48471. */
  48472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48473. /** @hidden */
  48474. _createTexture(): WebGLTexture;
  48475. /** @hidden */
  48476. _releaseTexture(texture: InternalTexture): void;
  48477. /**
  48478. * Usually called from Texture.ts.
  48479. * Passed information to create a WebGLTexture
  48480. * @param urlArg defines a value which contains one of the following:
  48481. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48482. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48483. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48485. * @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)
  48486. * @param scene needed for loading to the correct scene
  48487. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48488. * @param onLoad optional callback to be called upon successful completion
  48489. * @param onError optional callback to be called upon failure
  48490. * @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
  48491. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48492. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48493. * @param forcedExtension defines the extension to use to pick the right loader
  48494. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48496. */
  48497. 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;
  48498. /**
  48499. * Creates a new render target texture
  48500. * @param size defines the size of the texture
  48501. * @param options defines the options used to create the texture
  48502. * @returns a new render target texture stored in an InternalTexture
  48503. */
  48504. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48505. /**
  48506. * Update the sampling mode of a given texture
  48507. * @param samplingMode defines the required sampling mode
  48508. * @param texture defines the texture to update
  48509. */
  48510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48511. /**
  48512. * Binds the frame buffer to the specified texture.
  48513. * @param texture The texture to render to or null for the default canvas
  48514. * @param faceIndex The face of the texture to render to in case of cube texture
  48515. * @param requiredWidth The width of the target to render to
  48516. * @param requiredHeight The height of the target to render to
  48517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48518. * @param lodLevel defines le lod level to bind to the frame buffer
  48519. */
  48520. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48521. /**
  48522. * Unbind the current render target texture from the webGL context
  48523. * @param texture defines the render target texture to unbind
  48524. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48525. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48526. */
  48527. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48528. /**
  48529. * Creates a dynamic vertex buffer
  48530. * @param vertices the data for the dynamic vertex buffer
  48531. * @returns the new WebGL dynamic buffer
  48532. */
  48533. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48534. /**
  48535. * Update the content of a dynamic texture
  48536. * @param texture defines the texture to update
  48537. * @param canvas defines the canvas containing the source
  48538. * @param invertY defines if data must be stored with Y axis inverted
  48539. * @param premulAlpha defines if alpha is stored as premultiplied
  48540. * @param format defines the format of the data
  48541. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48542. */
  48543. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48544. /**
  48545. * Gets a boolean indicating if all created effects are ready
  48546. * @returns true if all effects are ready
  48547. */
  48548. areAllEffectsReady(): boolean;
  48549. /**
  48550. * @hidden
  48551. * Get the current error code of the webGL context
  48552. * @returns the error code
  48553. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48554. */
  48555. getError(): number;
  48556. /** @hidden */
  48557. _getUnpackAlignement(): number;
  48558. /** @hidden */
  48559. _unpackFlipY(value: boolean): void;
  48560. /**
  48561. * Update a dynamic index buffer
  48562. * @param indexBuffer defines the target index buffer
  48563. * @param indices defines the data to update
  48564. * @param offset defines the offset in the target index buffer where update should start
  48565. */
  48566. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48567. /**
  48568. * Updates a dynamic vertex buffer.
  48569. * @param vertexBuffer the vertex buffer to update
  48570. * @param vertices the data used to update the vertex buffer
  48571. * @param byteOffset the byte offset of the data (optional)
  48572. * @param byteLength the byte length of the data (optional)
  48573. */
  48574. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48575. /** @hidden */
  48576. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48577. /** @hidden */
  48578. _bindTexture(channel: number, texture: InternalTexture): void;
  48579. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48580. /**
  48581. * 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
  48582. */
  48583. releaseEffects(): void;
  48584. displayLoadingUI(): void;
  48585. hideLoadingUI(): void;
  48586. /** @hidden */
  48587. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48588. /** @hidden */
  48589. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48590. /** @hidden */
  48591. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48592. /** @hidden */
  48593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48594. }
  48595. }
  48596. declare module "babylonjs/Instrumentation/timeToken" {
  48597. import { Nullable } from "babylonjs/types";
  48598. /**
  48599. * @hidden
  48600. **/
  48601. export class _TimeToken {
  48602. _startTimeQuery: Nullable<WebGLQuery>;
  48603. _endTimeQuery: Nullable<WebGLQuery>;
  48604. _timeElapsedQuery: Nullable<WebGLQuery>;
  48605. _timeElapsedQueryEnded: boolean;
  48606. }
  48607. }
  48608. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48609. import { Nullable, int } from "babylonjs/types";
  48610. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48611. /** @hidden */
  48612. export class _OcclusionDataStorage {
  48613. /** @hidden */
  48614. occlusionInternalRetryCounter: number;
  48615. /** @hidden */
  48616. isOcclusionQueryInProgress: boolean;
  48617. /** @hidden */
  48618. isOccluded: boolean;
  48619. /** @hidden */
  48620. occlusionRetryCount: number;
  48621. /** @hidden */
  48622. occlusionType: number;
  48623. /** @hidden */
  48624. occlusionQueryAlgorithmType: number;
  48625. }
  48626. module "babylonjs/Engines/engine" {
  48627. interface Engine {
  48628. /**
  48629. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48630. * @return the new query
  48631. */
  48632. createQuery(): WebGLQuery;
  48633. /**
  48634. * Delete and release a webGL query
  48635. * @param query defines the query to delete
  48636. * @return the current engine
  48637. */
  48638. deleteQuery(query: WebGLQuery): Engine;
  48639. /**
  48640. * Check if a given query has resolved and got its value
  48641. * @param query defines the query to check
  48642. * @returns true if the query got its value
  48643. */
  48644. isQueryResultAvailable(query: WebGLQuery): boolean;
  48645. /**
  48646. * Gets the value of a given query
  48647. * @param query defines the query to check
  48648. * @returns the value of the query
  48649. */
  48650. getQueryResult(query: WebGLQuery): number;
  48651. /**
  48652. * Initiates an occlusion query
  48653. * @param algorithmType defines the algorithm to use
  48654. * @param query defines the query to use
  48655. * @returns the current engine
  48656. * @see http://doc.babylonjs.com/features/occlusionquery
  48657. */
  48658. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48659. /**
  48660. * Ends an occlusion query
  48661. * @see http://doc.babylonjs.com/features/occlusionquery
  48662. * @param algorithmType defines the algorithm to use
  48663. * @returns the current engine
  48664. */
  48665. endOcclusionQuery(algorithmType: number): Engine;
  48666. /**
  48667. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48668. * Please note that only one query can be issued at a time
  48669. * @returns a time token used to track the time span
  48670. */
  48671. startTimeQuery(): Nullable<_TimeToken>;
  48672. /**
  48673. * Ends a time query
  48674. * @param token defines the token used to measure the time span
  48675. * @returns the time spent (in ns)
  48676. */
  48677. endTimeQuery(token: _TimeToken): int;
  48678. /** @hidden */
  48679. _currentNonTimestampToken: Nullable<_TimeToken>;
  48680. /** @hidden */
  48681. _createTimeQuery(): WebGLQuery;
  48682. /** @hidden */
  48683. _deleteTimeQuery(query: WebGLQuery): void;
  48684. /** @hidden */
  48685. _getGlAlgorithmType(algorithmType: number): number;
  48686. /** @hidden */
  48687. _getTimeQueryResult(query: WebGLQuery): any;
  48688. /** @hidden */
  48689. _getTimeQueryAvailability(query: WebGLQuery): any;
  48690. }
  48691. }
  48692. module "babylonjs/Meshes/abstractMesh" {
  48693. interface AbstractMesh {
  48694. /**
  48695. * Backing filed
  48696. * @hidden
  48697. */
  48698. __occlusionDataStorage: _OcclusionDataStorage;
  48699. /**
  48700. * Access property
  48701. * @hidden
  48702. */
  48703. _occlusionDataStorage: _OcclusionDataStorage;
  48704. /**
  48705. * 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.
  48706. * The default value is -1 which means don't break the query and wait till the result
  48707. * @see http://doc.babylonjs.com/features/occlusionquery
  48708. */
  48709. occlusionRetryCount: number;
  48710. /**
  48711. * 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:
  48712. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48713. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48714. * * 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.
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. */
  48717. occlusionType: number;
  48718. /**
  48719. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48720. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48721. * * 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.
  48722. * @see http://doc.babylonjs.com/features/occlusionquery
  48723. */
  48724. occlusionQueryAlgorithmType: number;
  48725. /**
  48726. * 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
  48727. * @see http://doc.babylonjs.com/features/occlusionquery
  48728. */
  48729. isOccluded: boolean;
  48730. /**
  48731. * Flag to check the progress status of the query
  48732. * @see http://doc.babylonjs.com/features/occlusionquery
  48733. */
  48734. isOcclusionQueryInProgress: boolean;
  48735. }
  48736. }
  48737. }
  48738. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48739. import { Nullable } from "babylonjs/types";
  48740. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48741. /** @hidden */
  48742. export var _forceTransformFeedbackToBundle: boolean;
  48743. module "babylonjs/Engines/engine" {
  48744. interface Engine {
  48745. /**
  48746. * Creates a webGL transform feedback object
  48747. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48748. * @returns the webGL transform feedback object
  48749. */
  48750. createTransformFeedback(): WebGLTransformFeedback;
  48751. /**
  48752. * Delete a webGL transform feedback object
  48753. * @param value defines the webGL transform feedback object to delete
  48754. */
  48755. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48756. /**
  48757. * Bind a webGL transform feedback object to the webgl context
  48758. * @param value defines the webGL transform feedback object to bind
  48759. */
  48760. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48761. /**
  48762. * Begins a transform feedback operation
  48763. * @param usePoints defines if points or triangles must be used
  48764. */
  48765. beginTransformFeedback(usePoints: boolean): void;
  48766. /**
  48767. * Ends a transform feedback operation
  48768. */
  48769. endTransformFeedback(): void;
  48770. /**
  48771. * Specify the varyings to use with transform feedback
  48772. * @param program defines the associated webGL program
  48773. * @param value defines the list of strings representing the varying names
  48774. */
  48775. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48776. /**
  48777. * Bind a webGL buffer for a transform feedback operation
  48778. * @param value defines the webGL buffer to bind
  48779. */
  48780. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48781. }
  48782. }
  48783. }
  48784. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48785. import { Scene } from "babylonjs/scene";
  48786. import { Engine } from "babylonjs/Engines/engine";
  48787. import { Texture } from "babylonjs/Materials/Textures/texture";
  48788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48789. import "babylonjs/Engines/Extensions/engine.multiRender";
  48790. /**
  48791. * Creation options of the multi render target texture.
  48792. */
  48793. export interface IMultiRenderTargetOptions {
  48794. /**
  48795. * Define if the texture needs to create mip maps after render.
  48796. */
  48797. generateMipMaps?: boolean;
  48798. /**
  48799. * Define the types of all the draw buffers we want to create
  48800. */
  48801. types?: number[];
  48802. /**
  48803. * Define the sampling modes of all the draw buffers we want to create
  48804. */
  48805. samplingModes?: number[];
  48806. /**
  48807. * Define if a depth buffer is required
  48808. */
  48809. generateDepthBuffer?: boolean;
  48810. /**
  48811. * Define if a stencil buffer is required
  48812. */
  48813. generateStencilBuffer?: boolean;
  48814. /**
  48815. * Define if a depth texture is required instead of a depth buffer
  48816. */
  48817. generateDepthTexture?: boolean;
  48818. /**
  48819. * Define the number of desired draw buffers
  48820. */
  48821. textureCount?: number;
  48822. /**
  48823. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48824. */
  48825. doNotChangeAspectRatio?: boolean;
  48826. /**
  48827. * Define the default type of the buffers we are creating
  48828. */
  48829. defaultType?: number;
  48830. }
  48831. /**
  48832. * A multi render target, like a render target provides the ability to render to a texture.
  48833. * Unlike the render target, it can render to several draw buffers in one draw.
  48834. * This is specially interesting in deferred rendering or for any effects requiring more than
  48835. * just one color from a single pass.
  48836. */
  48837. export class MultiRenderTarget extends RenderTargetTexture {
  48838. private _internalTextures;
  48839. private _textures;
  48840. private _multiRenderTargetOptions;
  48841. /**
  48842. * Get if draw buffers are currently supported by the used hardware and browser.
  48843. */
  48844. get isSupported(): boolean;
  48845. /**
  48846. * Get the list of textures generated by the multi render target.
  48847. */
  48848. get textures(): Texture[];
  48849. /**
  48850. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48851. */
  48852. get depthTexture(): Texture;
  48853. /**
  48854. * Set the wrapping mode on U of all the textures we are rendering to.
  48855. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48856. */
  48857. set wrapU(wrap: number);
  48858. /**
  48859. * Set the wrapping mode on V of all the textures we are rendering to.
  48860. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48861. */
  48862. set wrapV(wrap: number);
  48863. /**
  48864. * Instantiate a new multi render target texture.
  48865. * A multi render target, like a render target provides the ability to render to a texture.
  48866. * Unlike the render target, it can render to several draw buffers in one draw.
  48867. * This is specially interesting in deferred rendering or for any effects requiring more than
  48868. * just one color from a single pass.
  48869. * @param name Define the name of the texture
  48870. * @param size Define the size of the buffers to render to
  48871. * @param count Define the number of target we are rendering into
  48872. * @param scene Define the scene the texture belongs to
  48873. * @param options Define the options used to create the multi render target
  48874. */
  48875. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48876. /** @hidden */
  48877. _rebuild(): void;
  48878. private _createInternalTextures;
  48879. private _createTextures;
  48880. /**
  48881. * Define the number of samples used if MSAA is enabled.
  48882. */
  48883. get samples(): number;
  48884. set samples(value: number);
  48885. /**
  48886. * Resize all the textures in the multi render target.
  48887. * Be carrefull as it will recreate all the data in the new texture.
  48888. * @param size Define the new size
  48889. */
  48890. resize(size: any): void;
  48891. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48892. /**
  48893. * Dispose the render targets and their associated resources
  48894. */
  48895. dispose(): void;
  48896. /**
  48897. * Release all the underlying texture used as draw buffers.
  48898. */
  48899. releaseInternalTextures(): void;
  48900. }
  48901. }
  48902. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48904. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48905. import { Nullable } from "babylonjs/types";
  48906. module "babylonjs/Engines/thinEngine" {
  48907. interface ThinEngine {
  48908. /**
  48909. * Unbind a list of render target textures from the webGL context
  48910. * This is used only when drawBuffer extension or webGL2 are active
  48911. * @param textures defines the render target textures to unbind
  48912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48914. */
  48915. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48916. /**
  48917. * Create a multi render target texture
  48918. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48919. * @param size defines the size of the texture
  48920. * @param options defines the creation options
  48921. * @returns the cube texture as an InternalTexture
  48922. */
  48923. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48924. /**
  48925. * Update the sample count for a given multiple render target texture
  48926. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48927. * @param textures defines the textures to update
  48928. * @param samples defines the sample count to set
  48929. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48930. */
  48931. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48932. }
  48933. }
  48934. }
  48935. declare module "babylonjs/Engines/Extensions/engine.views" {
  48936. import { Camera } from "babylonjs/Cameras/camera";
  48937. import { Nullable } from "babylonjs/types";
  48938. /**
  48939. * Class used to define an additional view for the engine
  48940. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48941. */
  48942. export class EngineView {
  48943. /** Defines the canvas where to render the view */
  48944. target: HTMLCanvasElement;
  48945. /** Defines an optional camera used to render the view (will use active camera else) */
  48946. camera?: Camera;
  48947. }
  48948. module "babylonjs/Engines/engine" {
  48949. interface Engine {
  48950. /**
  48951. * Gets or sets the HTML element to use for attaching events
  48952. */
  48953. inputElement: Nullable<HTMLElement>;
  48954. /**
  48955. * Gets the current engine view
  48956. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48957. */
  48958. activeView: Nullable<EngineView>;
  48959. /** Gets or sets the list of views */
  48960. views: EngineView[];
  48961. /**
  48962. * Register a new child canvas
  48963. * @param canvas defines the canvas to register
  48964. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48965. * @returns the associated view
  48966. */
  48967. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48968. /**
  48969. * Remove a registered child canvas
  48970. * @param canvas defines the canvas to remove
  48971. * @returns the current engine
  48972. */
  48973. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48974. }
  48975. }
  48976. }
  48977. declare module "babylonjs/Engines/Extensions/index" {
  48978. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48979. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48980. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48981. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48982. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48983. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48984. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48985. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48986. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48987. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48988. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48989. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48990. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48991. export * from "babylonjs/Engines/Extensions/engine.views";
  48992. }
  48993. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48994. import { Nullable } from "babylonjs/types";
  48995. /**
  48996. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48997. */
  48998. export interface CubeMapInfo {
  48999. /**
  49000. * The pixel array for the front face.
  49001. * This is stored in format, left to right, up to down format.
  49002. */
  49003. front: Nullable<ArrayBufferView>;
  49004. /**
  49005. * The pixel array for the back face.
  49006. * This is stored in format, left to right, up to down format.
  49007. */
  49008. back: Nullable<ArrayBufferView>;
  49009. /**
  49010. * The pixel array for the left face.
  49011. * This is stored in format, left to right, up to down format.
  49012. */
  49013. left: Nullable<ArrayBufferView>;
  49014. /**
  49015. * The pixel array for the right face.
  49016. * This is stored in format, left to right, up to down format.
  49017. */
  49018. right: Nullable<ArrayBufferView>;
  49019. /**
  49020. * The pixel array for the up face.
  49021. * This is stored in format, left to right, up to down format.
  49022. */
  49023. up: Nullable<ArrayBufferView>;
  49024. /**
  49025. * The pixel array for the down face.
  49026. * This is stored in format, left to right, up to down format.
  49027. */
  49028. down: Nullable<ArrayBufferView>;
  49029. /**
  49030. * The size of the cubemap stored.
  49031. *
  49032. * Each faces will be size * size pixels.
  49033. */
  49034. size: number;
  49035. /**
  49036. * The format of the texture.
  49037. *
  49038. * RGBA, RGB.
  49039. */
  49040. format: number;
  49041. /**
  49042. * The type of the texture data.
  49043. *
  49044. * UNSIGNED_INT, FLOAT.
  49045. */
  49046. type: number;
  49047. /**
  49048. * Specifies whether the texture is in gamma space.
  49049. */
  49050. gammaSpace: boolean;
  49051. }
  49052. /**
  49053. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49054. */
  49055. export class PanoramaToCubeMapTools {
  49056. private static FACE_FRONT;
  49057. private static FACE_BACK;
  49058. private static FACE_RIGHT;
  49059. private static FACE_LEFT;
  49060. private static FACE_DOWN;
  49061. private static FACE_UP;
  49062. /**
  49063. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49064. *
  49065. * @param float32Array The source data.
  49066. * @param inputWidth The width of the input panorama.
  49067. * @param inputHeight The height of the input panorama.
  49068. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49069. * @return The cubemap data
  49070. */
  49071. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49072. private static CreateCubemapTexture;
  49073. private static CalcProjectionSpherical;
  49074. }
  49075. }
  49076. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49077. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49079. import { Nullable } from "babylonjs/types";
  49080. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49081. /**
  49082. * Helper class dealing with the extraction of spherical polynomial dataArray
  49083. * from a cube map.
  49084. */
  49085. export class CubeMapToSphericalPolynomialTools {
  49086. private static FileFaces;
  49087. /**
  49088. * Converts a texture to the according Spherical Polynomial data.
  49089. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49090. *
  49091. * @param texture The texture to extract the information from.
  49092. * @return The Spherical Polynomial data.
  49093. */
  49094. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49095. /**
  49096. * Converts a cubemap to the according Spherical Polynomial data.
  49097. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49098. *
  49099. * @param cubeInfo The Cube map to extract the information from.
  49100. * @return The Spherical Polynomial data.
  49101. */
  49102. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49103. }
  49104. }
  49105. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49106. import { Nullable } from "babylonjs/types";
  49107. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49108. module "babylonjs/Materials/Textures/baseTexture" {
  49109. interface BaseTexture {
  49110. /**
  49111. * Get the polynomial representation of the texture data.
  49112. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49113. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49114. */
  49115. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49116. }
  49117. }
  49118. }
  49119. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49121. /** @hidden */
  49122. export var rgbdEncodePixelShader: {
  49123. name: string;
  49124. shader: string;
  49125. };
  49126. }
  49127. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49129. /** @hidden */
  49130. export var rgbdDecodePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module "babylonjs/Misc/environmentTextureTools" {
  49136. import { Nullable } from "babylonjs/types";
  49137. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49139. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49140. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49141. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49142. import "babylonjs/Shaders/rgbdEncode.fragment";
  49143. import "babylonjs/Shaders/rgbdDecode.fragment";
  49144. /**
  49145. * Raw texture data and descriptor sufficient for WebGL texture upload
  49146. */
  49147. export interface EnvironmentTextureInfo {
  49148. /**
  49149. * Version of the environment map
  49150. */
  49151. version: number;
  49152. /**
  49153. * Width of image
  49154. */
  49155. width: number;
  49156. /**
  49157. * Irradiance information stored in the file.
  49158. */
  49159. irradiance: any;
  49160. /**
  49161. * Specular information stored in the file.
  49162. */
  49163. specular: any;
  49164. }
  49165. /**
  49166. * Defines One Image in the file. It requires only the position in the file
  49167. * as well as the length.
  49168. */
  49169. interface BufferImageData {
  49170. /**
  49171. * Length of the image data.
  49172. */
  49173. length: number;
  49174. /**
  49175. * Position of the data from the null terminator delimiting the end of the JSON.
  49176. */
  49177. position: number;
  49178. }
  49179. /**
  49180. * Defines the specular data enclosed in the file.
  49181. * This corresponds to the version 1 of the data.
  49182. */
  49183. export interface EnvironmentTextureSpecularInfoV1 {
  49184. /**
  49185. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49186. */
  49187. specularDataPosition?: number;
  49188. /**
  49189. * This contains all the images data needed to reconstruct the cubemap.
  49190. */
  49191. mipmaps: Array<BufferImageData>;
  49192. /**
  49193. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49194. */
  49195. lodGenerationScale: number;
  49196. }
  49197. /**
  49198. * Sets of helpers addressing the serialization and deserialization of environment texture
  49199. * stored in a BabylonJS env file.
  49200. * Those files are usually stored as .env files.
  49201. */
  49202. export class EnvironmentTextureTools {
  49203. /**
  49204. * Magic number identifying the env file.
  49205. */
  49206. private static _MagicBytes;
  49207. /**
  49208. * Gets the environment info from an env file.
  49209. * @param data The array buffer containing the .env bytes.
  49210. * @returns the environment file info (the json header) if successfully parsed.
  49211. */
  49212. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49213. /**
  49214. * Creates an environment texture from a loaded cube texture.
  49215. * @param texture defines the cube texture to convert in env file
  49216. * @return a promise containing the environment data if succesfull.
  49217. */
  49218. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49219. /**
  49220. * Creates a JSON representation of the spherical data.
  49221. * @param texture defines the texture containing the polynomials
  49222. * @return the JSON representation of the spherical info
  49223. */
  49224. private static _CreateEnvTextureIrradiance;
  49225. /**
  49226. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49227. * @param data the image data
  49228. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49229. * @return the views described by info providing access to the underlying buffer
  49230. */
  49231. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49232. /**
  49233. * Uploads the texture info contained in the env file to the GPU.
  49234. * @param texture defines the internal texture to upload to
  49235. * @param data defines the data to load
  49236. * @param info defines the texture info retrieved through the GetEnvInfo method
  49237. * @returns a promise
  49238. */
  49239. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49240. private static _OnImageReadyAsync;
  49241. /**
  49242. * Uploads the levels of image data to the GPU.
  49243. * @param texture defines the internal texture to upload to
  49244. * @param imageData defines the array buffer views of image data [mipmap][face]
  49245. * @returns a promise
  49246. */
  49247. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49248. /**
  49249. * Uploads spherical polynomials information to the texture.
  49250. * @param texture defines the texture we are trying to upload the information to
  49251. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49252. */
  49253. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49254. /** @hidden */
  49255. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49256. }
  49257. }
  49258. declare module "babylonjs/Maths/math.vertexFormat" {
  49259. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49260. /**
  49261. * Contains position and normal vectors for a vertex
  49262. */
  49263. export class PositionNormalVertex {
  49264. /** the position of the vertex (defaut: 0,0,0) */
  49265. position: Vector3;
  49266. /** the normal of the vertex (defaut: 0,1,0) */
  49267. normal: Vector3;
  49268. /**
  49269. * Creates a PositionNormalVertex
  49270. * @param position the position of the vertex (defaut: 0,0,0)
  49271. * @param normal the normal of the vertex (defaut: 0,1,0)
  49272. */
  49273. constructor(
  49274. /** the position of the vertex (defaut: 0,0,0) */
  49275. position?: Vector3,
  49276. /** the normal of the vertex (defaut: 0,1,0) */
  49277. normal?: Vector3);
  49278. /**
  49279. * Clones the PositionNormalVertex
  49280. * @returns the cloned PositionNormalVertex
  49281. */
  49282. clone(): PositionNormalVertex;
  49283. }
  49284. /**
  49285. * Contains position, normal and uv vectors for a vertex
  49286. */
  49287. export class PositionNormalTextureVertex {
  49288. /** the position of the vertex (defaut: 0,0,0) */
  49289. position: Vector3;
  49290. /** the normal of the vertex (defaut: 0,1,0) */
  49291. normal: Vector3;
  49292. /** the uv of the vertex (default: 0,0) */
  49293. uv: Vector2;
  49294. /**
  49295. * Creates a PositionNormalTextureVertex
  49296. * @param position the position of the vertex (defaut: 0,0,0)
  49297. * @param normal the normal of the vertex (defaut: 0,1,0)
  49298. * @param uv the uv of the vertex (default: 0,0)
  49299. */
  49300. constructor(
  49301. /** the position of the vertex (defaut: 0,0,0) */
  49302. position?: Vector3,
  49303. /** the normal of the vertex (defaut: 0,1,0) */
  49304. normal?: Vector3,
  49305. /** the uv of the vertex (default: 0,0) */
  49306. uv?: Vector2);
  49307. /**
  49308. * Clones the PositionNormalTextureVertex
  49309. * @returns the cloned PositionNormalTextureVertex
  49310. */
  49311. clone(): PositionNormalTextureVertex;
  49312. }
  49313. }
  49314. declare module "babylonjs/Maths/math" {
  49315. export * from "babylonjs/Maths/math.axis";
  49316. export * from "babylonjs/Maths/math.color";
  49317. export * from "babylonjs/Maths/math.constants";
  49318. export * from "babylonjs/Maths/math.frustum";
  49319. export * from "babylonjs/Maths/math.path";
  49320. export * from "babylonjs/Maths/math.plane";
  49321. export * from "babylonjs/Maths/math.size";
  49322. export * from "babylonjs/Maths/math.vector";
  49323. export * from "babylonjs/Maths/math.vertexFormat";
  49324. export * from "babylonjs/Maths/math.viewport";
  49325. }
  49326. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49327. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49328. /** @hidden */
  49329. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49330. private _genericAttributeLocation;
  49331. private _varyingLocationCount;
  49332. private _varyingLocationMap;
  49333. private _replacements;
  49334. private _textureCount;
  49335. private _uniforms;
  49336. lineProcessor(line: string): string;
  49337. attributeProcessor(attribute: string): string;
  49338. varyingProcessor(varying: string, isFragment: boolean): string;
  49339. uniformProcessor(uniform: string): string;
  49340. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49341. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49342. }
  49343. }
  49344. declare module "babylonjs/Engines/nativeEngine" {
  49345. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49346. import { Engine } from "babylonjs/Engines/engine";
  49347. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49350. import { Effect } from "babylonjs/Materials/effect";
  49351. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49352. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49353. import { IColor4Like } from "babylonjs/Maths/math.like";
  49354. import { Scene } from "babylonjs/scene";
  49355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49356. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49357. /**
  49358. * Container for accessors for natively-stored mesh data buffers.
  49359. */
  49360. class NativeDataBuffer extends DataBuffer {
  49361. /**
  49362. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49363. */
  49364. nativeIndexBuffer?: any;
  49365. /**
  49366. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49367. */
  49368. nativeVertexBuffer?: any;
  49369. }
  49370. /** @hidden */
  49371. class NativeTexture extends InternalTexture {
  49372. getInternalTexture(): InternalTexture;
  49373. getViewCount(): number;
  49374. }
  49375. /** @hidden */
  49376. export class NativeEngine extends Engine {
  49377. private readonly _native;
  49378. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49379. private readonly INVALID_HANDLE;
  49380. getHardwareScalingLevel(): number;
  49381. constructor();
  49382. /**
  49383. * Can be used to override the current requestAnimationFrame requester.
  49384. * @hidden
  49385. */
  49386. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49387. /**
  49388. * Override default engine behavior.
  49389. * @param color
  49390. * @param backBuffer
  49391. * @param depth
  49392. * @param stencil
  49393. */
  49394. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49395. /**
  49396. * Gets host document
  49397. * @returns the host document object
  49398. */
  49399. getHostDocument(): Nullable<Document>;
  49400. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49401. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49402. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49403. recordVertexArrayObject(vertexBuffers: {
  49404. [key: string]: VertexBuffer;
  49405. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49406. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49407. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49408. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49409. /**
  49410. * Draw a list of indexed primitives
  49411. * @param fillMode defines the primitive to use
  49412. * @param indexStart defines the starting index
  49413. * @param indexCount defines the number of index to draw
  49414. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49415. */
  49416. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49417. /**
  49418. * Draw a list of unindexed primitives
  49419. * @param fillMode defines the primitive to use
  49420. * @param verticesStart defines the index of first vertex to draw
  49421. * @param verticesCount defines the count of vertices to draw
  49422. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49423. */
  49424. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49425. createPipelineContext(): IPipelineContext;
  49426. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49427. /** @hidden */
  49428. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49429. /** @hidden */
  49430. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49431. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49432. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49433. protected _setProgram(program: WebGLProgram): void;
  49434. _releaseEffect(effect: Effect): void;
  49435. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49436. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49437. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49438. bindSamplers(effect: Effect): void;
  49439. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49440. getRenderWidth(useScreen?: boolean): number;
  49441. getRenderHeight(useScreen?: boolean): number;
  49442. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49443. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49444. /**
  49445. * Set the z offset to apply to current rendering
  49446. * @param value defines the offset to apply
  49447. */
  49448. setZOffset(value: number): void;
  49449. /**
  49450. * Gets the current value of the zOffset
  49451. * @returns the current zOffset state
  49452. */
  49453. getZOffset(): number;
  49454. /**
  49455. * Enable or disable depth buffering
  49456. * @param enable defines the state to set
  49457. */
  49458. setDepthBuffer(enable: boolean): void;
  49459. /**
  49460. * Gets a boolean indicating if depth writing is enabled
  49461. * @returns the current depth writing state
  49462. */
  49463. getDepthWrite(): boolean;
  49464. /**
  49465. * Enable or disable depth writing
  49466. * @param enable defines the state to set
  49467. */
  49468. setDepthWrite(enable: boolean): void;
  49469. /**
  49470. * Enable or disable color writing
  49471. * @param enable defines the state to set
  49472. */
  49473. setColorWrite(enable: boolean): void;
  49474. /**
  49475. * Gets a boolean indicating if color writing is enabled
  49476. * @returns the current color writing state
  49477. */
  49478. getColorWrite(): boolean;
  49479. /**
  49480. * Sets alpha constants used by some alpha blending modes
  49481. * @param r defines the red component
  49482. * @param g defines the green component
  49483. * @param b defines the blue component
  49484. * @param a defines the alpha component
  49485. */
  49486. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49487. /**
  49488. * Sets the current alpha mode
  49489. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49490. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49491. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49492. */
  49493. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49494. /**
  49495. * Gets the current alpha mode
  49496. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49497. * @returns the current alpha mode
  49498. */
  49499. getAlphaMode(): number;
  49500. setInt(uniform: WebGLUniformLocation, int: number): void;
  49501. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49502. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49503. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49504. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49505. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49506. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49507. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49508. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49509. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49510. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49511. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49512. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49513. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49514. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49515. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49516. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49517. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49518. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49519. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49520. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49521. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49522. wipeCaches(bruteForce?: boolean): void;
  49523. _createTexture(): WebGLTexture;
  49524. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49525. /**
  49526. * Usually called from BABYLON.Texture.ts.
  49527. * Passed information to create a WebGLTexture
  49528. * @param urlArg defines a value which contains one of the following:
  49529. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49530. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49531. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49533. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49534. * @param scene needed for loading to the correct scene
  49535. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49536. * @param onLoad optional callback to be called upon successful completion
  49537. * @param onError optional callback to be called upon failure
  49538. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49539. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49540. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49541. * @param forcedExtension defines the extension to use to pick the right loader
  49542. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49543. */
  49544. 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;
  49545. /**
  49546. * Creates a cube texture
  49547. * @param rootUrl defines the url where the files to load is located
  49548. * @param scene defines the current scene
  49549. * @param files defines the list of files to load (1 per face)
  49550. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49551. * @param onLoad defines an optional callback raised when the texture is loaded
  49552. * @param onError defines an optional callback raised if there is an issue to load the texture
  49553. * @param format defines the format of the data
  49554. * @param forcedExtension defines the extension to use to pick the right loader
  49555. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49556. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49557. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49558. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49559. * @returns the cube texture as an InternalTexture
  49560. */
  49561. 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;
  49562. private _getSamplingFilter;
  49563. private static _GetNativeTextureFormat;
  49564. createRenderTargetTexture(size: number | {
  49565. width: number;
  49566. height: number;
  49567. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49568. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49570. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49571. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49572. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49573. /**
  49574. * Updates a dynamic vertex buffer.
  49575. * @param vertexBuffer the vertex buffer to update
  49576. * @param data the data used to update the vertex buffer
  49577. * @param byteOffset the byte offset of the data (optional)
  49578. * @param byteLength the byte length of the data (optional)
  49579. */
  49580. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49581. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49582. private _updateAnisotropicLevel;
  49583. private _getAddressMode;
  49584. /** @hidden */
  49585. _bindTexture(channel: number, texture: InternalTexture): void;
  49586. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49587. releaseEffects(): void;
  49588. /** @hidden */
  49589. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49590. /** @hidden */
  49591. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49592. /** @hidden */
  49593. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49594. /** @hidden */
  49595. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49596. }
  49597. }
  49598. declare module "babylonjs/Engines/index" {
  49599. export * from "babylonjs/Engines/constants";
  49600. export * from "babylonjs/Engines/engineCapabilities";
  49601. export * from "babylonjs/Engines/instancingAttributeInfo";
  49602. export * from "babylonjs/Engines/thinEngine";
  49603. export * from "babylonjs/Engines/engine";
  49604. export * from "babylonjs/Engines/engineStore";
  49605. export * from "babylonjs/Engines/nullEngine";
  49606. export * from "babylonjs/Engines/Extensions/index";
  49607. export * from "babylonjs/Engines/IPipelineContext";
  49608. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49609. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49610. export * from "babylonjs/Engines/nativeEngine";
  49611. }
  49612. declare module "babylonjs/Events/clipboardEvents" {
  49613. /**
  49614. * Gather the list of clipboard event types as constants.
  49615. */
  49616. export class ClipboardEventTypes {
  49617. /**
  49618. * The clipboard event is fired when a copy command is active (pressed).
  49619. */
  49620. static readonly COPY: number;
  49621. /**
  49622. * The clipboard event is fired when a cut command is active (pressed).
  49623. */
  49624. static readonly CUT: number;
  49625. /**
  49626. * The clipboard event is fired when a paste command is active (pressed).
  49627. */
  49628. static readonly PASTE: number;
  49629. }
  49630. /**
  49631. * This class is used to store clipboard related info for the onClipboardObservable event.
  49632. */
  49633. export class ClipboardInfo {
  49634. /**
  49635. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49636. */
  49637. type: number;
  49638. /**
  49639. * Defines the related dom event
  49640. */
  49641. event: ClipboardEvent;
  49642. /**
  49643. *Creates an instance of ClipboardInfo.
  49644. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49645. * @param event Defines the related dom event
  49646. */
  49647. constructor(
  49648. /**
  49649. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49650. */
  49651. type: number,
  49652. /**
  49653. * Defines the related dom event
  49654. */
  49655. event: ClipboardEvent);
  49656. /**
  49657. * Get the clipboard event's type from the keycode.
  49658. * @param keyCode Defines the keyCode for the current keyboard event.
  49659. * @return {number}
  49660. */
  49661. static GetTypeFromCharacter(keyCode: number): number;
  49662. }
  49663. }
  49664. declare module "babylonjs/Events/index" {
  49665. export * from "babylonjs/Events/keyboardEvents";
  49666. export * from "babylonjs/Events/pointerEvents";
  49667. export * from "babylonjs/Events/clipboardEvents";
  49668. }
  49669. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49670. import { Scene } from "babylonjs/scene";
  49671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49672. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49673. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49674. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49675. /**
  49676. * Google Daydream controller
  49677. */
  49678. export class DaydreamController extends WebVRController {
  49679. /**
  49680. * Base Url for the controller model.
  49681. */
  49682. static MODEL_BASE_URL: string;
  49683. /**
  49684. * File name for the controller model.
  49685. */
  49686. static MODEL_FILENAME: string;
  49687. /**
  49688. * Gamepad Id prefix used to identify Daydream Controller.
  49689. */
  49690. static readonly GAMEPAD_ID_PREFIX: string;
  49691. /**
  49692. * Creates a new DaydreamController from a gamepad
  49693. * @param vrGamepad the gamepad that the controller should be created from
  49694. */
  49695. constructor(vrGamepad: any);
  49696. /**
  49697. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49698. * @param scene scene in which to add meshes
  49699. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49700. */
  49701. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49702. /**
  49703. * Called once for each button that changed state since the last frame
  49704. * @param buttonIdx Which button index changed
  49705. * @param state New state of the button
  49706. * @param changes Which properties on the state changed since last frame
  49707. */
  49708. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49709. }
  49710. }
  49711. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49712. import { Scene } from "babylonjs/scene";
  49713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49714. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49715. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49716. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49717. /**
  49718. * Gear VR Controller
  49719. */
  49720. export class GearVRController extends WebVRController {
  49721. /**
  49722. * Base Url for the controller model.
  49723. */
  49724. static MODEL_BASE_URL: string;
  49725. /**
  49726. * File name for the controller model.
  49727. */
  49728. static MODEL_FILENAME: string;
  49729. /**
  49730. * Gamepad Id prefix used to identify this controller.
  49731. */
  49732. static readonly GAMEPAD_ID_PREFIX: string;
  49733. private readonly _buttonIndexToObservableNameMap;
  49734. /**
  49735. * Creates a new GearVRController from a gamepad
  49736. * @param vrGamepad the gamepad that the controller should be created from
  49737. */
  49738. constructor(vrGamepad: any);
  49739. /**
  49740. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49741. * @param scene scene in which to add meshes
  49742. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49743. */
  49744. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49745. /**
  49746. * Called once for each button that changed state since the last frame
  49747. * @param buttonIdx Which button index changed
  49748. * @param state New state of the button
  49749. * @param changes Which properties on the state changed since last frame
  49750. */
  49751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49752. }
  49753. }
  49754. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49755. import { Scene } from "babylonjs/scene";
  49756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49757. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49758. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49759. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49760. /**
  49761. * Generic Controller
  49762. */
  49763. export class GenericController extends WebVRController {
  49764. /**
  49765. * Base Url for the controller model.
  49766. */
  49767. static readonly MODEL_BASE_URL: string;
  49768. /**
  49769. * File name for the controller model.
  49770. */
  49771. static readonly MODEL_FILENAME: string;
  49772. /**
  49773. * Creates a new GenericController from a gamepad
  49774. * @param vrGamepad the gamepad that the controller should be created from
  49775. */
  49776. constructor(vrGamepad: any);
  49777. /**
  49778. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49779. * @param scene scene in which to add meshes
  49780. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49781. */
  49782. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49783. /**
  49784. * Called once for each button that changed state since the last frame
  49785. * @param buttonIdx Which button index changed
  49786. * @param state New state of the button
  49787. * @param changes Which properties on the state changed since last frame
  49788. */
  49789. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49790. }
  49791. }
  49792. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49793. import { Observable } from "babylonjs/Misc/observable";
  49794. import { Scene } from "babylonjs/scene";
  49795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49796. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49797. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49798. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49799. /**
  49800. * Oculus Touch Controller
  49801. */
  49802. export class OculusTouchController extends WebVRController {
  49803. /**
  49804. * Base Url for the controller model.
  49805. */
  49806. static MODEL_BASE_URL: string;
  49807. /**
  49808. * File name for the left controller model.
  49809. */
  49810. static MODEL_LEFT_FILENAME: string;
  49811. /**
  49812. * File name for the right controller model.
  49813. */
  49814. static MODEL_RIGHT_FILENAME: string;
  49815. /**
  49816. * Base Url for the Quest controller model.
  49817. */
  49818. static QUEST_MODEL_BASE_URL: string;
  49819. /**
  49820. * @hidden
  49821. * If the controllers are running on a device that needs the updated Quest controller models
  49822. */
  49823. static _IsQuest: boolean;
  49824. /**
  49825. * Fired when the secondary trigger on this controller is modified
  49826. */
  49827. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49828. /**
  49829. * Fired when the thumb rest on this controller is modified
  49830. */
  49831. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49832. /**
  49833. * Creates a new OculusTouchController from a gamepad
  49834. * @param vrGamepad the gamepad that the controller should be created from
  49835. */
  49836. constructor(vrGamepad: any);
  49837. /**
  49838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49839. * @param scene scene in which to add meshes
  49840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49841. */
  49842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49843. /**
  49844. * Fired when the A button on this controller is modified
  49845. */
  49846. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49847. /**
  49848. * Fired when the B button on this controller is modified
  49849. */
  49850. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49851. /**
  49852. * Fired when the X button on this controller is modified
  49853. */
  49854. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49855. /**
  49856. * Fired when the Y button on this controller is modified
  49857. */
  49858. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49859. /**
  49860. * Called once for each button that changed state since the last frame
  49861. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49862. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49863. * 2) secondary trigger (same)
  49864. * 3) A (right) X (left), touch, pressed = value
  49865. * 4) B / Y
  49866. * 5) thumb rest
  49867. * @param buttonIdx Which button index changed
  49868. * @param state New state of the button
  49869. * @param changes Which properties on the state changed since last frame
  49870. */
  49871. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49872. }
  49873. }
  49874. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49875. import { Scene } from "babylonjs/scene";
  49876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49877. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49878. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49879. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49880. import { Observable } from "babylonjs/Misc/observable";
  49881. /**
  49882. * Vive Controller
  49883. */
  49884. export class ViveController extends WebVRController {
  49885. /**
  49886. * Base Url for the controller model.
  49887. */
  49888. static MODEL_BASE_URL: string;
  49889. /**
  49890. * File name for the controller model.
  49891. */
  49892. static MODEL_FILENAME: string;
  49893. /**
  49894. * Creates a new ViveController from a gamepad
  49895. * @param vrGamepad the gamepad that the controller should be created from
  49896. */
  49897. constructor(vrGamepad: any);
  49898. /**
  49899. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49900. * @param scene scene in which to add meshes
  49901. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49902. */
  49903. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49904. /**
  49905. * Fired when the left button on this controller is modified
  49906. */
  49907. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49908. /**
  49909. * Fired when the right button on this controller is modified
  49910. */
  49911. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49912. /**
  49913. * Fired when the menu button on this controller is modified
  49914. */
  49915. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49916. /**
  49917. * Called once for each button that changed state since the last frame
  49918. * Vive mapping:
  49919. * 0: touchpad
  49920. * 1: trigger
  49921. * 2: left AND right buttons
  49922. * 3: menu button
  49923. * @param buttonIdx Which button index changed
  49924. * @param state New state of the button
  49925. * @param changes Which properties on the state changed since last frame
  49926. */
  49927. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49928. }
  49929. }
  49930. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49931. import { Observable } from "babylonjs/Misc/observable";
  49932. import { Scene } from "babylonjs/scene";
  49933. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49934. import { Ray } from "babylonjs/Culling/ray";
  49935. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49936. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49937. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49938. /**
  49939. * Defines the WindowsMotionController object that the state of the windows motion controller
  49940. */
  49941. export class WindowsMotionController extends WebVRController {
  49942. /**
  49943. * The base url used to load the left and right controller models
  49944. */
  49945. static MODEL_BASE_URL: string;
  49946. /**
  49947. * The name of the left controller model file
  49948. */
  49949. static MODEL_LEFT_FILENAME: string;
  49950. /**
  49951. * The name of the right controller model file
  49952. */
  49953. static MODEL_RIGHT_FILENAME: string;
  49954. /**
  49955. * The controller name prefix for this controller type
  49956. */
  49957. static readonly GAMEPAD_ID_PREFIX: string;
  49958. /**
  49959. * The controller id pattern for this controller type
  49960. */
  49961. private static readonly GAMEPAD_ID_PATTERN;
  49962. private _loadedMeshInfo;
  49963. protected readonly _mapping: {
  49964. buttons: string[];
  49965. buttonMeshNames: {
  49966. 'trigger': string;
  49967. 'menu': string;
  49968. 'grip': string;
  49969. 'thumbstick': string;
  49970. 'trackpad': string;
  49971. };
  49972. buttonObservableNames: {
  49973. 'trigger': string;
  49974. 'menu': string;
  49975. 'grip': string;
  49976. 'thumbstick': string;
  49977. 'trackpad': string;
  49978. };
  49979. axisMeshNames: string[];
  49980. pointingPoseMeshName: string;
  49981. };
  49982. /**
  49983. * Fired when the trackpad on this controller is clicked
  49984. */
  49985. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49986. /**
  49987. * Fired when the trackpad on this controller is modified
  49988. */
  49989. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49990. /**
  49991. * The current x and y values of this controller's trackpad
  49992. */
  49993. trackpad: StickValues;
  49994. /**
  49995. * Creates a new WindowsMotionController from a gamepad
  49996. * @param vrGamepad the gamepad that the controller should be created from
  49997. */
  49998. constructor(vrGamepad: any);
  49999. /**
  50000. * Fired when the trigger on this controller is modified
  50001. */
  50002. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50003. /**
  50004. * Fired when the menu button on this controller is modified
  50005. */
  50006. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50007. /**
  50008. * Fired when the grip button on this controller is modified
  50009. */
  50010. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50011. /**
  50012. * Fired when the thumbstick button on this controller is modified
  50013. */
  50014. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50015. /**
  50016. * Fired when the touchpad button on this controller is modified
  50017. */
  50018. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50019. /**
  50020. * Fired when the touchpad values on this controller are modified
  50021. */
  50022. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50023. protected _updateTrackpad(): void;
  50024. /**
  50025. * Called once per frame by the engine.
  50026. */
  50027. update(): void;
  50028. /**
  50029. * Called once for each button that changed state since the last frame
  50030. * @param buttonIdx Which button index changed
  50031. * @param state New state of the button
  50032. * @param changes Which properties on the state changed since last frame
  50033. */
  50034. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50035. /**
  50036. * Moves the buttons on the controller mesh based on their current state
  50037. * @param buttonName the name of the button to move
  50038. * @param buttonValue the value of the button which determines the buttons new position
  50039. */
  50040. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50041. /**
  50042. * Moves the axis on the controller mesh based on its current state
  50043. * @param axis the index of the axis
  50044. * @param axisValue the value of the axis which determines the meshes new position
  50045. * @hidden
  50046. */
  50047. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50048. /**
  50049. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50050. * @param scene scene in which to add meshes
  50051. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50052. */
  50053. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50054. /**
  50055. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50056. * can be transformed by button presses and axes values, based on this._mapping.
  50057. *
  50058. * @param scene scene in which the meshes exist
  50059. * @param meshes list of meshes that make up the controller model to process
  50060. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50061. */
  50062. private processModel;
  50063. private createMeshInfo;
  50064. /**
  50065. * Gets the ray of the controller in the direction the controller is pointing
  50066. * @param length the length the resulting ray should be
  50067. * @returns a ray in the direction the controller is pointing
  50068. */
  50069. getForwardRay(length?: number): Ray;
  50070. /**
  50071. * Disposes of the controller
  50072. */
  50073. dispose(): void;
  50074. }
  50075. /**
  50076. * This class represents a new windows motion controller in XR.
  50077. */
  50078. export class XRWindowsMotionController extends WindowsMotionController {
  50079. /**
  50080. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50081. */
  50082. protected readonly _mapping: {
  50083. buttons: string[];
  50084. buttonMeshNames: {
  50085. 'trigger': string;
  50086. 'menu': string;
  50087. 'grip': string;
  50088. 'thumbstick': string;
  50089. 'trackpad': string;
  50090. };
  50091. buttonObservableNames: {
  50092. 'trigger': string;
  50093. 'menu': string;
  50094. 'grip': string;
  50095. 'thumbstick': string;
  50096. 'trackpad': string;
  50097. };
  50098. axisMeshNames: string[];
  50099. pointingPoseMeshName: string;
  50100. };
  50101. /**
  50102. * Construct a new XR-Based windows motion controller
  50103. *
  50104. * @param gamepadInfo the gamepad object from the browser
  50105. */
  50106. constructor(gamepadInfo: any);
  50107. /**
  50108. * holds the thumbstick values (X,Y)
  50109. */
  50110. thumbstickValues: StickValues;
  50111. /**
  50112. * Fired when the thumbstick on this controller is clicked
  50113. */
  50114. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50115. /**
  50116. * Fired when the thumbstick on this controller is modified
  50117. */
  50118. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50119. /**
  50120. * Fired when the touchpad button on this controller is modified
  50121. */
  50122. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50123. /**
  50124. * Fired when the touchpad values on this controller are modified
  50125. */
  50126. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50127. /**
  50128. * Fired when the thumbstick button on this controller is modified
  50129. * here to prevent breaking changes
  50130. */
  50131. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50132. /**
  50133. * updating the thumbstick(!) and not the trackpad.
  50134. * This is named this way due to the difference between WebVR and XR and to avoid
  50135. * changing the parent class.
  50136. */
  50137. protected _updateTrackpad(): void;
  50138. /**
  50139. * Disposes the class with joy
  50140. */
  50141. dispose(): void;
  50142. }
  50143. }
  50144. declare module "babylonjs/Gamepads/Controllers/index" {
  50145. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50146. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50147. export * from "babylonjs/Gamepads/Controllers/genericController";
  50148. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50149. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50150. export * from "babylonjs/Gamepads/Controllers/viveController";
  50151. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50152. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50153. }
  50154. declare module "babylonjs/Gamepads/index" {
  50155. export * from "babylonjs/Gamepads/Controllers/index";
  50156. export * from "babylonjs/Gamepads/gamepad";
  50157. export * from "babylonjs/Gamepads/gamepadManager";
  50158. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50159. export * from "babylonjs/Gamepads/xboxGamepad";
  50160. export * from "babylonjs/Gamepads/dualShockGamepad";
  50161. }
  50162. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50163. import { Scene } from "babylonjs/scene";
  50164. import { Vector4 } from "babylonjs/Maths/math.vector";
  50165. import { Color4 } from "babylonjs/Maths/math.color";
  50166. import { Mesh } from "babylonjs/Meshes/mesh";
  50167. import { Nullable } from "babylonjs/types";
  50168. /**
  50169. * Class containing static functions to help procedurally build meshes
  50170. */
  50171. export class PolyhedronBuilder {
  50172. /**
  50173. * Creates a polyhedron mesh
  50174. * * 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
  50175. * * The parameter `size` (positive float, default 1) sets the polygon size
  50176. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50177. * * 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`
  50178. * * 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
  50179. * * 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)`)
  50180. * * 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
  50181. * * 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
  50182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50185. * @param name defines the name of the mesh
  50186. * @param options defines the options used to create the mesh
  50187. * @param scene defines the hosting scene
  50188. * @returns the polyhedron mesh
  50189. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50190. */
  50191. static CreatePolyhedron(name: string, options: {
  50192. type?: number;
  50193. size?: number;
  50194. sizeX?: number;
  50195. sizeY?: number;
  50196. sizeZ?: number;
  50197. custom?: any;
  50198. faceUV?: Vector4[];
  50199. faceColors?: Color4[];
  50200. flat?: boolean;
  50201. updatable?: boolean;
  50202. sideOrientation?: number;
  50203. frontUVs?: Vector4;
  50204. backUVs?: Vector4;
  50205. }, scene?: Nullable<Scene>): Mesh;
  50206. }
  50207. }
  50208. declare module "babylonjs/Gizmos/scaleGizmo" {
  50209. import { Observable } from "babylonjs/Misc/observable";
  50210. import { Nullable } from "babylonjs/types";
  50211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50212. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50213. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50214. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50215. /**
  50216. * Gizmo that enables scaling a mesh along 3 axis
  50217. */
  50218. export class ScaleGizmo extends Gizmo {
  50219. /**
  50220. * Internal gizmo used for interactions on the x axis
  50221. */
  50222. xGizmo: AxisScaleGizmo;
  50223. /**
  50224. * Internal gizmo used for interactions on the y axis
  50225. */
  50226. yGizmo: AxisScaleGizmo;
  50227. /**
  50228. * Internal gizmo used for interactions on the z axis
  50229. */
  50230. zGizmo: AxisScaleGizmo;
  50231. /**
  50232. * Internal gizmo used to scale all axis equally
  50233. */
  50234. uniformScaleGizmo: AxisScaleGizmo;
  50235. private _meshAttached;
  50236. private _updateGizmoRotationToMatchAttachedMesh;
  50237. private _snapDistance;
  50238. private _scaleRatio;
  50239. private _uniformScalingMesh;
  50240. private _octahedron;
  50241. private _sensitivity;
  50242. /** Fires an event when any of it's sub gizmos are dragged */
  50243. onDragStartObservable: Observable<unknown>;
  50244. /** Fires an event when any of it's sub gizmos are released from dragging */
  50245. onDragEndObservable: Observable<unknown>;
  50246. get attachedMesh(): Nullable<AbstractMesh>;
  50247. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50248. /**
  50249. * Creates a ScaleGizmo
  50250. * @param gizmoLayer The utility layer the gizmo will be added to
  50251. */
  50252. constructor(gizmoLayer?: UtilityLayerRenderer);
  50253. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50254. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50255. /**
  50256. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50257. */
  50258. set snapDistance(value: number);
  50259. get snapDistance(): number;
  50260. /**
  50261. * Ratio for the scale of the gizmo (Default: 1)
  50262. */
  50263. set scaleRatio(value: number);
  50264. get scaleRatio(): number;
  50265. /**
  50266. * Sensitivity factor for dragging (Default: 1)
  50267. */
  50268. set sensitivity(value: number);
  50269. get sensitivity(): number;
  50270. /**
  50271. * Disposes of the gizmo
  50272. */
  50273. dispose(): void;
  50274. }
  50275. }
  50276. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50277. import { Observable } from "babylonjs/Misc/observable";
  50278. import { Nullable } from "babylonjs/types";
  50279. import { Vector3 } from "babylonjs/Maths/math.vector";
  50280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50281. import { Mesh } from "babylonjs/Meshes/mesh";
  50282. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50283. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50284. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50285. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50286. import { Color3 } from "babylonjs/Maths/math.color";
  50287. /**
  50288. * Single axis scale gizmo
  50289. */
  50290. export class AxisScaleGizmo extends Gizmo {
  50291. /**
  50292. * Drag behavior responsible for the gizmos dragging interactions
  50293. */
  50294. dragBehavior: PointerDragBehavior;
  50295. private _pointerObserver;
  50296. /**
  50297. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50298. */
  50299. snapDistance: number;
  50300. /**
  50301. * Event that fires each time the gizmo snaps to a new location.
  50302. * * snapDistance is the the change in distance
  50303. */
  50304. onSnapObservable: Observable<{
  50305. snapDistance: number;
  50306. }>;
  50307. /**
  50308. * If the scaling operation should be done on all axis (default: false)
  50309. */
  50310. uniformScaling: boolean;
  50311. /**
  50312. * Custom sensitivity value for the drag strength
  50313. */
  50314. sensitivity: number;
  50315. private _isEnabled;
  50316. private _parent;
  50317. private _arrow;
  50318. private _coloredMaterial;
  50319. private _hoverMaterial;
  50320. /**
  50321. * Creates an AxisScaleGizmo
  50322. * @param gizmoLayer The utility layer the gizmo will be added to
  50323. * @param dragAxis The axis which the gizmo will be able to scale on
  50324. * @param color The color of the gizmo
  50325. */
  50326. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50327. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50328. /**
  50329. * If the gizmo is enabled
  50330. */
  50331. set isEnabled(value: boolean);
  50332. get isEnabled(): boolean;
  50333. /**
  50334. * Disposes of the gizmo
  50335. */
  50336. dispose(): void;
  50337. /**
  50338. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50339. * @param mesh The mesh to replace the default mesh of the gizmo
  50340. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50341. */
  50342. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50343. }
  50344. }
  50345. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50346. import { Observable } from "babylonjs/Misc/observable";
  50347. import { Nullable } from "babylonjs/types";
  50348. import { Vector3 } from "babylonjs/Maths/math.vector";
  50349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50350. import { Mesh } from "babylonjs/Meshes/mesh";
  50351. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50352. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50353. import { Color3 } from "babylonjs/Maths/math.color";
  50354. import "babylonjs/Meshes/Builders/boxBuilder";
  50355. /**
  50356. * Bounding box gizmo
  50357. */
  50358. export class BoundingBoxGizmo extends Gizmo {
  50359. private _lineBoundingBox;
  50360. private _rotateSpheresParent;
  50361. private _scaleBoxesParent;
  50362. private _boundingDimensions;
  50363. private _renderObserver;
  50364. private _pointerObserver;
  50365. private _scaleDragSpeed;
  50366. private _tmpQuaternion;
  50367. private _tmpVector;
  50368. private _tmpRotationMatrix;
  50369. /**
  50370. * 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)
  50371. */
  50372. ignoreChildren: boolean;
  50373. /**
  50374. * 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)
  50375. */
  50376. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50377. /**
  50378. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50379. */
  50380. rotationSphereSize: number;
  50381. /**
  50382. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50383. */
  50384. scaleBoxSize: number;
  50385. /**
  50386. * 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)
  50387. */
  50388. fixedDragMeshScreenSize: boolean;
  50389. /**
  50390. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50391. */
  50392. fixedDragMeshScreenSizeDistanceFactor: number;
  50393. /**
  50394. * Fired when a rotation sphere or scale box is dragged
  50395. */
  50396. onDragStartObservable: Observable<{}>;
  50397. /**
  50398. * Fired when a scale box is dragged
  50399. */
  50400. onScaleBoxDragObservable: Observable<{}>;
  50401. /**
  50402. * Fired when a scale box drag is ended
  50403. */
  50404. onScaleBoxDragEndObservable: Observable<{}>;
  50405. /**
  50406. * Fired when a rotation sphere is dragged
  50407. */
  50408. onRotationSphereDragObservable: Observable<{}>;
  50409. /**
  50410. * Fired when a rotation sphere drag is ended
  50411. */
  50412. onRotationSphereDragEndObservable: Observable<{}>;
  50413. /**
  50414. * 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)
  50415. */
  50416. scalePivot: Nullable<Vector3>;
  50417. /**
  50418. * Mesh used as a pivot to rotate the attached mesh
  50419. */
  50420. private _anchorMesh;
  50421. private _existingMeshScale;
  50422. private _dragMesh;
  50423. private pointerDragBehavior;
  50424. private coloredMaterial;
  50425. private hoverColoredMaterial;
  50426. /**
  50427. * Sets the color of the bounding box gizmo
  50428. * @param color the color to set
  50429. */
  50430. setColor(color: Color3): void;
  50431. /**
  50432. * Creates an BoundingBoxGizmo
  50433. * @param gizmoLayer The utility layer the gizmo will be added to
  50434. * @param color The color of the gizmo
  50435. */
  50436. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50438. private _selectNode;
  50439. /**
  50440. * Updates the bounding box information for the Gizmo
  50441. */
  50442. updateBoundingBox(): void;
  50443. private _updateRotationSpheres;
  50444. private _updateScaleBoxes;
  50445. /**
  50446. * Enables rotation on the specified axis and disables rotation on the others
  50447. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50448. */
  50449. setEnabledRotationAxis(axis: string): void;
  50450. /**
  50451. * Enables/disables scaling
  50452. * @param enable if scaling should be enabled
  50453. */
  50454. setEnabledScaling(enable: boolean): void;
  50455. private _updateDummy;
  50456. /**
  50457. * Enables a pointer drag behavior on the bounding box of the gizmo
  50458. */
  50459. enableDragBehavior(): void;
  50460. /**
  50461. * Disposes of the gizmo
  50462. */
  50463. dispose(): void;
  50464. /**
  50465. * 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)
  50466. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50467. * @returns the bounding box mesh with the passed in mesh as a child
  50468. */
  50469. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50470. /**
  50471. * CustomMeshes are not supported by this gizmo
  50472. * @param mesh The mesh to replace the default mesh of the gizmo
  50473. */
  50474. setCustomMesh(mesh: Mesh): void;
  50475. }
  50476. }
  50477. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50478. import { Observable } from "babylonjs/Misc/observable";
  50479. import { Nullable } from "babylonjs/types";
  50480. import { Vector3 } from "babylonjs/Maths/math.vector";
  50481. import { Color3 } from "babylonjs/Maths/math.color";
  50482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50483. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50484. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50485. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50486. import "babylonjs/Meshes/Builders/linesBuilder";
  50487. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50488. /**
  50489. * Single plane rotation gizmo
  50490. */
  50491. export class PlaneRotationGizmo extends Gizmo {
  50492. /**
  50493. * Drag behavior responsible for the gizmos dragging interactions
  50494. */
  50495. dragBehavior: PointerDragBehavior;
  50496. private _pointerObserver;
  50497. /**
  50498. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50499. */
  50500. snapDistance: number;
  50501. /**
  50502. * Event that fires each time the gizmo snaps to a new location.
  50503. * * snapDistance is the the change in distance
  50504. */
  50505. onSnapObservable: Observable<{
  50506. snapDistance: number;
  50507. }>;
  50508. private _isEnabled;
  50509. private _parent;
  50510. /**
  50511. * Creates a PlaneRotationGizmo
  50512. * @param gizmoLayer The utility layer the gizmo will be added to
  50513. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50514. * @param color The color of the gizmo
  50515. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50516. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50517. */
  50518. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50520. /**
  50521. * If the gizmo is enabled
  50522. */
  50523. set isEnabled(value: boolean);
  50524. get isEnabled(): boolean;
  50525. /**
  50526. * Disposes of the gizmo
  50527. */
  50528. dispose(): void;
  50529. }
  50530. }
  50531. declare module "babylonjs/Gizmos/rotationGizmo" {
  50532. import { Observable } from "babylonjs/Misc/observable";
  50533. import { Nullable } from "babylonjs/types";
  50534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50535. import { Mesh } from "babylonjs/Meshes/mesh";
  50536. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50537. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50538. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50539. /**
  50540. * Gizmo that enables rotating a mesh along 3 axis
  50541. */
  50542. export class RotationGizmo extends Gizmo {
  50543. /**
  50544. * Internal gizmo used for interactions on the x axis
  50545. */
  50546. xGizmo: PlaneRotationGizmo;
  50547. /**
  50548. * Internal gizmo used for interactions on the y axis
  50549. */
  50550. yGizmo: PlaneRotationGizmo;
  50551. /**
  50552. * Internal gizmo used for interactions on the z axis
  50553. */
  50554. zGizmo: PlaneRotationGizmo;
  50555. /** Fires an event when any of it's sub gizmos are dragged */
  50556. onDragStartObservable: Observable<unknown>;
  50557. /** Fires an event when any of it's sub gizmos are released from dragging */
  50558. onDragEndObservable: Observable<unknown>;
  50559. private _meshAttached;
  50560. get attachedMesh(): Nullable<AbstractMesh>;
  50561. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50562. /**
  50563. * Creates a RotationGizmo
  50564. * @param gizmoLayer The utility layer the gizmo will be added to
  50565. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50566. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50567. */
  50568. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50569. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50570. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50571. /**
  50572. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50573. */
  50574. set snapDistance(value: number);
  50575. get snapDistance(): number;
  50576. /**
  50577. * Ratio for the scale of the gizmo (Default: 1)
  50578. */
  50579. set scaleRatio(value: number);
  50580. get scaleRatio(): number;
  50581. /**
  50582. * Disposes of the gizmo
  50583. */
  50584. dispose(): void;
  50585. /**
  50586. * CustomMeshes are not supported by this gizmo
  50587. * @param mesh The mesh to replace the default mesh of the gizmo
  50588. */
  50589. setCustomMesh(mesh: Mesh): void;
  50590. }
  50591. }
  50592. declare module "babylonjs/Gizmos/gizmoManager" {
  50593. import { Observable } from "babylonjs/Misc/observable";
  50594. import { Nullable } from "babylonjs/types";
  50595. import { Scene, IDisposable } from "babylonjs/scene";
  50596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50597. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50598. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50599. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50600. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50601. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50602. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50603. /**
  50604. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50605. */
  50606. export class GizmoManager implements IDisposable {
  50607. private scene;
  50608. /**
  50609. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50610. */
  50611. gizmos: {
  50612. positionGizmo: Nullable<PositionGizmo>;
  50613. rotationGizmo: Nullable<RotationGizmo>;
  50614. scaleGizmo: Nullable<ScaleGizmo>;
  50615. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50616. };
  50617. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50618. clearGizmoOnEmptyPointerEvent: boolean;
  50619. /** Fires an event when the manager is attached to a mesh */
  50620. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50621. private _gizmosEnabled;
  50622. private _pointerObserver;
  50623. private _attachedMesh;
  50624. private _boundingBoxColor;
  50625. private _defaultUtilityLayer;
  50626. private _defaultKeepDepthUtilityLayer;
  50627. /**
  50628. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50629. */
  50630. boundingBoxDragBehavior: SixDofDragBehavior;
  50631. /**
  50632. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50633. */
  50634. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50635. /**
  50636. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50637. */
  50638. usePointerToAttachGizmos: boolean;
  50639. /**
  50640. * Utility layer that the bounding box gizmo belongs to
  50641. */
  50642. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50643. /**
  50644. * Utility layer that all gizmos besides bounding box belong to
  50645. */
  50646. get utilityLayer(): UtilityLayerRenderer;
  50647. /**
  50648. * Instatiates a gizmo manager
  50649. * @param scene the scene to overlay the gizmos on top of
  50650. */
  50651. constructor(scene: Scene);
  50652. /**
  50653. * Attaches a set of gizmos to the specified mesh
  50654. * @param mesh The mesh the gizmo's should be attached to
  50655. */
  50656. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50657. /**
  50658. * If the position gizmo is enabled
  50659. */
  50660. set positionGizmoEnabled(value: boolean);
  50661. get positionGizmoEnabled(): boolean;
  50662. /**
  50663. * If the rotation gizmo is enabled
  50664. */
  50665. set rotationGizmoEnabled(value: boolean);
  50666. get rotationGizmoEnabled(): boolean;
  50667. /**
  50668. * If the scale gizmo is enabled
  50669. */
  50670. set scaleGizmoEnabled(value: boolean);
  50671. get scaleGizmoEnabled(): boolean;
  50672. /**
  50673. * If the boundingBox gizmo is enabled
  50674. */
  50675. set boundingBoxGizmoEnabled(value: boolean);
  50676. get boundingBoxGizmoEnabled(): boolean;
  50677. /**
  50678. * Disposes of the gizmo manager
  50679. */
  50680. dispose(): void;
  50681. }
  50682. }
  50683. declare module "babylonjs/Lights/directionalLight" {
  50684. import { Camera } from "babylonjs/Cameras/camera";
  50685. import { Scene } from "babylonjs/scene";
  50686. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50688. import { Light } from "babylonjs/Lights/light";
  50689. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50690. import { Effect } from "babylonjs/Materials/effect";
  50691. /**
  50692. * A directional light is defined by a direction (what a surprise!).
  50693. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50694. * 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.
  50695. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50696. */
  50697. export class DirectionalLight extends ShadowLight {
  50698. private _shadowFrustumSize;
  50699. /**
  50700. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50701. */
  50702. get shadowFrustumSize(): number;
  50703. /**
  50704. * Specifies a fix frustum size for the shadow generation.
  50705. */
  50706. set shadowFrustumSize(value: number);
  50707. private _shadowOrthoScale;
  50708. /**
  50709. * Gets the shadow projection scale against the optimal computed one.
  50710. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50711. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50712. */
  50713. get shadowOrthoScale(): number;
  50714. /**
  50715. * Sets the shadow projection scale against the optimal computed one.
  50716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50718. */
  50719. set shadowOrthoScale(value: number);
  50720. /**
  50721. * Automatically compute the projection matrix to best fit (including all the casters)
  50722. * on each frame.
  50723. */
  50724. autoUpdateExtends: boolean;
  50725. /**
  50726. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50727. * on each frame. autoUpdateExtends must be set to true for this to work
  50728. */
  50729. autoCalcShadowZBounds: boolean;
  50730. private _orthoLeft;
  50731. private _orthoRight;
  50732. private _orthoTop;
  50733. private _orthoBottom;
  50734. /**
  50735. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50736. * The directional light is emitted from everywhere in the given direction.
  50737. * It can cast shadows.
  50738. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50739. * @param name The friendly name of the light
  50740. * @param direction The direction of the light
  50741. * @param scene The scene the light belongs to
  50742. */
  50743. constructor(name: string, direction: Vector3, scene: Scene);
  50744. /**
  50745. * Returns the string "DirectionalLight".
  50746. * @return The class name
  50747. */
  50748. getClassName(): string;
  50749. /**
  50750. * Returns the integer 1.
  50751. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50752. */
  50753. getTypeID(): number;
  50754. /**
  50755. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50756. * Returns the DirectionalLight Shadow projection matrix.
  50757. */
  50758. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50759. /**
  50760. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50761. * Returns the DirectionalLight Shadow projection matrix.
  50762. */
  50763. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50764. /**
  50765. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50766. * Returns the DirectionalLight Shadow projection matrix.
  50767. */
  50768. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50769. protected _buildUniformLayout(): void;
  50770. /**
  50771. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50772. * @param effect The effect to update
  50773. * @param lightIndex The index of the light in the effect to update
  50774. * @returns The directional light
  50775. */
  50776. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50777. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50778. /**
  50779. * Gets the minZ used for shadow according to both the scene and the light.
  50780. *
  50781. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50782. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50783. * @param activeCamera The camera we are returning the min for
  50784. * @returns the depth min z
  50785. */
  50786. getDepthMinZ(activeCamera: Camera): number;
  50787. /**
  50788. * Gets the maxZ used for shadow according to both the scene and the light.
  50789. *
  50790. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50791. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50792. * @param activeCamera The camera we are returning the max for
  50793. * @returns the depth max z
  50794. */
  50795. getDepthMaxZ(activeCamera: Camera): number;
  50796. /**
  50797. * Prepares the list of defines specific to the light type.
  50798. * @param defines the list of defines
  50799. * @param lightIndex defines the index of the light for the effect
  50800. */
  50801. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50802. }
  50803. }
  50804. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50805. import { Mesh } from "babylonjs/Meshes/mesh";
  50806. /**
  50807. * Class containing static functions to help procedurally build meshes
  50808. */
  50809. export class HemisphereBuilder {
  50810. /**
  50811. * Creates a hemisphere mesh
  50812. * @param name defines the name of the mesh
  50813. * @param options defines the options used to create the mesh
  50814. * @param scene defines the hosting scene
  50815. * @returns the hemisphere mesh
  50816. */
  50817. static CreateHemisphere(name: string, options: {
  50818. segments?: number;
  50819. diameter?: number;
  50820. sideOrientation?: number;
  50821. }, scene: any): Mesh;
  50822. }
  50823. }
  50824. declare module "babylonjs/Lights/spotLight" {
  50825. import { Nullable } from "babylonjs/types";
  50826. import { Scene } from "babylonjs/scene";
  50827. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50829. import { Effect } from "babylonjs/Materials/effect";
  50830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50831. import { Light } from "babylonjs/Lights/light";
  50832. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50833. /**
  50834. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50835. * These values define a cone of light starting from the position, emitting toward the direction.
  50836. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50837. * and the exponent defines the speed of the decay of the light with distance (reach).
  50838. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50839. */
  50840. export class SpotLight extends ShadowLight {
  50841. private _angle;
  50842. private _innerAngle;
  50843. private _cosHalfAngle;
  50844. private _lightAngleScale;
  50845. private _lightAngleOffset;
  50846. /**
  50847. * Gets the cone angle of the spot light in Radians.
  50848. */
  50849. get angle(): number;
  50850. /**
  50851. * Sets the cone angle of the spot light in Radians.
  50852. */
  50853. set angle(value: number);
  50854. /**
  50855. * Only used in gltf falloff mode, this defines the angle where
  50856. * the directional falloff will start before cutting at angle which could be seen
  50857. * as outer angle.
  50858. */
  50859. get innerAngle(): number;
  50860. /**
  50861. * Only used in gltf falloff mode, this defines the angle where
  50862. * the directional falloff will start before cutting at angle which could be seen
  50863. * as outer angle.
  50864. */
  50865. set innerAngle(value: number);
  50866. private _shadowAngleScale;
  50867. /**
  50868. * Allows scaling the angle of the light for shadow generation only.
  50869. */
  50870. get shadowAngleScale(): number;
  50871. /**
  50872. * Allows scaling the angle of the light for shadow generation only.
  50873. */
  50874. set shadowAngleScale(value: number);
  50875. /**
  50876. * The light decay speed with the distance from the emission spot.
  50877. */
  50878. exponent: number;
  50879. private _projectionTextureMatrix;
  50880. /**
  50881. * Allows reading the projecton texture
  50882. */
  50883. get projectionTextureMatrix(): Matrix;
  50884. protected _projectionTextureLightNear: number;
  50885. /**
  50886. * Gets the near clip of the Spotlight for texture projection.
  50887. */
  50888. get projectionTextureLightNear(): number;
  50889. /**
  50890. * Sets the near clip of the Spotlight for texture projection.
  50891. */
  50892. set projectionTextureLightNear(value: number);
  50893. protected _projectionTextureLightFar: number;
  50894. /**
  50895. * Gets the far clip of the Spotlight for texture projection.
  50896. */
  50897. get projectionTextureLightFar(): number;
  50898. /**
  50899. * Sets the far clip of the Spotlight for texture projection.
  50900. */
  50901. set projectionTextureLightFar(value: number);
  50902. protected _projectionTextureUpDirection: Vector3;
  50903. /**
  50904. * Gets the Up vector of the Spotlight for texture projection.
  50905. */
  50906. get projectionTextureUpDirection(): Vector3;
  50907. /**
  50908. * Sets the Up vector of the Spotlight for texture projection.
  50909. */
  50910. set projectionTextureUpDirection(value: Vector3);
  50911. private _projectionTexture;
  50912. /**
  50913. * Gets the projection texture of the light.
  50914. */
  50915. get projectionTexture(): Nullable<BaseTexture>;
  50916. /**
  50917. * Sets the projection texture of the light.
  50918. */
  50919. set projectionTexture(value: Nullable<BaseTexture>);
  50920. private _projectionTextureViewLightDirty;
  50921. private _projectionTextureProjectionLightDirty;
  50922. private _projectionTextureDirty;
  50923. private _projectionTextureViewTargetVector;
  50924. private _projectionTextureViewLightMatrix;
  50925. private _projectionTextureProjectionLightMatrix;
  50926. private _projectionTextureScalingMatrix;
  50927. /**
  50928. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50929. * It can cast shadows.
  50930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50931. * @param name The light friendly name
  50932. * @param position The position of the spot light in the scene
  50933. * @param direction The direction of the light in the scene
  50934. * @param angle The cone angle of the light in Radians
  50935. * @param exponent The light decay speed with the distance from the emission spot
  50936. * @param scene The scene the lights belongs to
  50937. */
  50938. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50939. /**
  50940. * Returns the string "SpotLight".
  50941. * @returns the class name
  50942. */
  50943. getClassName(): string;
  50944. /**
  50945. * Returns the integer 2.
  50946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50947. */
  50948. getTypeID(): number;
  50949. /**
  50950. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50951. */
  50952. protected _setDirection(value: Vector3): void;
  50953. /**
  50954. * Overrides the position setter to recompute the projection texture view light Matrix.
  50955. */
  50956. protected _setPosition(value: Vector3): void;
  50957. /**
  50958. * 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.
  50959. * Returns the SpotLight.
  50960. */
  50961. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50962. protected _computeProjectionTextureViewLightMatrix(): void;
  50963. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50964. /**
  50965. * Main function for light texture projection matrix computing.
  50966. */
  50967. protected _computeProjectionTextureMatrix(): void;
  50968. protected _buildUniformLayout(): void;
  50969. private _computeAngleValues;
  50970. /**
  50971. * Sets the passed Effect "effect" with the Light textures.
  50972. * @param effect The effect to update
  50973. * @param lightIndex The index of the light in the effect to update
  50974. * @returns The light
  50975. */
  50976. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50977. /**
  50978. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50979. * @param effect The effect to update
  50980. * @param lightIndex The index of the light in the effect to update
  50981. * @returns The spot light
  50982. */
  50983. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50985. /**
  50986. * Disposes the light and the associated resources.
  50987. */
  50988. dispose(): void;
  50989. /**
  50990. * Prepares the list of defines specific to the light type.
  50991. * @param defines the list of defines
  50992. * @param lightIndex defines the index of the light for the effect
  50993. */
  50994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50995. }
  50996. }
  50997. declare module "babylonjs/Gizmos/lightGizmo" {
  50998. import { Nullable } from "babylonjs/types";
  50999. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51000. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51001. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51002. import { Light } from "babylonjs/Lights/light";
  51003. /**
  51004. * Gizmo that enables viewing a light
  51005. */
  51006. export class LightGizmo extends Gizmo {
  51007. private _lightMesh;
  51008. private _material;
  51009. private _cachedPosition;
  51010. private _cachedForward;
  51011. private _attachedMeshParent;
  51012. /**
  51013. * Creates a LightGizmo
  51014. * @param gizmoLayer The utility layer the gizmo will be added to
  51015. */
  51016. constructor(gizmoLayer?: UtilityLayerRenderer);
  51017. private _light;
  51018. /**
  51019. * The light that the gizmo is attached to
  51020. */
  51021. set light(light: Nullable<Light>);
  51022. get light(): Nullable<Light>;
  51023. /**
  51024. * Gets the material used to render the light gizmo
  51025. */
  51026. get material(): StandardMaterial;
  51027. /**
  51028. * @hidden
  51029. * Updates the gizmo to match the attached mesh's position/rotation
  51030. */
  51031. protected _update(): void;
  51032. private static _Scale;
  51033. /**
  51034. * Creates the lines for a light mesh
  51035. */
  51036. private static _CreateLightLines;
  51037. /**
  51038. * Disposes of the light gizmo
  51039. */
  51040. dispose(): void;
  51041. private static _CreateHemisphericLightMesh;
  51042. private static _CreatePointLightMesh;
  51043. private static _CreateSpotLightMesh;
  51044. private static _CreateDirectionalLightMesh;
  51045. }
  51046. }
  51047. declare module "babylonjs/Gizmos/index" {
  51048. export * from "babylonjs/Gizmos/axisDragGizmo";
  51049. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51050. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51051. export * from "babylonjs/Gizmos/gizmo";
  51052. export * from "babylonjs/Gizmos/gizmoManager";
  51053. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51054. export * from "babylonjs/Gizmos/positionGizmo";
  51055. export * from "babylonjs/Gizmos/rotationGizmo";
  51056. export * from "babylonjs/Gizmos/scaleGizmo";
  51057. export * from "babylonjs/Gizmos/lightGizmo";
  51058. export * from "babylonjs/Gizmos/planeDragGizmo";
  51059. }
  51060. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51061. /** @hidden */
  51062. export var backgroundFragmentDeclaration: {
  51063. name: string;
  51064. shader: string;
  51065. };
  51066. }
  51067. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51068. /** @hidden */
  51069. export var backgroundUboDeclaration: {
  51070. name: string;
  51071. shader: string;
  51072. };
  51073. }
  51074. declare module "babylonjs/Shaders/background.fragment" {
  51075. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51076. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51077. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51078. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51079. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51080. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51081. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51082. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51083. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51084. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51085. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51086. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51088. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51089. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51090. /** @hidden */
  51091. export var backgroundPixelShader: {
  51092. name: string;
  51093. shader: string;
  51094. };
  51095. }
  51096. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51097. /** @hidden */
  51098. export var backgroundVertexDeclaration: {
  51099. name: string;
  51100. shader: string;
  51101. };
  51102. }
  51103. declare module "babylonjs/Shaders/background.vertex" {
  51104. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51105. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51107. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51108. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51109. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51110. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51114. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51115. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51116. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51117. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51118. /** @hidden */
  51119. export var backgroundVertexShader: {
  51120. name: string;
  51121. shader: string;
  51122. };
  51123. }
  51124. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51125. import { Nullable, int, float } from "babylonjs/types";
  51126. import { Scene } from "babylonjs/scene";
  51127. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51128. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51130. import { Mesh } from "babylonjs/Meshes/mesh";
  51131. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51132. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51133. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51135. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51136. import { Color3 } from "babylonjs/Maths/math.color";
  51137. import "babylonjs/Shaders/background.fragment";
  51138. import "babylonjs/Shaders/background.vertex";
  51139. /**
  51140. * Background material used to create an efficient environement around your scene.
  51141. */
  51142. export class BackgroundMaterial extends PushMaterial {
  51143. /**
  51144. * Standard reflectance value at parallel view angle.
  51145. */
  51146. static StandardReflectance0: number;
  51147. /**
  51148. * Standard reflectance value at grazing angle.
  51149. */
  51150. static StandardReflectance90: number;
  51151. protected _primaryColor: Color3;
  51152. /**
  51153. * Key light Color (multiply against the environement texture)
  51154. */
  51155. primaryColor: Color3;
  51156. protected __perceptualColor: Nullable<Color3>;
  51157. /**
  51158. * Experimental Internal Use Only.
  51159. *
  51160. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51161. * This acts as a helper to set the primary color to a more "human friendly" value.
  51162. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51163. * output color as close as possible from the chosen value.
  51164. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51165. * part of lighting setup.)
  51166. */
  51167. get _perceptualColor(): Nullable<Color3>;
  51168. set _perceptualColor(value: Nullable<Color3>);
  51169. protected _primaryColorShadowLevel: float;
  51170. /**
  51171. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51172. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51173. */
  51174. get primaryColorShadowLevel(): float;
  51175. set primaryColorShadowLevel(value: float);
  51176. protected _primaryColorHighlightLevel: float;
  51177. /**
  51178. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51179. * The primary color is used at the level chosen to define what the white area would look.
  51180. */
  51181. get primaryColorHighlightLevel(): float;
  51182. set primaryColorHighlightLevel(value: float);
  51183. protected _reflectionTexture: Nullable<BaseTexture>;
  51184. /**
  51185. * Reflection Texture used in the material.
  51186. * Should be author in a specific way for the best result (refer to the documentation).
  51187. */
  51188. reflectionTexture: Nullable<BaseTexture>;
  51189. protected _reflectionBlur: float;
  51190. /**
  51191. * Reflection Texture level of blur.
  51192. *
  51193. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51194. * texture twice.
  51195. */
  51196. reflectionBlur: float;
  51197. protected _diffuseTexture: Nullable<BaseTexture>;
  51198. /**
  51199. * Diffuse Texture used in the material.
  51200. * Should be author in a specific way for the best result (refer to the documentation).
  51201. */
  51202. diffuseTexture: Nullable<BaseTexture>;
  51203. protected _shadowLights: Nullable<IShadowLight[]>;
  51204. /**
  51205. * Specify the list of lights casting shadow on the material.
  51206. * All scene shadow lights will be included if null.
  51207. */
  51208. shadowLights: Nullable<IShadowLight[]>;
  51209. protected _shadowLevel: float;
  51210. /**
  51211. * Helps adjusting the shadow to a softer level if required.
  51212. * 0 means black shadows and 1 means no shadows.
  51213. */
  51214. shadowLevel: float;
  51215. protected _sceneCenter: Vector3;
  51216. /**
  51217. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51218. * It is usually zero but might be interesting to modify according to your setup.
  51219. */
  51220. sceneCenter: Vector3;
  51221. protected _opacityFresnel: boolean;
  51222. /**
  51223. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51224. * This helps ensuring a nice transition when the camera goes under the ground.
  51225. */
  51226. opacityFresnel: boolean;
  51227. protected _reflectionFresnel: boolean;
  51228. /**
  51229. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51230. * This helps adding a mirror texture on the ground.
  51231. */
  51232. reflectionFresnel: boolean;
  51233. protected _reflectionFalloffDistance: number;
  51234. /**
  51235. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51236. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51237. */
  51238. reflectionFalloffDistance: number;
  51239. protected _reflectionAmount: number;
  51240. /**
  51241. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51242. */
  51243. reflectionAmount: number;
  51244. protected _reflectionReflectance0: number;
  51245. /**
  51246. * This specifies the weight of the reflection at grazing angle.
  51247. */
  51248. reflectionReflectance0: number;
  51249. protected _reflectionReflectance90: number;
  51250. /**
  51251. * This specifies the weight of the reflection at a perpendicular point of view.
  51252. */
  51253. reflectionReflectance90: number;
  51254. /**
  51255. * Sets the reflection reflectance fresnel values according to the default standard
  51256. * empirically know to work well :-)
  51257. */
  51258. set reflectionStandardFresnelWeight(value: number);
  51259. protected _useRGBColor: boolean;
  51260. /**
  51261. * Helps to directly use the maps channels instead of their level.
  51262. */
  51263. useRGBColor: boolean;
  51264. protected _enableNoise: boolean;
  51265. /**
  51266. * This helps reducing the banding effect that could occur on the background.
  51267. */
  51268. enableNoise: boolean;
  51269. /**
  51270. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51271. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51272. * Recommended to be keep at 1.0 except for special cases.
  51273. */
  51274. get fovMultiplier(): number;
  51275. set fovMultiplier(value: number);
  51276. private _fovMultiplier;
  51277. /**
  51278. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51279. */
  51280. useEquirectangularFOV: boolean;
  51281. private _maxSimultaneousLights;
  51282. /**
  51283. * Number of Simultaneous lights allowed on the material.
  51284. */
  51285. maxSimultaneousLights: int;
  51286. /**
  51287. * Default configuration related to image processing available in the Background Material.
  51288. */
  51289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51290. /**
  51291. * Keep track of the image processing observer to allow dispose and replace.
  51292. */
  51293. private _imageProcessingObserver;
  51294. /**
  51295. * Attaches a new image processing configuration to the PBR Material.
  51296. * @param configuration (if null the scene configuration will be use)
  51297. */
  51298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51299. /**
  51300. * Gets the image processing configuration used either in this material.
  51301. */
  51302. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51303. /**
  51304. * Sets the Default image processing configuration used either in the this material.
  51305. *
  51306. * If sets to null, the scene one is in use.
  51307. */
  51308. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51309. /**
  51310. * Gets wether the color curves effect is enabled.
  51311. */
  51312. get cameraColorCurvesEnabled(): boolean;
  51313. /**
  51314. * Sets wether the color curves effect is enabled.
  51315. */
  51316. set cameraColorCurvesEnabled(value: boolean);
  51317. /**
  51318. * Gets wether the color grading effect is enabled.
  51319. */
  51320. get cameraColorGradingEnabled(): boolean;
  51321. /**
  51322. * Gets wether the color grading effect is enabled.
  51323. */
  51324. set cameraColorGradingEnabled(value: boolean);
  51325. /**
  51326. * Gets wether tonemapping is enabled or not.
  51327. */
  51328. get cameraToneMappingEnabled(): boolean;
  51329. /**
  51330. * Sets wether tonemapping is enabled or not
  51331. */
  51332. set cameraToneMappingEnabled(value: boolean);
  51333. /**
  51334. * The camera exposure used on this material.
  51335. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51336. * This corresponds to a photographic exposure.
  51337. */
  51338. get cameraExposure(): float;
  51339. /**
  51340. * The camera exposure used on this material.
  51341. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51342. * This corresponds to a photographic exposure.
  51343. */
  51344. set cameraExposure(value: float);
  51345. /**
  51346. * Gets The camera contrast used on this material.
  51347. */
  51348. get cameraContrast(): float;
  51349. /**
  51350. * Sets The camera contrast used on this material.
  51351. */
  51352. set cameraContrast(value: float);
  51353. /**
  51354. * Gets the Color Grading 2D Lookup Texture.
  51355. */
  51356. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51357. /**
  51358. * Sets the Color Grading 2D Lookup Texture.
  51359. */
  51360. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51361. /**
  51362. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51363. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51364. * 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;
  51365. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51366. */
  51367. get cameraColorCurves(): Nullable<ColorCurves>;
  51368. /**
  51369. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51370. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51371. * 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;
  51372. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51373. */
  51374. set cameraColorCurves(value: Nullable<ColorCurves>);
  51375. /**
  51376. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51377. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51378. */
  51379. switchToBGR: boolean;
  51380. private _renderTargets;
  51381. private _reflectionControls;
  51382. private _white;
  51383. private _primaryShadowColor;
  51384. private _primaryHighlightColor;
  51385. /**
  51386. * Instantiates a Background Material in the given scene
  51387. * @param name The friendly name of the material
  51388. * @param scene The scene to add the material to
  51389. */
  51390. constructor(name: string, scene: Scene);
  51391. /**
  51392. * Gets a boolean indicating that current material needs to register RTT
  51393. */
  51394. get hasRenderTargetTextures(): boolean;
  51395. /**
  51396. * The entire material has been created in order to prevent overdraw.
  51397. * @returns false
  51398. */
  51399. needAlphaTesting(): boolean;
  51400. /**
  51401. * The entire material has been created in order to prevent overdraw.
  51402. * @returns true if blending is enable
  51403. */
  51404. needAlphaBlending(): boolean;
  51405. /**
  51406. * Checks wether the material is ready to be rendered for a given mesh.
  51407. * @param mesh The mesh to render
  51408. * @param subMesh The submesh to check against
  51409. * @param useInstances Specify wether or not the material is used with instances
  51410. * @returns true if all the dependencies are ready (Textures, Effects...)
  51411. */
  51412. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51413. /**
  51414. * Compute the primary color according to the chosen perceptual color.
  51415. */
  51416. private _computePrimaryColorFromPerceptualColor;
  51417. /**
  51418. * Compute the highlights and shadow colors according to their chosen levels.
  51419. */
  51420. private _computePrimaryColors;
  51421. /**
  51422. * Build the uniform buffer used in the material.
  51423. */
  51424. buildUniformLayout(): void;
  51425. /**
  51426. * Unbind the material.
  51427. */
  51428. unbind(): void;
  51429. /**
  51430. * Bind only the world matrix to the material.
  51431. * @param world The world matrix to bind.
  51432. */
  51433. bindOnlyWorldMatrix(world: Matrix): void;
  51434. /**
  51435. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51436. * @param world The world matrix to bind.
  51437. * @param subMesh The submesh to bind for.
  51438. */
  51439. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51440. /**
  51441. * Checks to see if a texture is used in the material.
  51442. * @param texture - Base texture to use.
  51443. * @returns - Boolean specifying if a texture is used in the material.
  51444. */
  51445. hasTexture(texture: BaseTexture): boolean;
  51446. /**
  51447. * Dispose the material.
  51448. * @param forceDisposeEffect Force disposal of the associated effect.
  51449. * @param forceDisposeTextures Force disposal of the associated textures.
  51450. */
  51451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51452. /**
  51453. * Clones the material.
  51454. * @param name The cloned name.
  51455. * @returns The cloned material.
  51456. */
  51457. clone(name: string): BackgroundMaterial;
  51458. /**
  51459. * Serializes the current material to its JSON representation.
  51460. * @returns The JSON representation.
  51461. */
  51462. serialize(): any;
  51463. /**
  51464. * Gets the class name of the material
  51465. * @returns "BackgroundMaterial"
  51466. */
  51467. getClassName(): string;
  51468. /**
  51469. * Parse a JSON input to create back a background material.
  51470. * @param source The JSON data to parse
  51471. * @param scene The scene to create the parsed material in
  51472. * @param rootUrl The root url of the assets the material depends upon
  51473. * @returns the instantiated BackgroundMaterial.
  51474. */
  51475. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51476. }
  51477. }
  51478. declare module "babylonjs/Helpers/environmentHelper" {
  51479. import { Observable } from "babylonjs/Misc/observable";
  51480. import { Nullable } from "babylonjs/types";
  51481. import { Scene } from "babylonjs/scene";
  51482. import { Vector3 } from "babylonjs/Maths/math.vector";
  51483. import { Color3 } from "babylonjs/Maths/math.color";
  51484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51485. import { Mesh } from "babylonjs/Meshes/mesh";
  51486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51487. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51488. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51489. import "babylonjs/Meshes/Builders/planeBuilder";
  51490. import "babylonjs/Meshes/Builders/boxBuilder";
  51491. /**
  51492. * Represents the different options available during the creation of
  51493. * a Environment helper.
  51494. *
  51495. * This can control the default ground, skybox and image processing setup of your scene.
  51496. */
  51497. export interface IEnvironmentHelperOptions {
  51498. /**
  51499. * Specifies whether or not to create a ground.
  51500. * True by default.
  51501. */
  51502. createGround: boolean;
  51503. /**
  51504. * Specifies the ground size.
  51505. * 15 by default.
  51506. */
  51507. groundSize: number;
  51508. /**
  51509. * The texture used on the ground for the main color.
  51510. * Comes from the BabylonJS CDN by default.
  51511. *
  51512. * Remarks: Can be either a texture or a url.
  51513. */
  51514. groundTexture: string | BaseTexture;
  51515. /**
  51516. * The color mixed in the ground texture by default.
  51517. * BabylonJS clearColor by default.
  51518. */
  51519. groundColor: Color3;
  51520. /**
  51521. * Specifies the ground opacity.
  51522. * 1 by default.
  51523. */
  51524. groundOpacity: number;
  51525. /**
  51526. * Enables the ground to receive shadows.
  51527. * True by default.
  51528. */
  51529. enableGroundShadow: boolean;
  51530. /**
  51531. * Helps preventing the shadow to be fully black on the ground.
  51532. * 0.5 by default.
  51533. */
  51534. groundShadowLevel: number;
  51535. /**
  51536. * Creates a mirror texture attach to the ground.
  51537. * false by default.
  51538. */
  51539. enableGroundMirror: boolean;
  51540. /**
  51541. * Specifies the ground mirror size ratio.
  51542. * 0.3 by default as the default kernel is 64.
  51543. */
  51544. groundMirrorSizeRatio: number;
  51545. /**
  51546. * Specifies the ground mirror blur kernel size.
  51547. * 64 by default.
  51548. */
  51549. groundMirrorBlurKernel: number;
  51550. /**
  51551. * Specifies the ground mirror visibility amount.
  51552. * 1 by default
  51553. */
  51554. groundMirrorAmount: number;
  51555. /**
  51556. * Specifies the ground mirror reflectance weight.
  51557. * This uses the standard weight of the background material to setup the fresnel effect
  51558. * of the mirror.
  51559. * 1 by default.
  51560. */
  51561. groundMirrorFresnelWeight: number;
  51562. /**
  51563. * Specifies the ground mirror Falloff distance.
  51564. * This can helps reducing the size of the reflection.
  51565. * 0 by Default.
  51566. */
  51567. groundMirrorFallOffDistance: number;
  51568. /**
  51569. * Specifies the ground mirror texture type.
  51570. * Unsigned Int by Default.
  51571. */
  51572. groundMirrorTextureType: number;
  51573. /**
  51574. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51575. * the shown objects.
  51576. */
  51577. groundYBias: number;
  51578. /**
  51579. * Specifies whether or not to create a skybox.
  51580. * True by default.
  51581. */
  51582. createSkybox: boolean;
  51583. /**
  51584. * Specifies the skybox size.
  51585. * 20 by default.
  51586. */
  51587. skyboxSize: number;
  51588. /**
  51589. * The texture used on the skybox for the main color.
  51590. * Comes from the BabylonJS CDN by default.
  51591. *
  51592. * Remarks: Can be either a texture or a url.
  51593. */
  51594. skyboxTexture: string | BaseTexture;
  51595. /**
  51596. * The color mixed in the skybox texture by default.
  51597. * BabylonJS clearColor by default.
  51598. */
  51599. skyboxColor: Color3;
  51600. /**
  51601. * The background rotation around the Y axis of the scene.
  51602. * This helps aligning the key lights of your scene with the background.
  51603. * 0 by default.
  51604. */
  51605. backgroundYRotation: number;
  51606. /**
  51607. * Compute automatically the size of the elements to best fit with the scene.
  51608. */
  51609. sizeAuto: boolean;
  51610. /**
  51611. * Default position of the rootMesh if autoSize is not true.
  51612. */
  51613. rootPosition: Vector3;
  51614. /**
  51615. * Sets up the image processing in the scene.
  51616. * true by default.
  51617. */
  51618. setupImageProcessing: boolean;
  51619. /**
  51620. * The texture used as your environment texture in the scene.
  51621. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51622. *
  51623. * Remarks: Can be either a texture or a url.
  51624. */
  51625. environmentTexture: string | BaseTexture;
  51626. /**
  51627. * The value of the exposure to apply to the scene.
  51628. * 0.6 by default if setupImageProcessing is true.
  51629. */
  51630. cameraExposure: number;
  51631. /**
  51632. * The value of the contrast to apply to the scene.
  51633. * 1.6 by default if setupImageProcessing is true.
  51634. */
  51635. cameraContrast: number;
  51636. /**
  51637. * Specifies whether or not tonemapping should be enabled in the scene.
  51638. * true by default if setupImageProcessing is true.
  51639. */
  51640. toneMappingEnabled: boolean;
  51641. }
  51642. /**
  51643. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51644. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51645. * It also helps with the default setup of your imageProcessing configuration.
  51646. */
  51647. export class EnvironmentHelper {
  51648. /**
  51649. * Default ground texture URL.
  51650. */
  51651. private static _groundTextureCDNUrl;
  51652. /**
  51653. * Default skybox texture URL.
  51654. */
  51655. private static _skyboxTextureCDNUrl;
  51656. /**
  51657. * Default environment texture URL.
  51658. */
  51659. private static _environmentTextureCDNUrl;
  51660. /**
  51661. * Creates the default options for the helper.
  51662. */
  51663. private static _getDefaultOptions;
  51664. private _rootMesh;
  51665. /**
  51666. * Gets the root mesh created by the helper.
  51667. */
  51668. get rootMesh(): Mesh;
  51669. private _skybox;
  51670. /**
  51671. * Gets the skybox created by the helper.
  51672. */
  51673. get skybox(): Nullable<Mesh>;
  51674. private _skyboxTexture;
  51675. /**
  51676. * Gets the skybox texture created by the helper.
  51677. */
  51678. get skyboxTexture(): Nullable<BaseTexture>;
  51679. private _skyboxMaterial;
  51680. /**
  51681. * Gets the skybox material created by the helper.
  51682. */
  51683. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51684. private _ground;
  51685. /**
  51686. * Gets the ground mesh created by the helper.
  51687. */
  51688. get ground(): Nullable<Mesh>;
  51689. private _groundTexture;
  51690. /**
  51691. * Gets the ground texture created by the helper.
  51692. */
  51693. get groundTexture(): Nullable<BaseTexture>;
  51694. private _groundMirror;
  51695. /**
  51696. * Gets the ground mirror created by the helper.
  51697. */
  51698. get groundMirror(): Nullable<MirrorTexture>;
  51699. /**
  51700. * Gets the ground mirror render list to helps pushing the meshes
  51701. * you wish in the ground reflection.
  51702. */
  51703. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51704. private _groundMaterial;
  51705. /**
  51706. * Gets the ground material created by the helper.
  51707. */
  51708. get groundMaterial(): Nullable<BackgroundMaterial>;
  51709. /**
  51710. * Stores the creation options.
  51711. */
  51712. private readonly _scene;
  51713. private _options;
  51714. /**
  51715. * This observable will be notified with any error during the creation of the environment,
  51716. * mainly texture creation errors.
  51717. */
  51718. onErrorObservable: Observable<{
  51719. message?: string;
  51720. exception?: any;
  51721. }>;
  51722. /**
  51723. * constructor
  51724. * @param options Defines the options we want to customize the helper
  51725. * @param scene The scene to add the material to
  51726. */
  51727. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51728. /**
  51729. * Updates the background according to the new options
  51730. * @param options
  51731. */
  51732. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51733. /**
  51734. * Sets the primary color of all the available elements.
  51735. * @param color the main color to affect to the ground and the background
  51736. */
  51737. setMainColor(color: Color3): void;
  51738. /**
  51739. * Setup the image processing according to the specified options.
  51740. */
  51741. private _setupImageProcessing;
  51742. /**
  51743. * Setup the environment texture according to the specified options.
  51744. */
  51745. private _setupEnvironmentTexture;
  51746. /**
  51747. * Setup the background according to the specified options.
  51748. */
  51749. private _setupBackground;
  51750. /**
  51751. * Get the scene sizes according to the setup.
  51752. */
  51753. private _getSceneSize;
  51754. /**
  51755. * Setup the ground according to the specified options.
  51756. */
  51757. private _setupGround;
  51758. /**
  51759. * Setup the ground material according to the specified options.
  51760. */
  51761. private _setupGroundMaterial;
  51762. /**
  51763. * Setup the ground diffuse texture according to the specified options.
  51764. */
  51765. private _setupGroundDiffuseTexture;
  51766. /**
  51767. * Setup the ground mirror texture according to the specified options.
  51768. */
  51769. private _setupGroundMirrorTexture;
  51770. /**
  51771. * Setup the ground to receive the mirror texture.
  51772. */
  51773. private _setupMirrorInGroundMaterial;
  51774. /**
  51775. * Setup the skybox according to the specified options.
  51776. */
  51777. private _setupSkybox;
  51778. /**
  51779. * Setup the skybox material according to the specified options.
  51780. */
  51781. private _setupSkyboxMaterial;
  51782. /**
  51783. * Setup the skybox reflection texture according to the specified options.
  51784. */
  51785. private _setupSkyboxReflectionTexture;
  51786. private _errorHandler;
  51787. /**
  51788. * Dispose all the elements created by the Helper.
  51789. */
  51790. dispose(): void;
  51791. }
  51792. }
  51793. declare module "babylonjs/Helpers/photoDome" {
  51794. import { Observable } from "babylonjs/Misc/observable";
  51795. import { Nullable } from "babylonjs/types";
  51796. import { Scene } from "babylonjs/scene";
  51797. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51798. import { Mesh } from "babylonjs/Meshes/mesh";
  51799. import { Texture } from "babylonjs/Materials/Textures/texture";
  51800. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51801. import "babylonjs/Meshes/Builders/sphereBuilder";
  51802. /**
  51803. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51804. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51805. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51806. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51807. */
  51808. export class PhotoDome extends TransformNode {
  51809. /**
  51810. * Define the image as a Monoscopic panoramic 360 image.
  51811. */
  51812. static readonly MODE_MONOSCOPIC: number;
  51813. /**
  51814. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51815. */
  51816. static readonly MODE_TOPBOTTOM: number;
  51817. /**
  51818. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51819. */
  51820. static readonly MODE_SIDEBYSIDE: number;
  51821. private _useDirectMapping;
  51822. /**
  51823. * The texture being displayed on the sphere
  51824. */
  51825. protected _photoTexture: Texture;
  51826. /**
  51827. * Gets or sets the texture being displayed on the sphere
  51828. */
  51829. get photoTexture(): Texture;
  51830. set photoTexture(value: Texture);
  51831. /**
  51832. * Observable raised when an error occured while loading the 360 image
  51833. */
  51834. onLoadErrorObservable: Observable<string>;
  51835. /**
  51836. * The skybox material
  51837. */
  51838. protected _material: BackgroundMaterial;
  51839. /**
  51840. * The surface used for the skybox
  51841. */
  51842. protected _mesh: Mesh;
  51843. /**
  51844. * Gets the mesh used for the skybox.
  51845. */
  51846. get mesh(): Mesh;
  51847. /**
  51848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51849. * Also see the options.resolution property.
  51850. */
  51851. get fovMultiplier(): number;
  51852. set fovMultiplier(value: number);
  51853. private _imageMode;
  51854. /**
  51855. * Gets or set the current video mode for the video. It can be:
  51856. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51857. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51858. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51859. */
  51860. get imageMode(): number;
  51861. set imageMode(value: number);
  51862. /**
  51863. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51864. * @param name Element's name, child elements will append suffixes for their own names.
  51865. * @param urlsOfPhoto defines the url of the photo to display
  51866. * @param options defines an object containing optional or exposed sub element properties
  51867. * @param onError defines a callback called when an error occured while loading the texture
  51868. */
  51869. constructor(name: string, urlOfPhoto: string, options: {
  51870. resolution?: number;
  51871. size?: number;
  51872. useDirectMapping?: boolean;
  51873. faceForward?: boolean;
  51874. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51875. private _onBeforeCameraRenderObserver;
  51876. private _changeImageMode;
  51877. /**
  51878. * Releases resources associated with this node.
  51879. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51880. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51881. */
  51882. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51883. }
  51884. }
  51885. declare module "babylonjs/Misc/rgbdTextureTools" {
  51886. import "babylonjs/Shaders/rgbdDecode.fragment";
  51887. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51888. import { Texture } from "babylonjs/Materials/Textures/texture";
  51889. /**
  51890. * Class used to host RGBD texture specific utilities
  51891. */
  51892. export class RGBDTextureTools {
  51893. /**
  51894. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51895. * @param texture the texture to expand.
  51896. */
  51897. static ExpandRGBDTexture(texture: Texture): void;
  51898. }
  51899. }
  51900. declare module "babylonjs/Misc/brdfTextureTools" {
  51901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51902. import { Scene } from "babylonjs/scene";
  51903. /**
  51904. * Class used to host texture specific utilities
  51905. */
  51906. export class BRDFTextureTools {
  51907. /**
  51908. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51909. * @param scene defines the hosting scene
  51910. * @returns the environment BRDF texture
  51911. */
  51912. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51913. private static _environmentBRDFBase64Texture;
  51914. }
  51915. }
  51916. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51917. import { Nullable } from "babylonjs/types";
  51918. import { Color3 } from "babylonjs/Maths/math.color";
  51919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51920. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51921. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51922. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51923. import { Engine } from "babylonjs/Engines/engine";
  51924. import { Scene } from "babylonjs/scene";
  51925. /**
  51926. * @hidden
  51927. */
  51928. export interface IMaterialClearCoatDefines {
  51929. CLEARCOAT: boolean;
  51930. CLEARCOAT_DEFAULTIOR: boolean;
  51931. CLEARCOAT_TEXTURE: boolean;
  51932. CLEARCOAT_TEXTUREDIRECTUV: number;
  51933. CLEARCOAT_BUMP: boolean;
  51934. CLEARCOAT_BUMPDIRECTUV: number;
  51935. CLEARCOAT_TINT: boolean;
  51936. CLEARCOAT_TINT_TEXTURE: boolean;
  51937. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51938. /** @hidden */
  51939. _areTexturesDirty: boolean;
  51940. }
  51941. /**
  51942. * Define the code related to the clear coat parameters of the pbr material.
  51943. */
  51944. export class PBRClearCoatConfiguration {
  51945. /**
  51946. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51947. * The default fits with a polyurethane material.
  51948. */
  51949. private static readonly _DefaultIndexOfRefraction;
  51950. private _isEnabled;
  51951. /**
  51952. * Defines if the clear coat is enabled in the material.
  51953. */
  51954. isEnabled: boolean;
  51955. /**
  51956. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51957. */
  51958. intensity: number;
  51959. /**
  51960. * Defines the clear coat layer roughness.
  51961. */
  51962. roughness: number;
  51963. private _indexOfRefraction;
  51964. /**
  51965. * Defines the index of refraction of the clear coat.
  51966. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51967. * The default fits with a polyurethane material.
  51968. * Changing the default value is more performance intensive.
  51969. */
  51970. indexOfRefraction: number;
  51971. private _texture;
  51972. /**
  51973. * Stores the clear coat values in a texture.
  51974. */
  51975. texture: Nullable<BaseTexture>;
  51976. private _bumpTexture;
  51977. /**
  51978. * Define the clear coat specific bump texture.
  51979. */
  51980. bumpTexture: Nullable<BaseTexture>;
  51981. private _isTintEnabled;
  51982. /**
  51983. * Defines if the clear coat tint is enabled in the material.
  51984. */
  51985. isTintEnabled: boolean;
  51986. /**
  51987. * Defines the clear coat tint of the material.
  51988. * This is only use if tint is enabled
  51989. */
  51990. tintColor: Color3;
  51991. /**
  51992. * Defines the distance at which the tint color should be found in the
  51993. * clear coat media.
  51994. * This is only use if tint is enabled
  51995. */
  51996. tintColorAtDistance: number;
  51997. /**
  51998. * Defines the clear coat layer thickness.
  51999. * This is only use if tint is enabled
  52000. */
  52001. tintThickness: number;
  52002. private _tintTexture;
  52003. /**
  52004. * Stores the clear tint values in a texture.
  52005. * rgb is tint
  52006. * a is a thickness factor
  52007. */
  52008. tintTexture: Nullable<BaseTexture>;
  52009. /** @hidden */
  52010. private _internalMarkAllSubMeshesAsTexturesDirty;
  52011. /** @hidden */
  52012. _markAllSubMeshesAsTexturesDirty(): void;
  52013. /**
  52014. * Instantiate a new istance of clear coat configuration.
  52015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52016. */
  52017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52018. /**
  52019. * Gets wehter the submesh is ready to be used or not.
  52020. * @param defines the list of "defines" to update.
  52021. * @param scene defines the scene the material belongs to.
  52022. * @param engine defines the engine the material belongs to.
  52023. * @param disableBumpMap defines wether the material disables bump or not.
  52024. * @returns - boolean indicating that the submesh is ready or not.
  52025. */
  52026. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52027. /**
  52028. * Checks to see if a texture is used in the material.
  52029. * @param defines the list of "defines" to update.
  52030. * @param scene defines the scene to the material belongs to.
  52031. */
  52032. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52033. /**
  52034. * Binds the material data.
  52035. * @param uniformBuffer defines the Uniform buffer to fill in.
  52036. * @param scene defines the scene the material belongs to.
  52037. * @param engine defines the engine the material belongs to.
  52038. * @param disableBumpMap defines wether the material disables bump or not.
  52039. * @param isFrozen defines wether the material is frozen or not.
  52040. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52041. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52042. */
  52043. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52044. /**
  52045. * Checks to see if a texture is used in the material.
  52046. * @param texture - Base texture to use.
  52047. * @returns - Boolean specifying if a texture is used in the material.
  52048. */
  52049. hasTexture(texture: BaseTexture): boolean;
  52050. /**
  52051. * Returns an array of the actively used textures.
  52052. * @param activeTextures Array of BaseTextures
  52053. */
  52054. getActiveTextures(activeTextures: BaseTexture[]): void;
  52055. /**
  52056. * Returns the animatable textures.
  52057. * @param animatables Array of animatable textures.
  52058. */
  52059. getAnimatables(animatables: IAnimatable[]): void;
  52060. /**
  52061. * Disposes the resources of the material.
  52062. * @param forceDisposeTextures - Forces the disposal of all textures.
  52063. */
  52064. dispose(forceDisposeTextures?: boolean): void;
  52065. /**
  52066. * Get the current class name of the texture useful for serialization or dynamic coding.
  52067. * @returns "PBRClearCoatConfiguration"
  52068. */
  52069. getClassName(): string;
  52070. /**
  52071. * Add fallbacks to the effect fallbacks list.
  52072. * @param defines defines the Base texture to use.
  52073. * @param fallbacks defines the current fallback list.
  52074. * @param currentRank defines the current fallback rank.
  52075. * @returns the new fallback rank.
  52076. */
  52077. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52078. /**
  52079. * Add the required uniforms to the current list.
  52080. * @param uniforms defines the current uniform list.
  52081. */
  52082. static AddUniforms(uniforms: string[]): void;
  52083. /**
  52084. * Add the required samplers to the current list.
  52085. * @param samplers defines the current sampler list.
  52086. */
  52087. static AddSamplers(samplers: string[]): void;
  52088. /**
  52089. * Add the required uniforms to the current buffer.
  52090. * @param uniformBuffer defines the current uniform buffer.
  52091. */
  52092. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52093. /**
  52094. * Makes a duplicate of the current configuration into another one.
  52095. * @param clearCoatConfiguration define the config where to copy the info
  52096. */
  52097. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52098. /**
  52099. * Serializes this clear coat configuration.
  52100. * @returns - An object with the serialized config.
  52101. */
  52102. serialize(): any;
  52103. /**
  52104. * Parses a anisotropy Configuration from a serialized object.
  52105. * @param source - Serialized object.
  52106. * @param scene Defines the scene we are parsing for
  52107. * @param rootUrl Defines the rootUrl to load from
  52108. */
  52109. parse(source: any, scene: Scene, rootUrl: string): void;
  52110. }
  52111. }
  52112. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52113. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52115. import { Vector2 } from "babylonjs/Maths/math.vector";
  52116. import { Scene } from "babylonjs/scene";
  52117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52118. import { Nullable } from "babylonjs/types";
  52119. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52120. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52121. /**
  52122. * @hidden
  52123. */
  52124. export interface IMaterialAnisotropicDefines {
  52125. ANISOTROPIC: boolean;
  52126. ANISOTROPIC_TEXTURE: boolean;
  52127. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52128. MAINUV1: boolean;
  52129. _areTexturesDirty: boolean;
  52130. _needUVs: boolean;
  52131. }
  52132. /**
  52133. * Define the code related to the anisotropic parameters of the pbr material.
  52134. */
  52135. export class PBRAnisotropicConfiguration {
  52136. private _isEnabled;
  52137. /**
  52138. * Defines if the anisotropy is enabled in the material.
  52139. */
  52140. isEnabled: boolean;
  52141. /**
  52142. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52143. */
  52144. intensity: number;
  52145. /**
  52146. * Defines if the effect is along the tangents, bitangents or in between.
  52147. * By default, the effect is "strectching" the highlights along the tangents.
  52148. */
  52149. direction: Vector2;
  52150. private _texture;
  52151. /**
  52152. * Stores the anisotropy values in a texture.
  52153. * rg is direction (like normal from -1 to 1)
  52154. * b is a intensity
  52155. */
  52156. texture: Nullable<BaseTexture>;
  52157. /** @hidden */
  52158. private _internalMarkAllSubMeshesAsTexturesDirty;
  52159. /** @hidden */
  52160. _markAllSubMeshesAsTexturesDirty(): void;
  52161. /**
  52162. * Instantiate a new istance of anisotropy configuration.
  52163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52164. */
  52165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52166. /**
  52167. * Specifies that the submesh is ready to be used.
  52168. * @param defines the list of "defines" to update.
  52169. * @param scene defines the scene the material belongs to.
  52170. * @returns - boolean indicating that the submesh is ready or not.
  52171. */
  52172. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52173. /**
  52174. * Checks to see if a texture is used in the material.
  52175. * @param defines the list of "defines" to update.
  52176. * @param mesh the mesh we are preparing the defines for.
  52177. * @param scene defines the scene the material belongs to.
  52178. */
  52179. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52180. /**
  52181. * Binds the material data.
  52182. * @param uniformBuffer defines the Uniform buffer to fill in.
  52183. * @param scene defines the scene the material belongs to.
  52184. * @param isFrozen defines wether the material is frozen or not.
  52185. */
  52186. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52187. /**
  52188. * Checks to see if a texture is used in the material.
  52189. * @param texture - Base texture to use.
  52190. * @returns - Boolean specifying if a texture is used in the material.
  52191. */
  52192. hasTexture(texture: BaseTexture): boolean;
  52193. /**
  52194. * Returns an array of the actively used textures.
  52195. * @param activeTextures Array of BaseTextures
  52196. */
  52197. getActiveTextures(activeTextures: BaseTexture[]): void;
  52198. /**
  52199. * Returns the animatable textures.
  52200. * @param animatables Array of animatable textures.
  52201. */
  52202. getAnimatables(animatables: IAnimatable[]): void;
  52203. /**
  52204. * Disposes the resources of the material.
  52205. * @param forceDisposeTextures - Forces the disposal of all textures.
  52206. */
  52207. dispose(forceDisposeTextures?: boolean): void;
  52208. /**
  52209. * Get the current class name of the texture useful for serialization or dynamic coding.
  52210. * @returns "PBRAnisotropicConfiguration"
  52211. */
  52212. getClassName(): string;
  52213. /**
  52214. * Add fallbacks to the effect fallbacks list.
  52215. * @param defines defines the Base texture to use.
  52216. * @param fallbacks defines the current fallback list.
  52217. * @param currentRank defines the current fallback rank.
  52218. * @returns the new fallback rank.
  52219. */
  52220. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52221. /**
  52222. * Add the required uniforms to the current list.
  52223. * @param uniforms defines the current uniform list.
  52224. */
  52225. static AddUniforms(uniforms: string[]): void;
  52226. /**
  52227. * Add the required uniforms to the current buffer.
  52228. * @param uniformBuffer defines the current uniform buffer.
  52229. */
  52230. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52231. /**
  52232. * Add the required samplers to the current list.
  52233. * @param samplers defines the current sampler list.
  52234. */
  52235. static AddSamplers(samplers: string[]): void;
  52236. /**
  52237. * Makes a duplicate of the current configuration into another one.
  52238. * @param anisotropicConfiguration define the config where to copy the info
  52239. */
  52240. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52241. /**
  52242. * Serializes this anisotropy configuration.
  52243. * @returns - An object with the serialized config.
  52244. */
  52245. serialize(): any;
  52246. /**
  52247. * Parses a anisotropy Configuration from a serialized object.
  52248. * @param source - Serialized object.
  52249. * @param scene Defines the scene we are parsing for
  52250. * @param rootUrl Defines the rootUrl to load from
  52251. */
  52252. parse(source: any, scene: Scene, rootUrl: string): void;
  52253. }
  52254. }
  52255. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52256. import { Scene } from "babylonjs/scene";
  52257. /**
  52258. * @hidden
  52259. */
  52260. export interface IMaterialBRDFDefines {
  52261. BRDF_V_HEIGHT_CORRELATED: boolean;
  52262. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52263. SPHERICAL_HARMONICS: boolean;
  52264. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52265. /** @hidden */
  52266. _areMiscDirty: boolean;
  52267. }
  52268. /**
  52269. * Define the code related to the BRDF parameters of the pbr material.
  52270. */
  52271. export class PBRBRDFConfiguration {
  52272. /**
  52273. * Default value used for the energy conservation.
  52274. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52275. */
  52276. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52277. /**
  52278. * Default value used for the Smith Visibility Height Correlated mode.
  52279. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52280. */
  52281. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52282. /**
  52283. * Default value used for the IBL diffuse part.
  52284. * This can help switching back to the polynomials mode globally which is a tiny bit
  52285. * less GPU intensive at the drawback of a lower quality.
  52286. */
  52287. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52288. /**
  52289. * Default value used for activating energy conservation for the specular workflow.
  52290. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52291. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52292. */
  52293. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52294. private _useEnergyConservation;
  52295. /**
  52296. * Defines if the material uses energy conservation.
  52297. */
  52298. useEnergyConservation: boolean;
  52299. private _useSmithVisibilityHeightCorrelated;
  52300. /**
  52301. * LEGACY Mode set to false
  52302. * Defines if the material uses height smith correlated visibility term.
  52303. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52304. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52305. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52306. * Not relying on height correlated will also disable energy conservation.
  52307. */
  52308. useSmithVisibilityHeightCorrelated: boolean;
  52309. private _useSphericalHarmonics;
  52310. /**
  52311. * LEGACY Mode set to false
  52312. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52313. * diffuse part of the IBL.
  52314. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52315. * to the ground truth.
  52316. */
  52317. useSphericalHarmonics: boolean;
  52318. private _useSpecularGlossinessInputEnergyConservation;
  52319. /**
  52320. * Defines if the material uses energy conservation, when the specular workflow is active.
  52321. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52322. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52323. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52324. */
  52325. useSpecularGlossinessInputEnergyConservation: boolean;
  52326. /** @hidden */
  52327. private _internalMarkAllSubMeshesAsMiscDirty;
  52328. /** @hidden */
  52329. _markAllSubMeshesAsMiscDirty(): void;
  52330. /**
  52331. * Instantiate a new istance of clear coat configuration.
  52332. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52333. */
  52334. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52335. /**
  52336. * Checks to see if a texture is used in the material.
  52337. * @param defines the list of "defines" to update.
  52338. */
  52339. prepareDefines(defines: IMaterialBRDFDefines): void;
  52340. /**
  52341. * Get the current class name of the texture useful for serialization or dynamic coding.
  52342. * @returns "PBRClearCoatConfiguration"
  52343. */
  52344. getClassName(): string;
  52345. /**
  52346. * Makes a duplicate of the current configuration into another one.
  52347. * @param brdfConfiguration define the config where to copy the info
  52348. */
  52349. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52350. /**
  52351. * Serializes this BRDF configuration.
  52352. * @returns - An object with the serialized config.
  52353. */
  52354. serialize(): any;
  52355. /**
  52356. * Parses a anisotropy Configuration from a serialized object.
  52357. * @param source - Serialized object.
  52358. * @param scene Defines the scene we are parsing for
  52359. * @param rootUrl Defines the rootUrl to load from
  52360. */
  52361. parse(source: any, scene: Scene, rootUrl: string): void;
  52362. }
  52363. }
  52364. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52365. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52366. import { Color3 } from "babylonjs/Maths/math.color";
  52367. import { Scene } from "babylonjs/scene";
  52368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52369. import { Nullable } from "babylonjs/types";
  52370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52371. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52372. /**
  52373. * @hidden
  52374. */
  52375. export interface IMaterialSheenDefines {
  52376. SHEEN: boolean;
  52377. SHEEN_TEXTURE: boolean;
  52378. SHEEN_TEXTUREDIRECTUV: number;
  52379. SHEEN_LINKWITHALBEDO: boolean;
  52380. /** @hidden */
  52381. _areTexturesDirty: boolean;
  52382. }
  52383. /**
  52384. * Define the code related to the Sheen parameters of the pbr material.
  52385. */
  52386. export class PBRSheenConfiguration {
  52387. private _isEnabled;
  52388. /**
  52389. * Defines if the material uses sheen.
  52390. */
  52391. isEnabled: boolean;
  52392. private _linkSheenWithAlbedo;
  52393. /**
  52394. * Defines if the sheen is linked to the sheen color.
  52395. */
  52396. linkSheenWithAlbedo: boolean;
  52397. /**
  52398. * Defines the sheen intensity.
  52399. */
  52400. intensity: number;
  52401. /**
  52402. * Defines the sheen color.
  52403. */
  52404. color: Color3;
  52405. private _texture;
  52406. /**
  52407. * Stores the sheen tint values in a texture.
  52408. * rgb is tint
  52409. * a is a intensity
  52410. */
  52411. texture: Nullable<BaseTexture>;
  52412. /** @hidden */
  52413. private _internalMarkAllSubMeshesAsTexturesDirty;
  52414. /** @hidden */
  52415. _markAllSubMeshesAsTexturesDirty(): void;
  52416. /**
  52417. * Instantiate a new istance of clear coat configuration.
  52418. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52419. */
  52420. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52421. /**
  52422. * Specifies that the submesh is ready to be used.
  52423. * @param defines the list of "defines" to update.
  52424. * @param scene defines the scene the material belongs to.
  52425. * @returns - boolean indicating that the submesh is ready or not.
  52426. */
  52427. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52428. /**
  52429. * Checks to see if a texture is used in the material.
  52430. * @param defines the list of "defines" to update.
  52431. * @param scene defines the scene the material belongs to.
  52432. */
  52433. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52434. /**
  52435. * Binds the material data.
  52436. * @param uniformBuffer defines the Uniform buffer to fill in.
  52437. * @param scene defines the scene the material belongs to.
  52438. * @param isFrozen defines wether the material is frozen or not.
  52439. */
  52440. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52441. /**
  52442. * Checks to see if a texture is used in the material.
  52443. * @param texture - Base texture to use.
  52444. * @returns - Boolean specifying if a texture is used in the material.
  52445. */
  52446. hasTexture(texture: BaseTexture): boolean;
  52447. /**
  52448. * Returns an array of the actively used textures.
  52449. * @param activeTextures Array of BaseTextures
  52450. */
  52451. getActiveTextures(activeTextures: BaseTexture[]): void;
  52452. /**
  52453. * Returns the animatable textures.
  52454. * @param animatables Array of animatable textures.
  52455. */
  52456. getAnimatables(animatables: IAnimatable[]): void;
  52457. /**
  52458. * Disposes the resources of the material.
  52459. * @param forceDisposeTextures - Forces the disposal of all textures.
  52460. */
  52461. dispose(forceDisposeTextures?: boolean): void;
  52462. /**
  52463. * Get the current class name of the texture useful for serialization or dynamic coding.
  52464. * @returns "PBRSheenConfiguration"
  52465. */
  52466. getClassName(): string;
  52467. /**
  52468. * Add fallbacks to the effect fallbacks list.
  52469. * @param defines defines the Base texture to use.
  52470. * @param fallbacks defines the current fallback list.
  52471. * @param currentRank defines the current fallback rank.
  52472. * @returns the new fallback rank.
  52473. */
  52474. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52475. /**
  52476. * Add the required uniforms to the current list.
  52477. * @param uniforms defines the current uniform list.
  52478. */
  52479. static AddUniforms(uniforms: string[]): void;
  52480. /**
  52481. * Add the required uniforms to the current buffer.
  52482. * @param uniformBuffer defines the current uniform buffer.
  52483. */
  52484. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52485. /**
  52486. * Add the required samplers to the current list.
  52487. * @param samplers defines the current sampler list.
  52488. */
  52489. static AddSamplers(samplers: string[]): void;
  52490. /**
  52491. * Makes a duplicate of the current configuration into another one.
  52492. * @param sheenConfiguration define the config where to copy the info
  52493. */
  52494. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52495. /**
  52496. * Serializes this BRDF configuration.
  52497. * @returns - An object with the serialized config.
  52498. */
  52499. serialize(): any;
  52500. /**
  52501. * Parses a anisotropy Configuration from a serialized object.
  52502. * @param source - Serialized object.
  52503. * @param scene Defines the scene we are parsing for
  52504. * @param rootUrl Defines the rootUrl to load from
  52505. */
  52506. parse(source: any, scene: Scene, rootUrl: string): void;
  52507. }
  52508. }
  52509. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52510. import { Nullable } from "babylonjs/types";
  52511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52512. import { Color3 } from "babylonjs/Maths/math.color";
  52513. import { SmartArray } from "babylonjs/Misc/smartArray";
  52514. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52515. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52516. import { Effect } from "babylonjs/Materials/effect";
  52517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52518. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52519. import { Engine } from "babylonjs/Engines/engine";
  52520. import { Scene } from "babylonjs/scene";
  52521. /**
  52522. * @hidden
  52523. */
  52524. export interface IMaterialSubSurfaceDefines {
  52525. SUBSURFACE: boolean;
  52526. SS_REFRACTION: boolean;
  52527. SS_TRANSLUCENCY: boolean;
  52528. SS_SCATERRING: boolean;
  52529. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52530. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52531. SS_REFRACTIONMAP_3D: boolean;
  52532. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52533. SS_LODINREFRACTIONALPHA: boolean;
  52534. SS_GAMMAREFRACTION: boolean;
  52535. SS_RGBDREFRACTION: boolean;
  52536. SS_LINEARSPECULARREFRACTION: boolean;
  52537. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52538. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52539. /** @hidden */
  52540. _areTexturesDirty: boolean;
  52541. }
  52542. /**
  52543. * Define the code related to the sub surface parameters of the pbr material.
  52544. */
  52545. export class PBRSubSurfaceConfiguration {
  52546. private _isRefractionEnabled;
  52547. /**
  52548. * Defines if the refraction is enabled in the material.
  52549. */
  52550. isRefractionEnabled: boolean;
  52551. private _isTranslucencyEnabled;
  52552. /**
  52553. * Defines if the translucency is enabled in the material.
  52554. */
  52555. isTranslucencyEnabled: boolean;
  52556. private _isScatteringEnabled;
  52557. /**
  52558. * Defines the refraction intensity of the material.
  52559. * The refraction when enabled replaces the Diffuse part of the material.
  52560. * The intensity helps transitionning between diffuse and refraction.
  52561. */
  52562. refractionIntensity: number;
  52563. /**
  52564. * Defines the translucency intensity of the material.
  52565. * When translucency has been enabled, this defines how much of the "translucency"
  52566. * is addded to the diffuse part of the material.
  52567. */
  52568. translucencyIntensity: number;
  52569. /**
  52570. * Defines the scattering intensity of the material.
  52571. * When scattering has been enabled, this defines how much of the "scattered light"
  52572. * is addded to the diffuse part of the material.
  52573. */
  52574. scatteringIntensity: number;
  52575. private _thicknessTexture;
  52576. /**
  52577. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52578. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52579. * 0 would mean minimumThickness
  52580. * 1 would mean maximumThickness
  52581. * The other channels might be use as a mask to vary the different effects intensity.
  52582. */
  52583. thicknessTexture: Nullable<BaseTexture>;
  52584. private _refractionTexture;
  52585. /**
  52586. * Defines the texture to use for refraction.
  52587. */
  52588. refractionTexture: Nullable<BaseTexture>;
  52589. private _indexOfRefraction;
  52590. /**
  52591. * Defines the index of refraction used in the material.
  52592. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52593. */
  52594. indexOfRefraction: number;
  52595. private _invertRefractionY;
  52596. /**
  52597. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52598. */
  52599. invertRefractionY: boolean;
  52600. private _linkRefractionWithTransparency;
  52601. /**
  52602. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52603. * Materials half opaque for instance using refraction could benefit from this control.
  52604. */
  52605. linkRefractionWithTransparency: boolean;
  52606. /**
  52607. * Defines the minimum thickness stored in the thickness map.
  52608. * If no thickness map is defined, this value will be used to simulate thickness.
  52609. */
  52610. minimumThickness: number;
  52611. /**
  52612. * Defines the maximum thickness stored in the thickness map.
  52613. */
  52614. maximumThickness: number;
  52615. /**
  52616. * Defines the volume tint of the material.
  52617. * This is used for both translucency and scattering.
  52618. */
  52619. tintColor: Color3;
  52620. /**
  52621. * Defines the distance at which the tint color should be found in the media.
  52622. * This is used for refraction only.
  52623. */
  52624. tintColorAtDistance: number;
  52625. /**
  52626. * Defines how far each channel transmit through the media.
  52627. * It is defined as a color to simplify it selection.
  52628. */
  52629. diffusionDistance: Color3;
  52630. private _useMaskFromThicknessTexture;
  52631. /**
  52632. * Stores the intensity of the different subsurface effects in the thickness texture.
  52633. * * the green channel is the translucency intensity.
  52634. * * the blue channel is the scattering intensity.
  52635. * * the alpha channel is the refraction intensity.
  52636. */
  52637. useMaskFromThicknessTexture: boolean;
  52638. /** @hidden */
  52639. private _internalMarkAllSubMeshesAsTexturesDirty;
  52640. /** @hidden */
  52641. _markAllSubMeshesAsTexturesDirty(): void;
  52642. /**
  52643. * Instantiate a new istance of sub surface configuration.
  52644. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52645. */
  52646. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52647. /**
  52648. * Gets wehter the submesh is ready to be used or not.
  52649. * @param defines the list of "defines" to update.
  52650. * @param scene defines the scene the material belongs to.
  52651. * @returns - boolean indicating that the submesh is ready or not.
  52652. */
  52653. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52654. /**
  52655. * Checks to see if a texture is used in the material.
  52656. * @param defines the list of "defines" to update.
  52657. * @param scene defines the scene to the material belongs to.
  52658. */
  52659. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52660. /**
  52661. * Binds the material data.
  52662. * @param uniformBuffer defines the Uniform buffer to fill in.
  52663. * @param scene defines the scene the material belongs to.
  52664. * @param engine defines the engine the material belongs to.
  52665. * @param isFrozen defines wether the material is frozen or not.
  52666. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52667. */
  52668. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52669. /**
  52670. * Unbinds the material from the mesh.
  52671. * @param activeEffect defines the effect that should be unbound from.
  52672. * @returns true if unbound, otherwise false
  52673. */
  52674. unbind(activeEffect: Effect): boolean;
  52675. /**
  52676. * Returns the texture used for refraction or null if none is used.
  52677. * @param scene defines the scene the material belongs to.
  52678. * @returns - Refraction texture if present. If no refraction texture and refraction
  52679. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52680. */
  52681. private _getRefractionTexture;
  52682. /**
  52683. * Returns true if alpha blending should be disabled.
  52684. */
  52685. get disableAlphaBlending(): boolean;
  52686. /**
  52687. * Fills the list of render target textures.
  52688. * @param renderTargets the list of render targets to update
  52689. */
  52690. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52691. /**
  52692. * Checks to see if a texture is used in the material.
  52693. * @param texture - Base texture to use.
  52694. * @returns - Boolean specifying if a texture is used in the material.
  52695. */
  52696. hasTexture(texture: BaseTexture): boolean;
  52697. /**
  52698. * Gets a boolean indicating that current material needs to register RTT
  52699. * @returns true if this uses a render target otherwise false.
  52700. */
  52701. hasRenderTargetTextures(): boolean;
  52702. /**
  52703. * Returns an array of the actively used textures.
  52704. * @param activeTextures Array of BaseTextures
  52705. */
  52706. getActiveTextures(activeTextures: BaseTexture[]): void;
  52707. /**
  52708. * Returns the animatable textures.
  52709. * @param animatables Array of animatable textures.
  52710. */
  52711. getAnimatables(animatables: IAnimatable[]): void;
  52712. /**
  52713. * Disposes the resources of the material.
  52714. * @param forceDisposeTextures - Forces the disposal of all textures.
  52715. */
  52716. dispose(forceDisposeTextures?: boolean): void;
  52717. /**
  52718. * Get the current class name of the texture useful for serialization or dynamic coding.
  52719. * @returns "PBRSubSurfaceConfiguration"
  52720. */
  52721. getClassName(): string;
  52722. /**
  52723. * Add fallbacks to the effect fallbacks list.
  52724. * @param defines defines the Base texture to use.
  52725. * @param fallbacks defines the current fallback list.
  52726. * @param currentRank defines the current fallback rank.
  52727. * @returns the new fallback rank.
  52728. */
  52729. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52730. /**
  52731. * Add the required uniforms to the current list.
  52732. * @param uniforms defines the current uniform list.
  52733. */
  52734. static AddUniforms(uniforms: string[]): void;
  52735. /**
  52736. * Add the required samplers to the current list.
  52737. * @param samplers defines the current sampler list.
  52738. */
  52739. static AddSamplers(samplers: string[]): void;
  52740. /**
  52741. * Add the required uniforms to the current buffer.
  52742. * @param uniformBuffer defines the current uniform buffer.
  52743. */
  52744. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52745. /**
  52746. * Makes a duplicate of the current configuration into another one.
  52747. * @param configuration define the config where to copy the info
  52748. */
  52749. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52750. /**
  52751. * Serializes this Sub Surface configuration.
  52752. * @returns - An object with the serialized config.
  52753. */
  52754. serialize(): any;
  52755. /**
  52756. * Parses a anisotropy Configuration from a serialized object.
  52757. * @param source - Serialized object.
  52758. * @param scene Defines the scene we are parsing for
  52759. * @param rootUrl Defines the rootUrl to load from
  52760. */
  52761. parse(source: any, scene: Scene, rootUrl: string): void;
  52762. }
  52763. }
  52764. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52765. /** @hidden */
  52766. export var pbrFragmentDeclaration: {
  52767. name: string;
  52768. shader: string;
  52769. };
  52770. }
  52771. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52772. /** @hidden */
  52773. export var pbrUboDeclaration: {
  52774. name: string;
  52775. shader: string;
  52776. };
  52777. }
  52778. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52779. /** @hidden */
  52780. export var pbrFragmentExtraDeclaration: {
  52781. name: string;
  52782. shader: string;
  52783. };
  52784. }
  52785. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52786. /** @hidden */
  52787. export var pbrFragmentSamplersDeclaration: {
  52788. name: string;
  52789. shader: string;
  52790. };
  52791. }
  52792. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52793. /** @hidden */
  52794. export var pbrHelperFunctions: {
  52795. name: string;
  52796. shader: string;
  52797. };
  52798. }
  52799. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52800. /** @hidden */
  52801. export var harmonicsFunctions: {
  52802. name: string;
  52803. shader: string;
  52804. };
  52805. }
  52806. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52807. /** @hidden */
  52808. export var pbrDirectLightingSetupFunctions: {
  52809. name: string;
  52810. shader: string;
  52811. };
  52812. }
  52813. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52814. /** @hidden */
  52815. export var pbrDirectLightingFalloffFunctions: {
  52816. name: string;
  52817. shader: string;
  52818. };
  52819. }
  52820. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52821. /** @hidden */
  52822. export var pbrBRDFFunctions: {
  52823. name: string;
  52824. shader: string;
  52825. };
  52826. }
  52827. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52828. /** @hidden */
  52829. export var pbrDirectLightingFunctions: {
  52830. name: string;
  52831. shader: string;
  52832. };
  52833. }
  52834. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52835. /** @hidden */
  52836. export var pbrIBLFunctions: {
  52837. name: string;
  52838. shader: string;
  52839. };
  52840. }
  52841. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52842. /** @hidden */
  52843. export var pbrDebug: {
  52844. name: string;
  52845. shader: string;
  52846. };
  52847. }
  52848. declare module "babylonjs/Shaders/pbr.fragment" {
  52849. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52850. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52851. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52853. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52854. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52855. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52856. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52858. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52859. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52860. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52861. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52864. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52865. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52866. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52869. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52870. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52871. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52872. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52873. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52874. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52875. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52876. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52877. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52878. /** @hidden */
  52879. export var pbrPixelShader: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52885. /** @hidden */
  52886. export var pbrVertexDeclaration: {
  52887. name: string;
  52888. shader: string;
  52889. };
  52890. }
  52891. declare module "babylonjs/Shaders/pbr.vertex" {
  52892. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52893. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52894. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52895. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52896. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52897. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52898. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52907. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52908. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52909. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52910. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52911. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52912. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52913. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52914. /** @hidden */
  52915. export var pbrVertexShader: {
  52916. name: string;
  52917. shader: string;
  52918. };
  52919. }
  52920. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52921. import { Nullable } from "babylonjs/types";
  52922. import { Scene } from "babylonjs/scene";
  52923. import { Matrix } from "babylonjs/Maths/math.vector";
  52924. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52926. import { Mesh } from "babylonjs/Meshes/mesh";
  52927. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52928. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52929. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52930. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52931. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52932. import { Color3 } from "babylonjs/Maths/math.color";
  52933. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52934. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52935. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52936. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52938. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52939. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52940. import "babylonjs/Shaders/pbr.fragment";
  52941. import "babylonjs/Shaders/pbr.vertex";
  52942. /**
  52943. * Manages the defines for the PBR Material.
  52944. * @hidden
  52945. */
  52946. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52947. PBR: boolean;
  52948. MAINUV1: boolean;
  52949. MAINUV2: boolean;
  52950. UV1: boolean;
  52951. UV2: boolean;
  52952. ALBEDO: boolean;
  52953. ALBEDODIRECTUV: number;
  52954. VERTEXCOLOR: boolean;
  52955. AMBIENT: boolean;
  52956. AMBIENTDIRECTUV: number;
  52957. AMBIENTINGRAYSCALE: boolean;
  52958. OPACITY: boolean;
  52959. VERTEXALPHA: boolean;
  52960. OPACITYDIRECTUV: number;
  52961. OPACITYRGB: boolean;
  52962. ALPHATEST: boolean;
  52963. DEPTHPREPASS: boolean;
  52964. ALPHABLEND: boolean;
  52965. ALPHAFROMALBEDO: boolean;
  52966. ALPHATESTVALUE: string;
  52967. SPECULAROVERALPHA: boolean;
  52968. RADIANCEOVERALPHA: boolean;
  52969. ALPHAFRESNEL: boolean;
  52970. LINEARALPHAFRESNEL: boolean;
  52971. PREMULTIPLYALPHA: boolean;
  52972. EMISSIVE: boolean;
  52973. EMISSIVEDIRECTUV: number;
  52974. REFLECTIVITY: boolean;
  52975. REFLECTIVITYDIRECTUV: number;
  52976. SPECULARTERM: boolean;
  52977. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52978. MICROSURFACEAUTOMATIC: boolean;
  52979. LODBASEDMICROSFURACE: boolean;
  52980. MICROSURFACEMAP: boolean;
  52981. MICROSURFACEMAPDIRECTUV: number;
  52982. METALLICWORKFLOW: boolean;
  52983. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52984. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52985. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52986. AOSTOREINMETALMAPRED: boolean;
  52987. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52988. ENVIRONMENTBRDF: boolean;
  52989. ENVIRONMENTBRDF_RGBD: boolean;
  52990. NORMAL: boolean;
  52991. TANGENT: boolean;
  52992. BUMP: boolean;
  52993. BUMPDIRECTUV: number;
  52994. OBJECTSPACE_NORMALMAP: boolean;
  52995. PARALLAX: boolean;
  52996. PARALLAXOCCLUSION: boolean;
  52997. NORMALXYSCALE: boolean;
  52998. LIGHTMAP: boolean;
  52999. LIGHTMAPDIRECTUV: number;
  53000. USELIGHTMAPASSHADOWMAP: boolean;
  53001. GAMMALIGHTMAP: boolean;
  53002. RGBDLIGHTMAP: boolean;
  53003. REFLECTION: boolean;
  53004. REFLECTIONMAP_3D: boolean;
  53005. REFLECTIONMAP_SPHERICAL: boolean;
  53006. REFLECTIONMAP_PLANAR: boolean;
  53007. REFLECTIONMAP_CUBIC: boolean;
  53008. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53009. REFLECTIONMAP_PROJECTION: boolean;
  53010. REFLECTIONMAP_SKYBOX: boolean;
  53011. REFLECTIONMAP_EXPLICIT: boolean;
  53012. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53013. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53014. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53015. INVERTCUBICMAP: boolean;
  53016. USESPHERICALFROMREFLECTIONMAP: boolean;
  53017. USEIRRADIANCEMAP: boolean;
  53018. SPHERICAL_HARMONICS: boolean;
  53019. USESPHERICALINVERTEX: boolean;
  53020. REFLECTIONMAP_OPPOSITEZ: boolean;
  53021. LODINREFLECTIONALPHA: boolean;
  53022. GAMMAREFLECTION: boolean;
  53023. RGBDREFLECTION: boolean;
  53024. LINEARSPECULARREFLECTION: boolean;
  53025. RADIANCEOCCLUSION: boolean;
  53026. HORIZONOCCLUSION: boolean;
  53027. INSTANCES: boolean;
  53028. NUM_BONE_INFLUENCERS: number;
  53029. BonesPerMesh: number;
  53030. BONETEXTURE: boolean;
  53031. NONUNIFORMSCALING: boolean;
  53032. MORPHTARGETS: boolean;
  53033. MORPHTARGETS_NORMAL: boolean;
  53034. MORPHTARGETS_TANGENT: boolean;
  53035. MORPHTARGETS_UV: boolean;
  53036. NUM_MORPH_INFLUENCERS: number;
  53037. IMAGEPROCESSING: boolean;
  53038. VIGNETTE: boolean;
  53039. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53040. VIGNETTEBLENDMODEOPAQUE: boolean;
  53041. TONEMAPPING: boolean;
  53042. TONEMAPPING_ACES: boolean;
  53043. CONTRAST: boolean;
  53044. COLORCURVES: boolean;
  53045. COLORGRADING: boolean;
  53046. COLORGRADING3D: boolean;
  53047. SAMPLER3DGREENDEPTH: boolean;
  53048. SAMPLER3DBGRMAP: boolean;
  53049. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53050. EXPOSURE: boolean;
  53051. MULTIVIEW: boolean;
  53052. USEPHYSICALLIGHTFALLOFF: boolean;
  53053. USEGLTFLIGHTFALLOFF: boolean;
  53054. TWOSIDEDLIGHTING: boolean;
  53055. SHADOWFLOAT: boolean;
  53056. CLIPPLANE: boolean;
  53057. CLIPPLANE2: boolean;
  53058. CLIPPLANE3: boolean;
  53059. CLIPPLANE4: boolean;
  53060. CLIPPLANE5: boolean;
  53061. CLIPPLANE6: boolean;
  53062. POINTSIZE: boolean;
  53063. FOG: boolean;
  53064. LOGARITHMICDEPTH: boolean;
  53065. FORCENORMALFORWARD: boolean;
  53066. SPECULARAA: boolean;
  53067. CLEARCOAT: boolean;
  53068. CLEARCOAT_DEFAULTIOR: boolean;
  53069. CLEARCOAT_TEXTURE: boolean;
  53070. CLEARCOAT_TEXTUREDIRECTUV: number;
  53071. CLEARCOAT_BUMP: boolean;
  53072. CLEARCOAT_BUMPDIRECTUV: number;
  53073. CLEARCOAT_TINT: boolean;
  53074. CLEARCOAT_TINT_TEXTURE: boolean;
  53075. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53076. ANISOTROPIC: boolean;
  53077. ANISOTROPIC_TEXTURE: boolean;
  53078. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53079. BRDF_V_HEIGHT_CORRELATED: boolean;
  53080. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53081. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53082. SHEEN: boolean;
  53083. SHEEN_TEXTURE: boolean;
  53084. SHEEN_TEXTUREDIRECTUV: number;
  53085. SHEEN_LINKWITHALBEDO: boolean;
  53086. SUBSURFACE: boolean;
  53087. SS_REFRACTION: boolean;
  53088. SS_TRANSLUCENCY: boolean;
  53089. SS_SCATERRING: boolean;
  53090. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53091. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53092. SS_REFRACTIONMAP_3D: boolean;
  53093. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53094. SS_LODINREFRACTIONALPHA: boolean;
  53095. SS_GAMMAREFRACTION: boolean;
  53096. SS_RGBDREFRACTION: boolean;
  53097. SS_LINEARSPECULARREFRACTION: boolean;
  53098. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53099. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53100. UNLIT: boolean;
  53101. DEBUGMODE: number;
  53102. /**
  53103. * Initializes the PBR Material defines.
  53104. */
  53105. constructor();
  53106. /**
  53107. * Resets the PBR Material defines.
  53108. */
  53109. reset(): void;
  53110. }
  53111. /**
  53112. * The Physically based material base class of BJS.
  53113. *
  53114. * This offers the main features of a standard PBR material.
  53115. * For more information, please refer to the documentation :
  53116. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53117. */
  53118. export abstract class PBRBaseMaterial extends PushMaterial {
  53119. /**
  53120. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53121. */
  53122. static readonly PBRMATERIAL_OPAQUE: number;
  53123. /**
  53124. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53125. */
  53126. static readonly PBRMATERIAL_ALPHATEST: number;
  53127. /**
  53128. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53129. */
  53130. static readonly PBRMATERIAL_ALPHABLEND: number;
  53131. /**
  53132. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53133. * They are also discarded below the alpha cutoff threshold to improve performances.
  53134. */
  53135. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53136. /**
  53137. * Defines the default value of how much AO map is occluding the analytical lights
  53138. * (point spot...).
  53139. */
  53140. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53141. /**
  53142. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53143. */
  53144. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53145. /**
  53146. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53147. * to enhance interoperability with other engines.
  53148. */
  53149. static readonly LIGHTFALLOFF_GLTF: number;
  53150. /**
  53151. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53152. * to enhance interoperability with other materials.
  53153. */
  53154. static readonly LIGHTFALLOFF_STANDARD: number;
  53155. /**
  53156. * Intensity of the direct lights e.g. the four lights available in your scene.
  53157. * This impacts both the direct diffuse and specular highlights.
  53158. */
  53159. protected _directIntensity: number;
  53160. /**
  53161. * Intensity of the emissive part of the material.
  53162. * This helps controlling the emissive effect without modifying the emissive color.
  53163. */
  53164. protected _emissiveIntensity: number;
  53165. /**
  53166. * Intensity of the environment e.g. how much the environment will light the object
  53167. * either through harmonics for rough material or through the refelction for shiny ones.
  53168. */
  53169. protected _environmentIntensity: number;
  53170. /**
  53171. * This is a special control allowing the reduction of the specular highlights coming from the
  53172. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53173. */
  53174. protected _specularIntensity: number;
  53175. /**
  53176. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53177. */
  53178. private _lightingInfos;
  53179. /**
  53180. * Debug Control allowing disabling the bump map on this material.
  53181. */
  53182. protected _disableBumpMap: boolean;
  53183. /**
  53184. * AKA Diffuse Texture in standard nomenclature.
  53185. */
  53186. protected _albedoTexture: Nullable<BaseTexture>;
  53187. /**
  53188. * AKA Occlusion Texture in other nomenclature.
  53189. */
  53190. protected _ambientTexture: Nullable<BaseTexture>;
  53191. /**
  53192. * AKA Occlusion Texture Intensity in other nomenclature.
  53193. */
  53194. protected _ambientTextureStrength: number;
  53195. /**
  53196. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53197. * 1 means it completely occludes it
  53198. * 0 mean it has no impact
  53199. */
  53200. protected _ambientTextureImpactOnAnalyticalLights: number;
  53201. /**
  53202. * Stores the alpha values in a texture.
  53203. */
  53204. protected _opacityTexture: Nullable<BaseTexture>;
  53205. /**
  53206. * Stores the reflection values in a texture.
  53207. */
  53208. protected _reflectionTexture: Nullable<BaseTexture>;
  53209. /**
  53210. * Stores the emissive values in a texture.
  53211. */
  53212. protected _emissiveTexture: Nullable<BaseTexture>;
  53213. /**
  53214. * AKA Specular texture in other nomenclature.
  53215. */
  53216. protected _reflectivityTexture: Nullable<BaseTexture>;
  53217. /**
  53218. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53219. */
  53220. protected _metallicTexture: Nullable<BaseTexture>;
  53221. /**
  53222. * Specifies the metallic scalar of the metallic/roughness workflow.
  53223. * Can also be used to scale the metalness values of the metallic texture.
  53224. */
  53225. protected _metallic: Nullable<number>;
  53226. /**
  53227. * Specifies the roughness scalar of the metallic/roughness workflow.
  53228. * Can also be used to scale the roughness values of the metallic texture.
  53229. */
  53230. protected _roughness: Nullable<number>;
  53231. /**
  53232. * Specifies the an F0 factor to help configuring the material F0.
  53233. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53234. * to 0.5 the previously hard coded value stays the same.
  53235. * Can also be used to scale the F0 values of the metallic texture.
  53236. */
  53237. protected _metallicF0Factor: number;
  53238. /**
  53239. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53240. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53241. * your expectation as it multiplies with the texture data.
  53242. */
  53243. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53244. /**
  53245. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53246. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53247. */
  53248. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53249. /**
  53250. * Stores surface normal data used to displace a mesh in a texture.
  53251. */
  53252. protected _bumpTexture: Nullable<BaseTexture>;
  53253. /**
  53254. * Stores the pre-calculated light information of a mesh in a texture.
  53255. */
  53256. protected _lightmapTexture: Nullable<BaseTexture>;
  53257. /**
  53258. * The color of a material in ambient lighting.
  53259. */
  53260. protected _ambientColor: Color3;
  53261. /**
  53262. * AKA Diffuse Color in other nomenclature.
  53263. */
  53264. protected _albedoColor: Color3;
  53265. /**
  53266. * AKA Specular Color in other nomenclature.
  53267. */
  53268. protected _reflectivityColor: Color3;
  53269. /**
  53270. * The color applied when light is reflected from a material.
  53271. */
  53272. protected _reflectionColor: Color3;
  53273. /**
  53274. * The color applied when light is emitted from a material.
  53275. */
  53276. protected _emissiveColor: Color3;
  53277. /**
  53278. * AKA Glossiness in other nomenclature.
  53279. */
  53280. protected _microSurface: number;
  53281. /**
  53282. * Specifies that the material will use the light map as a show map.
  53283. */
  53284. protected _useLightmapAsShadowmap: boolean;
  53285. /**
  53286. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53287. * makes the reflect vector face the model (under horizon).
  53288. */
  53289. protected _useHorizonOcclusion: boolean;
  53290. /**
  53291. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53292. * too much the area relying on ambient texture to define their ambient occlusion.
  53293. */
  53294. protected _useRadianceOcclusion: boolean;
  53295. /**
  53296. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53297. */
  53298. protected _useAlphaFromAlbedoTexture: boolean;
  53299. /**
  53300. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53301. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53302. */
  53303. protected _useSpecularOverAlpha: boolean;
  53304. /**
  53305. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53306. */
  53307. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53308. /**
  53309. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53310. */
  53311. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53312. /**
  53313. * Specifies if the metallic texture contains the roughness information in its green channel.
  53314. */
  53315. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53316. /**
  53317. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53318. */
  53319. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53320. /**
  53321. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53322. */
  53323. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53324. /**
  53325. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53326. */
  53327. protected _useAmbientInGrayScale: boolean;
  53328. /**
  53329. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53330. * The material will try to infer what glossiness each pixel should be.
  53331. */
  53332. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53333. /**
  53334. * Defines the falloff type used in this material.
  53335. * It by default is Physical.
  53336. */
  53337. protected _lightFalloff: number;
  53338. /**
  53339. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53340. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53341. */
  53342. protected _useRadianceOverAlpha: boolean;
  53343. /**
  53344. * Allows using an object space normal map (instead of tangent space).
  53345. */
  53346. protected _useObjectSpaceNormalMap: boolean;
  53347. /**
  53348. * Allows using the bump map in parallax mode.
  53349. */
  53350. protected _useParallax: boolean;
  53351. /**
  53352. * Allows using the bump map in parallax occlusion mode.
  53353. */
  53354. protected _useParallaxOcclusion: boolean;
  53355. /**
  53356. * Controls the scale bias of the parallax mode.
  53357. */
  53358. protected _parallaxScaleBias: number;
  53359. /**
  53360. * If sets to true, disables all the lights affecting the material.
  53361. */
  53362. protected _disableLighting: boolean;
  53363. /**
  53364. * Number of Simultaneous lights allowed on the material.
  53365. */
  53366. protected _maxSimultaneousLights: number;
  53367. /**
  53368. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53369. */
  53370. protected _invertNormalMapX: boolean;
  53371. /**
  53372. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53373. */
  53374. protected _invertNormalMapY: boolean;
  53375. /**
  53376. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53377. */
  53378. protected _twoSidedLighting: boolean;
  53379. /**
  53380. * Defines the alpha limits in alpha test mode.
  53381. */
  53382. protected _alphaCutOff: number;
  53383. /**
  53384. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53385. */
  53386. protected _forceAlphaTest: boolean;
  53387. /**
  53388. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53389. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53390. */
  53391. protected _useAlphaFresnel: boolean;
  53392. /**
  53393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53394. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53395. */
  53396. protected _useLinearAlphaFresnel: boolean;
  53397. /**
  53398. * The transparency mode of the material.
  53399. */
  53400. protected _transparencyMode: Nullable<number>;
  53401. /**
  53402. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53403. * from cos thetav and roughness:
  53404. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53405. */
  53406. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53407. /**
  53408. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53409. */
  53410. protected _forceIrradianceInFragment: boolean;
  53411. /**
  53412. * Force normal to face away from face.
  53413. */
  53414. protected _forceNormalForward: boolean;
  53415. /**
  53416. * Enables specular anti aliasing in the PBR shader.
  53417. * It will both interacts on the Geometry for analytical and IBL lighting.
  53418. * It also prefilter the roughness map based on the bump values.
  53419. */
  53420. protected _enableSpecularAntiAliasing: boolean;
  53421. /**
  53422. * Default configuration related to image processing available in the PBR Material.
  53423. */
  53424. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53425. /**
  53426. * Keep track of the image processing observer to allow dispose and replace.
  53427. */
  53428. private _imageProcessingObserver;
  53429. /**
  53430. * Attaches a new image processing configuration to the PBR Material.
  53431. * @param configuration
  53432. */
  53433. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53434. /**
  53435. * Stores the available render targets.
  53436. */
  53437. private _renderTargets;
  53438. /**
  53439. * Sets the global ambient color for the material used in lighting calculations.
  53440. */
  53441. private _globalAmbientColor;
  53442. /**
  53443. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53444. */
  53445. private _useLogarithmicDepth;
  53446. /**
  53447. * If set to true, no lighting calculations will be applied.
  53448. */
  53449. private _unlit;
  53450. private _debugMode;
  53451. /**
  53452. * @hidden
  53453. * This is reserved for the inspector.
  53454. * Defines the material debug mode.
  53455. * It helps seeing only some components of the material while troubleshooting.
  53456. */
  53457. debugMode: number;
  53458. /**
  53459. * @hidden
  53460. * This is reserved for the inspector.
  53461. * Specify from where on screen the debug mode should start.
  53462. * The value goes from -1 (full screen) to 1 (not visible)
  53463. * It helps with side by side comparison against the final render
  53464. * This defaults to -1
  53465. */
  53466. private debugLimit;
  53467. /**
  53468. * @hidden
  53469. * This is reserved for the inspector.
  53470. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53471. * You can use the factor to better multiply the final value.
  53472. */
  53473. private debugFactor;
  53474. /**
  53475. * Defines the clear coat layer parameters for the material.
  53476. */
  53477. readonly clearCoat: PBRClearCoatConfiguration;
  53478. /**
  53479. * Defines the anisotropic parameters for the material.
  53480. */
  53481. readonly anisotropy: PBRAnisotropicConfiguration;
  53482. /**
  53483. * Defines the BRDF parameters for the material.
  53484. */
  53485. readonly brdf: PBRBRDFConfiguration;
  53486. /**
  53487. * Defines the Sheen parameters for the material.
  53488. */
  53489. readonly sheen: PBRSheenConfiguration;
  53490. /**
  53491. * Defines the SubSurface parameters for the material.
  53492. */
  53493. readonly subSurface: PBRSubSurfaceConfiguration;
  53494. /**
  53495. * Custom callback helping to override the default shader used in the material.
  53496. */
  53497. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53498. protected _rebuildInParallel: boolean;
  53499. /**
  53500. * Instantiates a new PBRMaterial instance.
  53501. *
  53502. * @param name The material name
  53503. * @param scene The scene the material will be use in.
  53504. */
  53505. constructor(name: string, scene: Scene);
  53506. /**
  53507. * Gets a boolean indicating that current material needs to register RTT
  53508. */
  53509. get hasRenderTargetTextures(): boolean;
  53510. /**
  53511. * Gets the name of the material class.
  53512. */
  53513. getClassName(): string;
  53514. /**
  53515. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53516. */
  53517. get useLogarithmicDepth(): boolean;
  53518. /**
  53519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53520. */
  53521. set useLogarithmicDepth(value: boolean);
  53522. /**
  53523. * Gets the current transparency mode.
  53524. */
  53525. get transparencyMode(): Nullable<number>;
  53526. /**
  53527. * Sets the transparency mode of the material.
  53528. *
  53529. * | Value | Type | Description |
  53530. * | ----- | ----------------------------------- | ----------- |
  53531. * | 0 | OPAQUE | |
  53532. * | 1 | ALPHATEST | |
  53533. * | 2 | ALPHABLEND | |
  53534. * | 3 | ALPHATESTANDBLEND | |
  53535. *
  53536. */
  53537. set transparencyMode(value: Nullable<number>);
  53538. /**
  53539. * Returns true if alpha blending should be disabled.
  53540. */
  53541. private get _disableAlphaBlending();
  53542. /**
  53543. * Specifies whether or not this material should be rendered in alpha blend mode.
  53544. */
  53545. needAlphaBlending(): boolean;
  53546. /**
  53547. * Specifies if the mesh will require alpha blending.
  53548. * @param mesh - BJS mesh.
  53549. */
  53550. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53551. /**
  53552. * Specifies whether or not this material should be rendered in alpha test mode.
  53553. */
  53554. needAlphaTesting(): boolean;
  53555. /**
  53556. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53557. */
  53558. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53559. /**
  53560. * Gets the texture used for the alpha test.
  53561. */
  53562. getAlphaTestTexture(): Nullable<BaseTexture>;
  53563. /**
  53564. * Specifies that the submesh is ready to be used.
  53565. * @param mesh - BJS mesh.
  53566. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53567. * @param useInstances - Specifies that instances should be used.
  53568. * @returns - boolean indicating that the submesh is ready or not.
  53569. */
  53570. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53571. /**
  53572. * Specifies if the material uses metallic roughness workflow.
  53573. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53574. */
  53575. isMetallicWorkflow(): boolean;
  53576. private _prepareEffect;
  53577. private _prepareDefines;
  53578. /**
  53579. * Force shader compilation
  53580. */
  53581. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53582. /**
  53583. * Initializes the uniform buffer layout for the shader.
  53584. */
  53585. buildUniformLayout(): void;
  53586. /**
  53587. * Unbinds the material from the mesh
  53588. */
  53589. unbind(): void;
  53590. /**
  53591. * Binds the submesh data.
  53592. * @param world - The world matrix.
  53593. * @param mesh - The BJS mesh.
  53594. * @param subMesh - A submesh of the BJS mesh.
  53595. */
  53596. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53597. /**
  53598. * Returns the animatable textures.
  53599. * @returns - Array of animatable textures.
  53600. */
  53601. getAnimatables(): IAnimatable[];
  53602. /**
  53603. * Returns the texture used for reflections.
  53604. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53605. */
  53606. private _getReflectionTexture;
  53607. /**
  53608. * Returns an array of the actively used textures.
  53609. * @returns - Array of BaseTextures
  53610. */
  53611. getActiveTextures(): BaseTexture[];
  53612. /**
  53613. * Checks to see if a texture is used in the material.
  53614. * @param texture - Base texture to use.
  53615. * @returns - Boolean specifying if a texture is used in the material.
  53616. */
  53617. hasTexture(texture: BaseTexture): boolean;
  53618. /**
  53619. * Disposes the resources of the material.
  53620. * @param forceDisposeEffect - Forces the disposal of effects.
  53621. * @param forceDisposeTextures - Forces the disposal of all textures.
  53622. */
  53623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53624. }
  53625. }
  53626. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53627. import { Nullable } from "babylonjs/types";
  53628. import { Scene } from "babylonjs/scene";
  53629. import { Color3 } from "babylonjs/Maths/math.color";
  53630. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53631. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53633. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53634. /**
  53635. * The Physically based material of BJS.
  53636. *
  53637. * This offers the main features of a standard PBR material.
  53638. * For more information, please refer to the documentation :
  53639. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53640. */
  53641. export class PBRMaterial extends PBRBaseMaterial {
  53642. /**
  53643. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53644. */
  53645. static readonly PBRMATERIAL_OPAQUE: number;
  53646. /**
  53647. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53648. */
  53649. static readonly PBRMATERIAL_ALPHATEST: number;
  53650. /**
  53651. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53652. */
  53653. static readonly PBRMATERIAL_ALPHABLEND: number;
  53654. /**
  53655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53656. * They are also discarded below the alpha cutoff threshold to improve performances.
  53657. */
  53658. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53659. /**
  53660. * Defines the default value of how much AO map is occluding the analytical lights
  53661. * (point spot...).
  53662. */
  53663. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53664. /**
  53665. * Intensity of the direct lights e.g. the four lights available in your scene.
  53666. * This impacts both the direct diffuse and specular highlights.
  53667. */
  53668. directIntensity: number;
  53669. /**
  53670. * Intensity of the emissive part of the material.
  53671. * This helps controlling the emissive effect without modifying the emissive color.
  53672. */
  53673. emissiveIntensity: number;
  53674. /**
  53675. * Intensity of the environment e.g. how much the environment will light the object
  53676. * either through harmonics for rough material or through the refelction for shiny ones.
  53677. */
  53678. environmentIntensity: number;
  53679. /**
  53680. * This is a special control allowing the reduction of the specular highlights coming from the
  53681. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53682. */
  53683. specularIntensity: number;
  53684. /**
  53685. * Debug Control allowing disabling the bump map on this material.
  53686. */
  53687. disableBumpMap: boolean;
  53688. /**
  53689. * AKA Diffuse Texture in standard nomenclature.
  53690. */
  53691. albedoTexture: BaseTexture;
  53692. /**
  53693. * AKA Occlusion Texture in other nomenclature.
  53694. */
  53695. ambientTexture: BaseTexture;
  53696. /**
  53697. * AKA Occlusion Texture Intensity in other nomenclature.
  53698. */
  53699. ambientTextureStrength: number;
  53700. /**
  53701. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53702. * 1 means it completely occludes it
  53703. * 0 mean it has no impact
  53704. */
  53705. ambientTextureImpactOnAnalyticalLights: number;
  53706. /**
  53707. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53708. */
  53709. opacityTexture: BaseTexture;
  53710. /**
  53711. * Stores the reflection values in a texture.
  53712. */
  53713. reflectionTexture: Nullable<BaseTexture>;
  53714. /**
  53715. * Stores the emissive values in a texture.
  53716. */
  53717. emissiveTexture: BaseTexture;
  53718. /**
  53719. * AKA Specular texture in other nomenclature.
  53720. */
  53721. reflectivityTexture: BaseTexture;
  53722. /**
  53723. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53724. */
  53725. metallicTexture: BaseTexture;
  53726. /**
  53727. * Specifies the metallic scalar of the metallic/roughness workflow.
  53728. * Can also be used to scale the metalness values of the metallic texture.
  53729. */
  53730. metallic: Nullable<number>;
  53731. /**
  53732. * Specifies the roughness scalar of the metallic/roughness workflow.
  53733. * Can also be used to scale the roughness values of the metallic texture.
  53734. */
  53735. roughness: Nullable<number>;
  53736. /**
  53737. * Specifies the an F0 factor to help configuring the material F0.
  53738. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53739. * to 0.5 the previously hard coded value stays the same.
  53740. * Can also be used to scale the F0 values of the metallic texture.
  53741. */
  53742. metallicF0Factor: number;
  53743. /**
  53744. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53745. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53746. * your expectation as it multiplies with the texture data.
  53747. */
  53748. useMetallicF0FactorFromMetallicTexture: boolean;
  53749. /**
  53750. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53751. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53752. */
  53753. microSurfaceTexture: BaseTexture;
  53754. /**
  53755. * Stores surface normal data used to displace a mesh in a texture.
  53756. */
  53757. bumpTexture: BaseTexture;
  53758. /**
  53759. * Stores the pre-calculated light information of a mesh in a texture.
  53760. */
  53761. lightmapTexture: BaseTexture;
  53762. /**
  53763. * Stores the refracted light information in a texture.
  53764. */
  53765. get refractionTexture(): Nullable<BaseTexture>;
  53766. set refractionTexture(value: Nullable<BaseTexture>);
  53767. /**
  53768. * The color of a material in ambient lighting.
  53769. */
  53770. ambientColor: Color3;
  53771. /**
  53772. * AKA Diffuse Color in other nomenclature.
  53773. */
  53774. albedoColor: Color3;
  53775. /**
  53776. * AKA Specular Color in other nomenclature.
  53777. */
  53778. reflectivityColor: Color3;
  53779. /**
  53780. * The color reflected from the material.
  53781. */
  53782. reflectionColor: Color3;
  53783. /**
  53784. * The color emitted from the material.
  53785. */
  53786. emissiveColor: Color3;
  53787. /**
  53788. * AKA Glossiness in other nomenclature.
  53789. */
  53790. microSurface: number;
  53791. /**
  53792. * source material index of refraction (IOR)' / 'destination material IOR.
  53793. */
  53794. get indexOfRefraction(): number;
  53795. set indexOfRefraction(value: number);
  53796. /**
  53797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53798. */
  53799. get invertRefractionY(): boolean;
  53800. set invertRefractionY(value: boolean);
  53801. /**
  53802. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53803. * Materials half opaque for instance using refraction could benefit from this control.
  53804. */
  53805. get linkRefractionWithTransparency(): boolean;
  53806. set linkRefractionWithTransparency(value: boolean);
  53807. /**
  53808. * If true, the light map contains occlusion information instead of lighting info.
  53809. */
  53810. useLightmapAsShadowmap: boolean;
  53811. /**
  53812. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53813. */
  53814. useAlphaFromAlbedoTexture: boolean;
  53815. /**
  53816. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53817. */
  53818. forceAlphaTest: boolean;
  53819. /**
  53820. * Defines the alpha limits in alpha test mode.
  53821. */
  53822. alphaCutOff: number;
  53823. /**
  53824. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53825. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53826. */
  53827. useSpecularOverAlpha: boolean;
  53828. /**
  53829. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53830. */
  53831. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53832. /**
  53833. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53834. */
  53835. useRoughnessFromMetallicTextureAlpha: boolean;
  53836. /**
  53837. * Specifies if the metallic texture contains the roughness information in its green channel.
  53838. */
  53839. useRoughnessFromMetallicTextureGreen: boolean;
  53840. /**
  53841. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53842. */
  53843. useMetallnessFromMetallicTextureBlue: boolean;
  53844. /**
  53845. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53846. */
  53847. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53848. /**
  53849. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53850. */
  53851. useAmbientInGrayScale: boolean;
  53852. /**
  53853. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53854. * The material will try to infer what glossiness each pixel should be.
  53855. */
  53856. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53857. /**
  53858. * BJS is using an harcoded light falloff based on a manually sets up range.
  53859. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53860. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53861. */
  53862. get usePhysicalLightFalloff(): boolean;
  53863. /**
  53864. * BJS is using an harcoded light falloff based on a manually sets up range.
  53865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53867. */
  53868. set usePhysicalLightFalloff(value: boolean);
  53869. /**
  53870. * In order to support the falloff compatibility with gltf, a special mode has been added
  53871. * to reproduce the gltf light falloff.
  53872. */
  53873. get useGLTFLightFalloff(): boolean;
  53874. /**
  53875. * In order to support the falloff compatibility with gltf, a special mode has been added
  53876. * to reproduce the gltf light falloff.
  53877. */
  53878. set useGLTFLightFalloff(value: boolean);
  53879. /**
  53880. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53881. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53882. */
  53883. useRadianceOverAlpha: boolean;
  53884. /**
  53885. * Allows using an object space normal map (instead of tangent space).
  53886. */
  53887. useObjectSpaceNormalMap: boolean;
  53888. /**
  53889. * Allows using the bump map in parallax mode.
  53890. */
  53891. useParallax: boolean;
  53892. /**
  53893. * Allows using the bump map in parallax occlusion mode.
  53894. */
  53895. useParallaxOcclusion: boolean;
  53896. /**
  53897. * Controls the scale bias of the parallax mode.
  53898. */
  53899. parallaxScaleBias: number;
  53900. /**
  53901. * If sets to true, disables all the lights affecting the material.
  53902. */
  53903. disableLighting: boolean;
  53904. /**
  53905. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53906. */
  53907. forceIrradianceInFragment: boolean;
  53908. /**
  53909. * Number of Simultaneous lights allowed on the material.
  53910. */
  53911. maxSimultaneousLights: number;
  53912. /**
  53913. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53914. */
  53915. invertNormalMapX: boolean;
  53916. /**
  53917. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53918. */
  53919. invertNormalMapY: boolean;
  53920. /**
  53921. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53922. */
  53923. twoSidedLighting: boolean;
  53924. /**
  53925. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53926. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53927. */
  53928. useAlphaFresnel: boolean;
  53929. /**
  53930. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53931. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53932. */
  53933. useLinearAlphaFresnel: boolean;
  53934. /**
  53935. * Let user defines the brdf lookup texture used for IBL.
  53936. * A default 8bit version is embedded but you could point at :
  53937. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53938. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53939. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53940. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53941. */
  53942. environmentBRDFTexture: Nullable<BaseTexture>;
  53943. /**
  53944. * Force normal to face away from face.
  53945. */
  53946. forceNormalForward: boolean;
  53947. /**
  53948. * Enables specular anti aliasing in the PBR shader.
  53949. * It will both interacts on the Geometry for analytical and IBL lighting.
  53950. * It also prefilter the roughness map based on the bump values.
  53951. */
  53952. enableSpecularAntiAliasing: boolean;
  53953. /**
  53954. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53955. * makes the reflect vector face the model (under horizon).
  53956. */
  53957. useHorizonOcclusion: boolean;
  53958. /**
  53959. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53960. * too much the area relying on ambient texture to define their ambient occlusion.
  53961. */
  53962. useRadianceOcclusion: boolean;
  53963. /**
  53964. * If set to true, no lighting calculations will be applied.
  53965. */
  53966. unlit: boolean;
  53967. /**
  53968. * Gets the image processing configuration used either in this material.
  53969. */
  53970. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53971. /**
  53972. * Sets the Default image processing configuration used either in the this material.
  53973. *
  53974. * If sets to null, the scene one is in use.
  53975. */
  53976. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53977. /**
  53978. * Gets wether the color curves effect is enabled.
  53979. */
  53980. get cameraColorCurvesEnabled(): boolean;
  53981. /**
  53982. * Sets wether the color curves effect is enabled.
  53983. */
  53984. set cameraColorCurvesEnabled(value: boolean);
  53985. /**
  53986. * Gets wether the color grading effect is enabled.
  53987. */
  53988. get cameraColorGradingEnabled(): boolean;
  53989. /**
  53990. * Gets wether the color grading effect is enabled.
  53991. */
  53992. set cameraColorGradingEnabled(value: boolean);
  53993. /**
  53994. * Gets wether tonemapping is enabled or not.
  53995. */
  53996. get cameraToneMappingEnabled(): boolean;
  53997. /**
  53998. * Sets wether tonemapping is enabled or not
  53999. */
  54000. set cameraToneMappingEnabled(value: boolean);
  54001. /**
  54002. * The camera exposure used on this material.
  54003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54004. * This corresponds to a photographic exposure.
  54005. */
  54006. get cameraExposure(): number;
  54007. /**
  54008. * The camera exposure used on this material.
  54009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54010. * This corresponds to a photographic exposure.
  54011. */
  54012. set cameraExposure(value: number);
  54013. /**
  54014. * Gets The camera contrast used on this material.
  54015. */
  54016. get cameraContrast(): number;
  54017. /**
  54018. * Sets The camera contrast used on this material.
  54019. */
  54020. set cameraContrast(value: number);
  54021. /**
  54022. * Gets the Color Grading 2D Lookup Texture.
  54023. */
  54024. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54025. /**
  54026. * Sets the Color Grading 2D Lookup Texture.
  54027. */
  54028. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54029. /**
  54030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54032. * 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;
  54033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54034. */
  54035. get cameraColorCurves(): Nullable<ColorCurves>;
  54036. /**
  54037. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54038. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54039. * 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;
  54040. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54041. */
  54042. set cameraColorCurves(value: Nullable<ColorCurves>);
  54043. /**
  54044. * Instantiates a new PBRMaterial instance.
  54045. *
  54046. * @param name The material name
  54047. * @param scene The scene the material will be use in.
  54048. */
  54049. constructor(name: string, scene: Scene);
  54050. /**
  54051. * Returns the name of this material class.
  54052. */
  54053. getClassName(): string;
  54054. /**
  54055. * Makes a duplicate of the current material.
  54056. * @param name - name to use for the new material.
  54057. */
  54058. clone(name: string): PBRMaterial;
  54059. /**
  54060. * Serializes this PBR Material.
  54061. * @returns - An object with the serialized material.
  54062. */
  54063. serialize(): any;
  54064. /**
  54065. * Parses a PBR Material from a serialized object.
  54066. * @param source - Serialized object.
  54067. * @param scene - BJS scene instance.
  54068. * @param rootUrl - url for the scene object
  54069. * @returns - PBRMaterial
  54070. */
  54071. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54072. }
  54073. }
  54074. declare module "babylonjs/Misc/dds" {
  54075. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54077. import { Nullable } from "babylonjs/types";
  54078. import { Scene } from "babylonjs/scene";
  54079. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54080. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54081. /**
  54082. * Direct draw surface info
  54083. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54084. */
  54085. export interface DDSInfo {
  54086. /**
  54087. * Width of the texture
  54088. */
  54089. width: number;
  54090. /**
  54091. * Width of the texture
  54092. */
  54093. height: number;
  54094. /**
  54095. * Number of Mipmaps for the texture
  54096. * @see https://en.wikipedia.org/wiki/Mipmap
  54097. */
  54098. mipmapCount: number;
  54099. /**
  54100. * If the textures format is a known fourCC format
  54101. * @see https://www.fourcc.org/
  54102. */
  54103. isFourCC: boolean;
  54104. /**
  54105. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54106. */
  54107. isRGB: boolean;
  54108. /**
  54109. * If the texture is a lumincance format
  54110. */
  54111. isLuminance: boolean;
  54112. /**
  54113. * If this is a cube texture
  54114. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54115. */
  54116. isCube: boolean;
  54117. /**
  54118. * If the texture is a compressed format eg. FOURCC_DXT1
  54119. */
  54120. isCompressed: boolean;
  54121. /**
  54122. * The dxgiFormat of the texture
  54123. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54124. */
  54125. dxgiFormat: number;
  54126. /**
  54127. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54128. */
  54129. textureType: number;
  54130. /**
  54131. * Sphericle polynomial created for the dds texture
  54132. */
  54133. sphericalPolynomial?: SphericalPolynomial;
  54134. }
  54135. /**
  54136. * Class used to provide DDS decompression tools
  54137. */
  54138. export class DDSTools {
  54139. /**
  54140. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54141. */
  54142. static StoreLODInAlphaChannel: boolean;
  54143. /**
  54144. * Gets DDS information from an array buffer
  54145. * @param data defines the array buffer view to read data from
  54146. * @returns the DDS information
  54147. */
  54148. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54149. private static _FloatView;
  54150. private static _Int32View;
  54151. private static _ToHalfFloat;
  54152. private static _FromHalfFloat;
  54153. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54154. private static _GetHalfFloatRGBAArrayBuffer;
  54155. private static _GetFloatRGBAArrayBuffer;
  54156. private static _GetFloatAsUIntRGBAArrayBuffer;
  54157. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54158. private static _GetRGBAArrayBuffer;
  54159. private static _ExtractLongWordOrder;
  54160. private static _GetRGBArrayBuffer;
  54161. private static _GetLuminanceArrayBuffer;
  54162. /**
  54163. * Uploads DDS Levels to a Babylon Texture
  54164. * @hidden
  54165. */
  54166. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54167. }
  54168. module "babylonjs/Engines/thinEngine" {
  54169. interface ThinEngine {
  54170. /**
  54171. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54172. * @param rootUrl defines the url where the file to load is located
  54173. * @param scene defines the current scene
  54174. * @param lodScale defines scale to apply to the mip map selection
  54175. * @param lodOffset defines offset to apply to the mip map selection
  54176. * @param onLoad defines an optional callback raised when the texture is loaded
  54177. * @param onError defines an optional callback raised if there is an issue to load the texture
  54178. * @param format defines the format of the data
  54179. * @param forcedExtension defines the extension to use to pick the right loader
  54180. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54181. * @returns the cube texture as an InternalTexture
  54182. */
  54183. 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;
  54184. }
  54185. }
  54186. }
  54187. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54188. import { Nullable } from "babylonjs/types";
  54189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54190. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54191. /**
  54192. * Implementation of the DDS Texture Loader.
  54193. * @hidden
  54194. */
  54195. export class _DDSTextureLoader implements IInternalTextureLoader {
  54196. /**
  54197. * Defines wether the loader supports cascade loading the different faces.
  54198. */
  54199. readonly supportCascades: boolean;
  54200. /**
  54201. * This returns if the loader support the current file information.
  54202. * @param extension defines the file extension of the file being loaded
  54203. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54204. * @param fallback defines the fallback internal texture if any
  54205. * @param isBase64 defines whether the texture is encoded as a base64
  54206. * @param isBuffer defines whether the texture data are stored as a buffer
  54207. * @returns true if the loader can load the specified file
  54208. */
  54209. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54210. /**
  54211. * Transform the url before loading if required.
  54212. * @param rootUrl the url of the texture
  54213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54214. * @returns the transformed texture
  54215. */
  54216. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54217. /**
  54218. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54219. * @param rootUrl the url of the texture
  54220. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54221. * @returns the fallback texture
  54222. */
  54223. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54224. /**
  54225. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54226. * @param data contains the texture data
  54227. * @param texture defines the BabylonJS internal texture
  54228. * @param createPolynomials will be true if polynomials have been requested
  54229. * @param onLoad defines the callback to trigger once the texture is ready
  54230. * @param onError defines the callback to trigger in case of error
  54231. */
  54232. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54233. /**
  54234. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54235. * @param data contains the texture data
  54236. * @param texture defines the BabylonJS internal texture
  54237. * @param callback defines the method to call once ready to upload
  54238. */
  54239. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54240. }
  54241. }
  54242. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54243. import { Nullable } from "babylonjs/types";
  54244. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54245. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54246. /**
  54247. * Implementation of the ENV Texture Loader.
  54248. * @hidden
  54249. */
  54250. export class _ENVTextureLoader implements IInternalTextureLoader {
  54251. /**
  54252. * Defines wether the loader supports cascade loading the different faces.
  54253. */
  54254. readonly supportCascades: boolean;
  54255. /**
  54256. * This returns if the loader support the current file information.
  54257. * @param extension defines the file extension of the file being loaded
  54258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54259. * @param fallback defines the fallback internal texture if any
  54260. * @param isBase64 defines whether the texture is encoded as a base64
  54261. * @param isBuffer defines whether the texture data are stored as a buffer
  54262. * @returns true if the loader can load the specified file
  54263. */
  54264. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54265. /**
  54266. * Transform the url before loading if required.
  54267. * @param rootUrl the url of the texture
  54268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54269. * @returns the transformed texture
  54270. */
  54271. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54272. /**
  54273. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54274. * @param rootUrl the url of the texture
  54275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54276. * @returns the fallback texture
  54277. */
  54278. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54279. /**
  54280. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54281. * @param data contains the texture data
  54282. * @param texture defines the BabylonJS internal texture
  54283. * @param createPolynomials will be true if polynomials have been requested
  54284. * @param onLoad defines the callback to trigger once the texture is ready
  54285. * @param onError defines the callback to trigger in case of error
  54286. */
  54287. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54288. /**
  54289. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54290. * @param data contains the texture data
  54291. * @param texture defines the BabylonJS internal texture
  54292. * @param callback defines the method to call once ready to upload
  54293. */
  54294. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54295. }
  54296. }
  54297. declare module "babylonjs/Misc/khronosTextureContainer" {
  54298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54299. /**
  54300. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54301. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54302. */
  54303. export class KhronosTextureContainer {
  54304. /** contents of the KTX container file */
  54305. data: ArrayBufferView;
  54306. private static HEADER_LEN;
  54307. private static COMPRESSED_2D;
  54308. private static COMPRESSED_3D;
  54309. private static TEX_2D;
  54310. private static TEX_3D;
  54311. /**
  54312. * Gets the openGL type
  54313. */
  54314. glType: number;
  54315. /**
  54316. * Gets the openGL type size
  54317. */
  54318. glTypeSize: number;
  54319. /**
  54320. * Gets the openGL format
  54321. */
  54322. glFormat: number;
  54323. /**
  54324. * Gets the openGL internal format
  54325. */
  54326. glInternalFormat: number;
  54327. /**
  54328. * Gets the base internal format
  54329. */
  54330. glBaseInternalFormat: number;
  54331. /**
  54332. * Gets image width in pixel
  54333. */
  54334. pixelWidth: number;
  54335. /**
  54336. * Gets image height in pixel
  54337. */
  54338. pixelHeight: number;
  54339. /**
  54340. * Gets image depth in pixels
  54341. */
  54342. pixelDepth: number;
  54343. /**
  54344. * Gets the number of array elements
  54345. */
  54346. numberOfArrayElements: number;
  54347. /**
  54348. * Gets the number of faces
  54349. */
  54350. numberOfFaces: number;
  54351. /**
  54352. * Gets the number of mipmap levels
  54353. */
  54354. numberOfMipmapLevels: number;
  54355. /**
  54356. * Gets the bytes of key value data
  54357. */
  54358. bytesOfKeyValueData: number;
  54359. /**
  54360. * Gets the load type
  54361. */
  54362. loadType: number;
  54363. /**
  54364. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54365. */
  54366. isInvalid: boolean;
  54367. /**
  54368. * Creates a new KhronosTextureContainer
  54369. * @param data contents of the KTX container file
  54370. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54371. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54372. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54373. */
  54374. constructor(
  54375. /** contents of the KTX container file */
  54376. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54377. /**
  54378. * Uploads KTX content to a Babylon Texture.
  54379. * It is assumed that the texture has already been created & is currently bound
  54380. * @hidden
  54381. */
  54382. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54383. private _upload2DCompressedLevels;
  54384. }
  54385. }
  54386. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54387. import { Nullable } from "babylonjs/types";
  54388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54389. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54390. /**
  54391. * Implementation of the KTX Texture Loader.
  54392. * @hidden
  54393. */
  54394. export class _KTXTextureLoader implements IInternalTextureLoader {
  54395. /**
  54396. * Defines wether the loader supports cascade loading the different faces.
  54397. */
  54398. readonly supportCascades: boolean;
  54399. /**
  54400. * This returns if the loader support the current file information.
  54401. * @param extension defines the file extension of the file being loaded
  54402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54403. * @param fallback defines the fallback internal texture if any
  54404. * @param isBase64 defines whether the texture is encoded as a base64
  54405. * @param isBuffer defines whether the texture data are stored as a buffer
  54406. * @returns true if the loader can load the specified file
  54407. */
  54408. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54409. /**
  54410. * Transform the url before loading if required.
  54411. * @param rootUrl the url of the texture
  54412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54413. * @returns the transformed texture
  54414. */
  54415. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54416. /**
  54417. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54418. * @param rootUrl the url of the texture
  54419. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54420. * @returns the fallback texture
  54421. */
  54422. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54423. /**
  54424. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54425. * @param data contains the texture data
  54426. * @param texture defines the BabylonJS internal texture
  54427. * @param createPolynomials will be true if polynomials have been requested
  54428. * @param onLoad defines the callback to trigger once the texture is ready
  54429. * @param onError defines the callback to trigger in case of error
  54430. */
  54431. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54432. /**
  54433. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54434. * @param data contains the texture data
  54435. * @param texture defines the BabylonJS internal texture
  54436. * @param callback defines the method to call once ready to upload
  54437. */
  54438. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54439. }
  54440. }
  54441. declare module "babylonjs/Helpers/sceneHelpers" {
  54442. import { Nullable } from "babylonjs/types";
  54443. import { Mesh } from "babylonjs/Meshes/mesh";
  54444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54445. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54446. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54447. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54448. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54449. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54450. import "babylonjs/Meshes/Builders/boxBuilder";
  54451. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54452. /** @hidden */
  54453. export var _forceSceneHelpersToBundle: boolean;
  54454. module "babylonjs/scene" {
  54455. interface Scene {
  54456. /**
  54457. * Creates a default light for the scene.
  54458. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54459. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54460. */
  54461. createDefaultLight(replace?: boolean): void;
  54462. /**
  54463. * Creates a default camera for the scene.
  54464. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54465. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54466. * @param replace has default false, when true replaces the active camera in the scene
  54467. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54468. */
  54469. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54470. /**
  54471. * Creates a default camera and a default light.
  54472. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54473. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54474. * @param replace has the default false, when true replaces the active camera/light in the scene
  54475. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54476. */
  54477. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54478. /**
  54479. * Creates a new sky box
  54480. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54481. * @param environmentTexture defines the texture to use as environment texture
  54482. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54483. * @param scale defines the overall scale of the skybox
  54484. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54485. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54486. * @returns a new mesh holding the sky box
  54487. */
  54488. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54489. /**
  54490. * Creates a new environment
  54491. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54492. * @param options defines the options you can use to configure the environment
  54493. * @returns the new EnvironmentHelper
  54494. */
  54495. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54496. /**
  54497. * Creates a new VREXperienceHelper
  54498. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54499. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54500. * @returns a new VREXperienceHelper
  54501. */
  54502. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54503. /**
  54504. * Creates a new WebXRDefaultExperience
  54505. * @see http://doc.babylonjs.com/how_to/webxr
  54506. * @param options experience options
  54507. * @returns a promise for a new WebXRDefaultExperience
  54508. */
  54509. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54510. }
  54511. }
  54512. }
  54513. declare module "babylonjs/Helpers/videoDome" {
  54514. import { Scene } from "babylonjs/scene";
  54515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54516. import { Mesh } from "babylonjs/Meshes/mesh";
  54517. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54518. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54519. import "babylonjs/Meshes/Builders/sphereBuilder";
  54520. /**
  54521. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54522. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54523. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54524. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54525. */
  54526. export class VideoDome extends TransformNode {
  54527. /**
  54528. * Define the video source as a Monoscopic panoramic 360 video.
  54529. */
  54530. static readonly MODE_MONOSCOPIC: number;
  54531. /**
  54532. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54533. */
  54534. static readonly MODE_TOPBOTTOM: number;
  54535. /**
  54536. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54537. */
  54538. static readonly MODE_SIDEBYSIDE: number;
  54539. private _halfDome;
  54540. private _useDirectMapping;
  54541. /**
  54542. * The video texture being displayed on the sphere
  54543. */
  54544. protected _videoTexture: VideoTexture;
  54545. /**
  54546. * Gets the video texture being displayed on the sphere
  54547. */
  54548. get videoTexture(): VideoTexture;
  54549. /**
  54550. * The skybox material
  54551. */
  54552. protected _material: BackgroundMaterial;
  54553. /**
  54554. * The surface used for the skybox
  54555. */
  54556. protected _mesh: Mesh;
  54557. /**
  54558. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54559. */
  54560. private _halfDomeMask;
  54561. /**
  54562. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54563. * Also see the options.resolution property.
  54564. */
  54565. get fovMultiplier(): number;
  54566. set fovMultiplier(value: number);
  54567. private _videoMode;
  54568. /**
  54569. * Gets or set the current video mode for the video. It can be:
  54570. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54571. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54572. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54573. */
  54574. get videoMode(): number;
  54575. set videoMode(value: number);
  54576. /**
  54577. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54578. *
  54579. */
  54580. get halfDome(): boolean;
  54581. /**
  54582. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54583. */
  54584. set halfDome(enabled: boolean);
  54585. /**
  54586. * Oberserver used in Stereoscopic VR Mode.
  54587. */
  54588. private _onBeforeCameraRenderObserver;
  54589. /**
  54590. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54591. * @param name Element's name, child elements will append suffixes for their own names.
  54592. * @param urlsOrVideo defines the url(s) or the video element to use
  54593. * @param options An object containing optional or exposed sub element properties
  54594. */
  54595. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54596. resolution?: number;
  54597. clickToPlay?: boolean;
  54598. autoPlay?: boolean;
  54599. loop?: boolean;
  54600. size?: number;
  54601. poster?: string;
  54602. faceForward?: boolean;
  54603. useDirectMapping?: boolean;
  54604. halfDomeMode?: boolean;
  54605. }, scene: Scene);
  54606. private _changeVideoMode;
  54607. /**
  54608. * Releases resources associated with this node.
  54609. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54610. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54611. */
  54612. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54613. }
  54614. }
  54615. declare module "babylonjs/Helpers/index" {
  54616. export * from "babylonjs/Helpers/environmentHelper";
  54617. export * from "babylonjs/Helpers/photoDome";
  54618. export * from "babylonjs/Helpers/sceneHelpers";
  54619. export * from "babylonjs/Helpers/videoDome";
  54620. }
  54621. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54622. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54623. import { IDisposable } from "babylonjs/scene";
  54624. import { Engine } from "babylonjs/Engines/engine";
  54625. /**
  54626. * This class can be used to get instrumentation data from a Babylon engine
  54627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54628. */
  54629. export class EngineInstrumentation implements IDisposable {
  54630. /**
  54631. * Define the instrumented engine.
  54632. */
  54633. engine: Engine;
  54634. private _captureGPUFrameTime;
  54635. private _gpuFrameTimeToken;
  54636. private _gpuFrameTime;
  54637. private _captureShaderCompilationTime;
  54638. private _shaderCompilationTime;
  54639. private _onBeginFrameObserver;
  54640. private _onEndFrameObserver;
  54641. private _onBeforeShaderCompilationObserver;
  54642. private _onAfterShaderCompilationObserver;
  54643. /**
  54644. * Gets the perf counter used for GPU frame time
  54645. */
  54646. get gpuFrameTimeCounter(): PerfCounter;
  54647. /**
  54648. * Gets the GPU frame time capture status
  54649. */
  54650. get captureGPUFrameTime(): boolean;
  54651. /**
  54652. * Enable or disable the GPU frame time capture
  54653. */
  54654. set captureGPUFrameTime(value: boolean);
  54655. /**
  54656. * Gets the perf counter used for shader compilation time
  54657. */
  54658. get shaderCompilationTimeCounter(): PerfCounter;
  54659. /**
  54660. * Gets the shader compilation time capture status
  54661. */
  54662. get captureShaderCompilationTime(): boolean;
  54663. /**
  54664. * Enable or disable the shader compilation time capture
  54665. */
  54666. set captureShaderCompilationTime(value: boolean);
  54667. /**
  54668. * Instantiates a new engine instrumentation.
  54669. * This class can be used to get instrumentation data from a Babylon engine
  54670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54671. * @param engine Defines the engine to instrument
  54672. */
  54673. constructor(
  54674. /**
  54675. * Define the instrumented engine.
  54676. */
  54677. engine: Engine);
  54678. /**
  54679. * Dispose and release associated resources.
  54680. */
  54681. dispose(): void;
  54682. }
  54683. }
  54684. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54685. import { Scene, IDisposable } from "babylonjs/scene";
  54686. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54687. /**
  54688. * This class can be used to get instrumentation data from a Babylon engine
  54689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54690. */
  54691. export class SceneInstrumentation implements IDisposable {
  54692. /**
  54693. * Defines the scene to instrument
  54694. */
  54695. scene: Scene;
  54696. private _captureActiveMeshesEvaluationTime;
  54697. private _activeMeshesEvaluationTime;
  54698. private _captureRenderTargetsRenderTime;
  54699. private _renderTargetsRenderTime;
  54700. private _captureFrameTime;
  54701. private _frameTime;
  54702. private _captureRenderTime;
  54703. private _renderTime;
  54704. private _captureInterFrameTime;
  54705. private _interFrameTime;
  54706. private _captureParticlesRenderTime;
  54707. private _particlesRenderTime;
  54708. private _captureSpritesRenderTime;
  54709. private _spritesRenderTime;
  54710. private _capturePhysicsTime;
  54711. private _physicsTime;
  54712. private _captureAnimationsTime;
  54713. private _animationsTime;
  54714. private _captureCameraRenderTime;
  54715. private _cameraRenderTime;
  54716. private _onBeforeActiveMeshesEvaluationObserver;
  54717. private _onAfterActiveMeshesEvaluationObserver;
  54718. private _onBeforeRenderTargetsRenderObserver;
  54719. private _onAfterRenderTargetsRenderObserver;
  54720. private _onAfterRenderObserver;
  54721. private _onBeforeDrawPhaseObserver;
  54722. private _onAfterDrawPhaseObserver;
  54723. private _onBeforeAnimationsObserver;
  54724. private _onBeforeParticlesRenderingObserver;
  54725. private _onAfterParticlesRenderingObserver;
  54726. private _onBeforeSpritesRenderingObserver;
  54727. private _onAfterSpritesRenderingObserver;
  54728. private _onBeforePhysicsObserver;
  54729. private _onAfterPhysicsObserver;
  54730. private _onAfterAnimationsObserver;
  54731. private _onBeforeCameraRenderObserver;
  54732. private _onAfterCameraRenderObserver;
  54733. /**
  54734. * Gets the perf counter used for active meshes evaluation time
  54735. */
  54736. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54737. /**
  54738. * Gets the active meshes evaluation time capture status
  54739. */
  54740. get captureActiveMeshesEvaluationTime(): boolean;
  54741. /**
  54742. * Enable or disable the active meshes evaluation time capture
  54743. */
  54744. set captureActiveMeshesEvaluationTime(value: boolean);
  54745. /**
  54746. * Gets the perf counter used for render targets render time
  54747. */
  54748. get renderTargetsRenderTimeCounter(): PerfCounter;
  54749. /**
  54750. * Gets the render targets render time capture status
  54751. */
  54752. get captureRenderTargetsRenderTime(): boolean;
  54753. /**
  54754. * Enable or disable the render targets render time capture
  54755. */
  54756. set captureRenderTargetsRenderTime(value: boolean);
  54757. /**
  54758. * Gets the perf counter used for particles render time
  54759. */
  54760. get particlesRenderTimeCounter(): PerfCounter;
  54761. /**
  54762. * Gets the particles render time capture status
  54763. */
  54764. get captureParticlesRenderTime(): boolean;
  54765. /**
  54766. * Enable or disable the particles render time capture
  54767. */
  54768. set captureParticlesRenderTime(value: boolean);
  54769. /**
  54770. * Gets the perf counter used for sprites render time
  54771. */
  54772. get spritesRenderTimeCounter(): PerfCounter;
  54773. /**
  54774. * Gets the sprites render time capture status
  54775. */
  54776. get captureSpritesRenderTime(): boolean;
  54777. /**
  54778. * Enable or disable the sprites render time capture
  54779. */
  54780. set captureSpritesRenderTime(value: boolean);
  54781. /**
  54782. * Gets the perf counter used for physics time
  54783. */
  54784. get physicsTimeCounter(): PerfCounter;
  54785. /**
  54786. * Gets the physics time capture status
  54787. */
  54788. get capturePhysicsTime(): boolean;
  54789. /**
  54790. * Enable or disable the physics time capture
  54791. */
  54792. set capturePhysicsTime(value: boolean);
  54793. /**
  54794. * Gets the perf counter used for animations time
  54795. */
  54796. get animationsTimeCounter(): PerfCounter;
  54797. /**
  54798. * Gets the animations time capture status
  54799. */
  54800. get captureAnimationsTime(): boolean;
  54801. /**
  54802. * Enable or disable the animations time capture
  54803. */
  54804. set captureAnimationsTime(value: boolean);
  54805. /**
  54806. * Gets the perf counter used for frame time capture
  54807. */
  54808. get frameTimeCounter(): PerfCounter;
  54809. /**
  54810. * Gets the frame time capture status
  54811. */
  54812. get captureFrameTime(): boolean;
  54813. /**
  54814. * Enable or disable the frame time capture
  54815. */
  54816. set captureFrameTime(value: boolean);
  54817. /**
  54818. * Gets the perf counter used for inter-frames time capture
  54819. */
  54820. get interFrameTimeCounter(): PerfCounter;
  54821. /**
  54822. * Gets the inter-frames time capture status
  54823. */
  54824. get captureInterFrameTime(): boolean;
  54825. /**
  54826. * Enable or disable the inter-frames time capture
  54827. */
  54828. set captureInterFrameTime(value: boolean);
  54829. /**
  54830. * Gets the perf counter used for render time capture
  54831. */
  54832. get renderTimeCounter(): PerfCounter;
  54833. /**
  54834. * Gets the render time capture status
  54835. */
  54836. get captureRenderTime(): boolean;
  54837. /**
  54838. * Enable or disable the render time capture
  54839. */
  54840. set captureRenderTime(value: boolean);
  54841. /**
  54842. * Gets the perf counter used for camera render time capture
  54843. */
  54844. get cameraRenderTimeCounter(): PerfCounter;
  54845. /**
  54846. * Gets the camera render time capture status
  54847. */
  54848. get captureCameraRenderTime(): boolean;
  54849. /**
  54850. * Enable or disable the camera render time capture
  54851. */
  54852. set captureCameraRenderTime(value: boolean);
  54853. /**
  54854. * Gets the perf counter used for draw calls
  54855. */
  54856. get drawCallsCounter(): PerfCounter;
  54857. /**
  54858. * Instantiates a new scene instrumentation.
  54859. * This class can be used to get instrumentation data from a Babylon engine
  54860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54861. * @param scene Defines the scene to instrument
  54862. */
  54863. constructor(
  54864. /**
  54865. * Defines the scene to instrument
  54866. */
  54867. scene: Scene);
  54868. /**
  54869. * Dispose and release associated resources.
  54870. */
  54871. dispose(): void;
  54872. }
  54873. }
  54874. declare module "babylonjs/Instrumentation/index" {
  54875. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54876. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54877. export * from "babylonjs/Instrumentation/timeToken";
  54878. }
  54879. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54880. /** @hidden */
  54881. export var glowMapGenerationPixelShader: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54887. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54888. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54889. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54890. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54891. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54892. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54893. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54894. /** @hidden */
  54895. export var glowMapGenerationVertexShader: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module "babylonjs/Layers/effectLayer" {
  54901. import { Observable } from "babylonjs/Misc/observable";
  54902. import { Nullable } from "babylonjs/types";
  54903. import { Camera } from "babylonjs/Cameras/camera";
  54904. import { Scene } from "babylonjs/scene";
  54905. import { ISize } from "babylonjs/Maths/math.size";
  54906. import { Color4 } from "babylonjs/Maths/math.color";
  54907. import { Engine } from "babylonjs/Engines/engine";
  54908. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54910. import { Mesh } from "babylonjs/Meshes/mesh";
  54911. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54913. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54914. import { Effect } from "babylonjs/Materials/effect";
  54915. import { Material } from "babylonjs/Materials/material";
  54916. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54917. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54918. /**
  54919. * Effect layer options. This helps customizing the behaviour
  54920. * of the effect layer.
  54921. */
  54922. export interface IEffectLayerOptions {
  54923. /**
  54924. * Multiplication factor apply to the canvas size to compute the render target size
  54925. * used to generated the objects (the smaller the faster).
  54926. */
  54927. mainTextureRatio: number;
  54928. /**
  54929. * Enforces a fixed size texture to ensure effect stability across devices.
  54930. */
  54931. mainTextureFixedSize?: number;
  54932. /**
  54933. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54934. */
  54935. alphaBlendingMode: number;
  54936. /**
  54937. * The camera attached to the layer.
  54938. */
  54939. camera: Nullable<Camera>;
  54940. /**
  54941. * The rendering group to draw the layer in.
  54942. */
  54943. renderingGroupId: number;
  54944. }
  54945. /**
  54946. * The effect layer Helps adding post process effect blended with the main pass.
  54947. *
  54948. * This can be for instance use to generate glow or higlight effects on the scene.
  54949. *
  54950. * The effect layer class can not be used directly and is intented to inherited from to be
  54951. * customized per effects.
  54952. */
  54953. export abstract class EffectLayer {
  54954. private _vertexBuffers;
  54955. private _indexBuffer;
  54956. private _cachedDefines;
  54957. private _effectLayerMapGenerationEffect;
  54958. private _effectLayerOptions;
  54959. private _mergeEffect;
  54960. protected _scene: Scene;
  54961. protected _engine: Engine;
  54962. protected _maxSize: number;
  54963. protected _mainTextureDesiredSize: ISize;
  54964. protected _mainTexture: RenderTargetTexture;
  54965. protected _shouldRender: boolean;
  54966. protected _postProcesses: PostProcess[];
  54967. protected _textures: BaseTexture[];
  54968. protected _emissiveTextureAndColor: {
  54969. texture: Nullable<BaseTexture>;
  54970. color: Color4;
  54971. };
  54972. /**
  54973. * The name of the layer
  54974. */
  54975. name: string;
  54976. /**
  54977. * The clear color of the texture used to generate the glow map.
  54978. */
  54979. neutralColor: Color4;
  54980. /**
  54981. * Specifies whether the highlight layer is enabled or not.
  54982. */
  54983. isEnabled: boolean;
  54984. /**
  54985. * Gets the camera attached to the layer.
  54986. */
  54987. get camera(): Nullable<Camera>;
  54988. /**
  54989. * Gets the rendering group id the layer should render in.
  54990. */
  54991. get renderingGroupId(): number;
  54992. set renderingGroupId(renderingGroupId: number);
  54993. /**
  54994. * An event triggered when the effect layer has been disposed.
  54995. */
  54996. onDisposeObservable: Observable<EffectLayer>;
  54997. /**
  54998. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54999. */
  55000. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55001. /**
  55002. * An event triggered when the generated texture is being merged in the scene.
  55003. */
  55004. onBeforeComposeObservable: Observable<EffectLayer>;
  55005. /**
  55006. * An event triggered when the mesh is rendered into the effect render target.
  55007. */
  55008. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55009. /**
  55010. * An event triggered after the mesh has been rendered into the effect render target.
  55011. */
  55012. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55013. /**
  55014. * An event triggered when the generated texture has been merged in the scene.
  55015. */
  55016. onAfterComposeObservable: Observable<EffectLayer>;
  55017. /**
  55018. * An event triggered when the efffect layer changes its size.
  55019. */
  55020. onSizeChangedObservable: Observable<EffectLayer>;
  55021. /** @hidden */
  55022. static _SceneComponentInitialization: (scene: Scene) => void;
  55023. /**
  55024. * Instantiates a new effect Layer and references it in the scene.
  55025. * @param name The name of the layer
  55026. * @param scene The scene to use the layer in
  55027. */
  55028. constructor(
  55029. /** The Friendly of the effect in the scene */
  55030. name: string, scene: Scene);
  55031. /**
  55032. * Get the effect name of the layer.
  55033. * @return The effect name
  55034. */
  55035. abstract getEffectName(): string;
  55036. /**
  55037. * Checks for the readiness of the element composing the layer.
  55038. * @param subMesh the mesh to check for
  55039. * @param useInstances specify whether or not to use instances to render the mesh
  55040. * @return true if ready otherwise, false
  55041. */
  55042. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55043. /**
  55044. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55045. * @returns true if the effect requires stencil during the main canvas render pass.
  55046. */
  55047. abstract needStencil(): boolean;
  55048. /**
  55049. * Create the merge effect. This is the shader use to blit the information back
  55050. * to the main canvas at the end of the scene rendering.
  55051. * @returns The effect containing the shader used to merge the effect on the main canvas
  55052. */
  55053. protected abstract _createMergeEffect(): Effect;
  55054. /**
  55055. * Creates the render target textures and post processes used in the effect layer.
  55056. */
  55057. protected abstract _createTextureAndPostProcesses(): void;
  55058. /**
  55059. * Implementation specific of rendering the generating effect on the main canvas.
  55060. * @param effect The effect used to render through
  55061. */
  55062. protected abstract _internalRender(effect: Effect): void;
  55063. /**
  55064. * Sets the required values for both the emissive texture and and the main color.
  55065. */
  55066. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55067. /**
  55068. * Free any resources and references associated to a mesh.
  55069. * Internal use
  55070. * @param mesh The mesh to free.
  55071. */
  55072. abstract _disposeMesh(mesh: Mesh): void;
  55073. /**
  55074. * Serializes this layer (Glow or Highlight for example)
  55075. * @returns a serialized layer object
  55076. */
  55077. abstract serialize?(): any;
  55078. /**
  55079. * Initializes the effect layer with the required options.
  55080. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55081. */
  55082. protected _init(options: Partial<IEffectLayerOptions>): void;
  55083. /**
  55084. * Generates the index buffer of the full screen quad blending to the main canvas.
  55085. */
  55086. private _generateIndexBuffer;
  55087. /**
  55088. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55089. */
  55090. private _generateVertexBuffer;
  55091. /**
  55092. * Sets the main texture desired size which is the closest power of two
  55093. * of the engine canvas size.
  55094. */
  55095. private _setMainTextureSize;
  55096. /**
  55097. * Creates the main texture for the effect layer.
  55098. */
  55099. protected _createMainTexture(): void;
  55100. /**
  55101. * Adds specific effects defines.
  55102. * @param defines The defines to add specifics to.
  55103. */
  55104. protected _addCustomEffectDefines(defines: string[]): void;
  55105. /**
  55106. * Checks for the readiness of the element composing the layer.
  55107. * @param subMesh the mesh to check for
  55108. * @param useInstances specify whether or not to use instances to render the mesh
  55109. * @param emissiveTexture the associated emissive texture used to generate the glow
  55110. * @return true if ready otherwise, false
  55111. */
  55112. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55113. /**
  55114. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55115. */
  55116. render(): void;
  55117. /**
  55118. * Determine if a given mesh will be used in the current effect.
  55119. * @param mesh mesh to test
  55120. * @returns true if the mesh will be used
  55121. */
  55122. hasMesh(mesh: AbstractMesh): boolean;
  55123. /**
  55124. * Returns true if the layer contains information to display, otherwise false.
  55125. * @returns true if the glow layer should be rendered
  55126. */
  55127. shouldRender(): boolean;
  55128. /**
  55129. * Returns true if the mesh should render, otherwise false.
  55130. * @param mesh The mesh to render
  55131. * @returns true if it should render otherwise false
  55132. */
  55133. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55134. /**
  55135. * Returns true if the mesh can be rendered, otherwise false.
  55136. * @param mesh The mesh to render
  55137. * @param material The material used on the mesh
  55138. * @returns true if it can be rendered otherwise false
  55139. */
  55140. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55141. /**
  55142. * Returns true if the mesh should render, otherwise false.
  55143. * @param mesh The mesh to render
  55144. * @returns true if it should render otherwise false
  55145. */
  55146. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55147. /**
  55148. * Renders the submesh passed in parameter to the generation map.
  55149. */
  55150. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55151. /**
  55152. * Defines whether the current material of the mesh should be use to render the effect.
  55153. * @param mesh defines the current mesh to render
  55154. */
  55155. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55156. /**
  55157. * Rebuild the required buffers.
  55158. * @hidden Internal use only.
  55159. */
  55160. _rebuild(): void;
  55161. /**
  55162. * Dispose only the render target textures and post process.
  55163. */
  55164. private _disposeTextureAndPostProcesses;
  55165. /**
  55166. * Dispose the highlight layer and free resources.
  55167. */
  55168. dispose(): void;
  55169. /**
  55170. * Gets the class name of the effect layer
  55171. * @returns the string with the class name of the effect layer
  55172. */
  55173. getClassName(): string;
  55174. /**
  55175. * Creates an effect layer from parsed effect layer data
  55176. * @param parsedEffectLayer defines effect layer data
  55177. * @param scene defines the current scene
  55178. * @param rootUrl defines the root URL containing the effect layer information
  55179. * @returns a parsed effect Layer
  55180. */
  55181. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55182. }
  55183. }
  55184. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55185. import { Scene } from "babylonjs/scene";
  55186. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55187. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55188. import { AbstractScene } from "babylonjs/abstractScene";
  55189. module "babylonjs/abstractScene" {
  55190. interface AbstractScene {
  55191. /**
  55192. * The list of effect layers (highlights/glow) added to the scene
  55193. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55194. * @see http://doc.babylonjs.com/how_to/glow_layer
  55195. */
  55196. effectLayers: Array<EffectLayer>;
  55197. /**
  55198. * Removes the given effect layer from this scene.
  55199. * @param toRemove defines the effect layer to remove
  55200. * @returns the index of the removed effect layer
  55201. */
  55202. removeEffectLayer(toRemove: EffectLayer): number;
  55203. /**
  55204. * Adds the given effect layer to this scene
  55205. * @param newEffectLayer defines the effect layer to add
  55206. */
  55207. addEffectLayer(newEffectLayer: EffectLayer): void;
  55208. }
  55209. }
  55210. /**
  55211. * Defines the layer scene component responsible to manage any effect layers
  55212. * in a given scene.
  55213. */
  55214. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55215. /**
  55216. * The component name helpfull to identify the component in the list of scene components.
  55217. */
  55218. readonly name: string;
  55219. /**
  55220. * The scene the component belongs to.
  55221. */
  55222. scene: Scene;
  55223. private _engine;
  55224. private _renderEffects;
  55225. private _needStencil;
  55226. private _previousStencilState;
  55227. /**
  55228. * Creates a new instance of the component for the given scene
  55229. * @param scene Defines the scene to register the component in
  55230. */
  55231. constructor(scene: Scene);
  55232. /**
  55233. * Registers the component in a given scene
  55234. */
  55235. register(): void;
  55236. /**
  55237. * Rebuilds the elements related to this component in case of
  55238. * context lost for instance.
  55239. */
  55240. rebuild(): void;
  55241. /**
  55242. * Serializes the component data to the specified json object
  55243. * @param serializationObject The object to serialize to
  55244. */
  55245. serialize(serializationObject: any): void;
  55246. /**
  55247. * Adds all the elements from the container to the scene
  55248. * @param container the container holding the elements
  55249. */
  55250. addFromContainer(container: AbstractScene): void;
  55251. /**
  55252. * Removes all the elements in the container from the scene
  55253. * @param container contains the elements to remove
  55254. * @param dispose if the removed element should be disposed (default: false)
  55255. */
  55256. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55257. /**
  55258. * Disposes the component and the associated ressources.
  55259. */
  55260. dispose(): void;
  55261. private _isReadyForMesh;
  55262. private _renderMainTexture;
  55263. private _setStencil;
  55264. private _setStencilBack;
  55265. private _draw;
  55266. private _drawCamera;
  55267. private _drawRenderingGroup;
  55268. }
  55269. }
  55270. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55271. /** @hidden */
  55272. export var glowMapMergePixelShader: {
  55273. name: string;
  55274. shader: string;
  55275. };
  55276. }
  55277. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55278. /** @hidden */
  55279. export var glowMapMergeVertexShader: {
  55280. name: string;
  55281. shader: string;
  55282. };
  55283. }
  55284. declare module "babylonjs/Layers/glowLayer" {
  55285. import { Nullable } from "babylonjs/types";
  55286. import { Camera } from "babylonjs/Cameras/camera";
  55287. import { Scene } from "babylonjs/scene";
  55288. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55290. import { Mesh } from "babylonjs/Meshes/mesh";
  55291. import { Texture } from "babylonjs/Materials/Textures/texture";
  55292. import { Effect } from "babylonjs/Materials/effect";
  55293. import { Material } from "babylonjs/Materials/material";
  55294. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55295. import { Color4 } from "babylonjs/Maths/math.color";
  55296. import "babylonjs/Shaders/glowMapMerge.fragment";
  55297. import "babylonjs/Shaders/glowMapMerge.vertex";
  55298. import "babylonjs/Layers/effectLayerSceneComponent";
  55299. module "babylonjs/abstractScene" {
  55300. interface AbstractScene {
  55301. /**
  55302. * Return a the first highlight layer of the scene with a given name.
  55303. * @param name The name of the highlight layer to look for.
  55304. * @return The highlight layer if found otherwise null.
  55305. */
  55306. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55307. }
  55308. }
  55309. /**
  55310. * Glow layer options. This helps customizing the behaviour
  55311. * of the glow layer.
  55312. */
  55313. export interface IGlowLayerOptions {
  55314. /**
  55315. * Multiplication factor apply to the canvas size to compute the render target size
  55316. * used to generated the glowing objects (the smaller the faster).
  55317. */
  55318. mainTextureRatio: number;
  55319. /**
  55320. * Enforces a fixed size texture to ensure resize independant blur.
  55321. */
  55322. mainTextureFixedSize?: number;
  55323. /**
  55324. * How big is the kernel of the blur texture.
  55325. */
  55326. blurKernelSize: number;
  55327. /**
  55328. * The camera attached to the layer.
  55329. */
  55330. camera: Nullable<Camera>;
  55331. /**
  55332. * Enable MSAA by chosing the number of samples.
  55333. */
  55334. mainTextureSamples?: number;
  55335. /**
  55336. * The rendering group to draw the layer in.
  55337. */
  55338. renderingGroupId: number;
  55339. }
  55340. /**
  55341. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55342. *
  55343. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55344. *
  55345. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55346. */
  55347. export class GlowLayer extends EffectLayer {
  55348. /**
  55349. * Effect Name of the layer.
  55350. */
  55351. static readonly EffectName: string;
  55352. /**
  55353. * The default blur kernel size used for the glow.
  55354. */
  55355. static DefaultBlurKernelSize: number;
  55356. /**
  55357. * The default texture size ratio used for the glow.
  55358. */
  55359. static DefaultTextureRatio: number;
  55360. /**
  55361. * Sets the kernel size of the blur.
  55362. */
  55363. set blurKernelSize(value: number);
  55364. /**
  55365. * Gets the kernel size of the blur.
  55366. */
  55367. get blurKernelSize(): number;
  55368. /**
  55369. * Sets the glow intensity.
  55370. */
  55371. set intensity(value: number);
  55372. /**
  55373. * Gets the glow intensity.
  55374. */
  55375. get intensity(): number;
  55376. private _options;
  55377. private _intensity;
  55378. private _horizontalBlurPostprocess1;
  55379. private _verticalBlurPostprocess1;
  55380. private _horizontalBlurPostprocess2;
  55381. private _verticalBlurPostprocess2;
  55382. private _blurTexture1;
  55383. private _blurTexture2;
  55384. private _postProcesses1;
  55385. private _postProcesses2;
  55386. private _includedOnlyMeshes;
  55387. private _excludedMeshes;
  55388. private _meshesUsingTheirOwnMaterials;
  55389. /**
  55390. * Callback used to let the user override the color selection on a per mesh basis
  55391. */
  55392. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55393. /**
  55394. * Callback used to let the user override the texture selection on a per mesh basis
  55395. */
  55396. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55397. /**
  55398. * Instantiates a new glow Layer and references it to the scene.
  55399. * @param name The name of the layer
  55400. * @param scene The scene to use the layer in
  55401. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55402. */
  55403. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55404. /**
  55405. * Get the effect name of the layer.
  55406. * @return The effect name
  55407. */
  55408. getEffectName(): string;
  55409. /**
  55410. * Create the merge effect. This is the shader use to blit the information back
  55411. * to the main canvas at the end of the scene rendering.
  55412. */
  55413. protected _createMergeEffect(): Effect;
  55414. /**
  55415. * Creates the render target textures and post processes used in the glow layer.
  55416. */
  55417. protected _createTextureAndPostProcesses(): void;
  55418. /**
  55419. * Checks for the readiness of the element composing the layer.
  55420. * @param subMesh the mesh to check for
  55421. * @param useInstances specify wether or not to use instances to render the mesh
  55422. * @param emissiveTexture the associated emissive texture used to generate the glow
  55423. * @return true if ready otherwise, false
  55424. */
  55425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55426. /**
  55427. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55428. */
  55429. needStencil(): boolean;
  55430. /**
  55431. * Returns true if the mesh can be rendered, otherwise false.
  55432. * @param mesh The mesh to render
  55433. * @param material The material used on the mesh
  55434. * @returns true if it can be rendered otherwise false
  55435. */
  55436. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55437. /**
  55438. * Implementation specific of rendering the generating effect on the main canvas.
  55439. * @param effect The effect used to render through
  55440. */
  55441. protected _internalRender(effect: Effect): void;
  55442. /**
  55443. * Sets the required values for both the emissive texture and and the main color.
  55444. */
  55445. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55446. /**
  55447. * Returns true if the mesh should render, otherwise false.
  55448. * @param mesh The mesh to render
  55449. * @returns true if it should render otherwise false
  55450. */
  55451. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55452. /**
  55453. * Adds specific effects defines.
  55454. * @param defines The defines to add specifics to.
  55455. */
  55456. protected _addCustomEffectDefines(defines: string[]): void;
  55457. /**
  55458. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55459. * @param mesh The mesh to exclude from the glow layer
  55460. */
  55461. addExcludedMesh(mesh: Mesh): void;
  55462. /**
  55463. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55464. * @param mesh The mesh to remove
  55465. */
  55466. removeExcludedMesh(mesh: Mesh): void;
  55467. /**
  55468. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55469. * @param mesh The mesh to include in the glow layer
  55470. */
  55471. addIncludedOnlyMesh(mesh: Mesh): void;
  55472. /**
  55473. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55474. * @param mesh The mesh to remove
  55475. */
  55476. removeIncludedOnlyMesh(mesh: Mesh): void;
  55477. /**
  55478. * Determine if a given mesh will be used in the glow layer
  55479. * @param mesh The mesh to test
  55480. * @returns true if the mesh will be highlighted by the current glow layer
  55481. */
  55482. hasMesh(mesh: AbstractMesh): boolean;
  55483. /**
  55484. * Defines whether the current material of the mesh should be use to render the effect.
  55485. * @param mesh defines the current mesh to render
  55486. */
  55487. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55488. /**
  55489. * Add a mesh to be rendered through its own material and not with emissive only.
  55490. * @param mesh The mesh for which we need to use its material
  55491. */
  55492. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55493. /**
  55494. * Remove a mesh from being rendered through its own material and not with emissive only.
  55495. * @param mesh The mesh for which we need to not use its material
  55496. */
  55497. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55498. /**
  55499. * Free any resources and references associated to a mesh.
  55500. * Internal use
  55501. * @param mesh The mesh to free.
  55502. * @hidden
  55503. */
  55504. _disposeMesh(mesh: Mesh): void;
  55505. /**
  55506. * Gets the class name of the effect layer
  55507. * @returns the string with the class name of the effect layer
  55508. */
  55509. getClassName(): string;
  55510. /**
  55511. * Serializes this glow layer
  55512. * @returns a serialized glow layer object
  55513. */
  55514. serialize(): any;
  55515. /**
  55516. * Creates a Glow Layer from parsed glow layer data
  55517. * @param parsedGlowLayer defines glow layer data
  55518. * @param scene defines the current scene
  55519. * @param rootUrl defines the root URL containing the glow layer information
  55520. * @returns a parsed Glow Layer
  55521. */
  55522. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55523. }
  55524. }
  55525. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55526. /** @hidden */
  55527. export var glowBlurPostProcessPixelShader: {
  55528. name: string;
  55529. shader: string;
  55530. };
  55531. }
  55532. declare module "babylonjs/Layers/highlightLayer" {
  55533. import { Observable } from "babylonjs/Misc/observable";
  55534. import { Nullable } from "babylonjs/types";
  55535. import { Camera } from "babylonjs/Cameras/camera";
  55536. import { Scene } from "babylonjs/scene";
  55537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55539. import { Mesh } from "babylonjs/Meshes/mesh";
  55540. import { Effect } from "babylonjs/Materials/effect";
  55541. import { Material } from "babylonjs/Materials/material";
  55542. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55543. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55544. import "babylonjs/Shaders/glowMapMerge.fragment";
  55545. import "babylonjs/Shaders/glowMapMerge.vertex";
  55546. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55547. module "babylonjs/abstractScene" {
  55548. interface AbstractScene {
  55549. /**
  55550. * Return a the first highlight layer of the scene with a given name.
  55551. * @param name The name of the highlight layer to look for.
  55552. * @return The highlight layer if found otherwise null.
  55553. */
  55554. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55555. }
  55556. }
  55557. /**
  55558. * Highlight layer options. This helps customizing the behaviour
  55559. * of the highlight layer.
  55560. */
  55561. export interface IHighlightLayerOptions {
  55562. /**
  55563. * Multiplication factor apply to the canvas size to compute the render target size
  55564. * used to generated the glowing objects (the smaller the faster).
  55565. */
  55566. mainTextureRatio: number;
  55567. /**
  55568. * Enforces a fixed size texture to ensure resize independant blur.
  55569. */
  55570. mainTextureFixedSize?: number;
  55571. /**
  55572. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55573. * of the picture to blur (the smaller the faster).
  55574. */
  55575. blurTextureSizeRatio: number;
  55576. /**
  55577. * How big in texel of the blur texture is the vertical blur.
  55578. */
  55579. blurVerticalSize: number;
  55580. /**
  55581. * How big in texel of the blur texture is the horizontal blur.
  55582. */
  55583. blurHorizontalSize: number;
  55584. /**
  55585. * Alpha blending mode used to apply the blur. Default is combine.
  55586. */
  55587. alphaBlendingMode: number;
  55588. /**
  55589. * The camera attached to the layer.
  55590. */
  55591. camera: Nullable<Camera>;
  55592. /**
  55593. * Should we display highlight as a solid stroke?
  55594. */
  55595. isStroke?: boolean;
  55596. /**
  55597. * The rendering group to draw the layer in.
  55598. */
  55599. renderingGroupId: number;
  55600. }
  55601. /**
  55602. * The highlight layer Helps adding a glow effect around a mesh.
  55603. *
  55604. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55605. * glowy meshes to your scene.
  55606. *
  55607. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55608. */
  55609. export class HighlightLayer extends EffectLayer {
  55610. name: string;
  55611. /**
  55612. * Effect Name of the highlight layer.
  55613. */
  55614. static readonly EffectName: string;
  55615. /**
  55616. * The neutral color used during the preparation of the glow effect.
  55617. * This is black by default as the blend operation is a blend operation.
  55618. */
  55619. static NeutralColor: Color4;
  55620. /**
  55621. * Stencil value used for glowing meshes.
  55622. */
  55623. static GlowingMeshStencilReference: number;
  55624. /**
  55625. * Stencil value used for the other meshes in the scene.
  55626. */
  55627. static NormalMeshStencilReference: number;
  55628. /**
  55629. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55630. */
  55631. innerGlow: boolean;
  55632. /**
  55633. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55634. */
  55635. outerGlow: boolean;
  55636. /**
  55637. * Specifies the horizontal size of the blur.
  55638. */
  55639. set blurHorizontalSize(value: number);
  55640. /**
  55641. * Specifies the vertical size of the blur.
  55642. */
  55643. set blurVerticalSize(value: number);
  55644. /**
  55645. * Gets the horizontal size of the blur.
  55646. */
  55647. get blurHorizontalSize(): number;
  55648. /**
  55649. * Gets the vertical size of the blur.
  55650. */
  55651. get blurVerticalSize(): number;
  55652. /**
  55653. * An event triggered when the highlight layer is being blurred.
  55654. */
  55655. onBeforeBlurObservable: Observable<HighlightLayer>;
  55656. /**
  55657. * An event triggered when the highlight layer has been blurred.
  55658. */
  55659. onAfterBlurObservable: Observable<HighlightLayer>;
  55660. private _instanceGlowingMeshStencilReference;
  55661. private _options;
  55662. private _downSamplePostprocess;
  55663. private _horizontalBlurPostprocess;
  55664. private _verticalBlurPostprocess;
  55665. private _blurTexture;
  55666. private _meshes;
  55667. private _excludedMeshes;
  55668. /**
  55669. * Instantiates a new highlight Layer and references it to the scene..
  55670. * @param name The name of the layer
  55671. * @param scene The scene to use the layer in
  55672. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55673. */
  55674. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55675. /**
  55676. * Get the effect name of the layer.
  55677. * @return The effect name
  55678. */
  55679. getEffectName(): string;
  55680. /**
  55681. * Create the merge effect. This is the shader use to blit the information back
  55682. * to the main canvas at the end of the scene rendering.
  55683. */
  55684. protected _createMergeEffect(): Effect;
  55685. /**
  55686. * Creates the render target textures and post processes used in the highlight layer.
  55687. */
  55688. protected _createTextureAndPostProcesses(): void;
  55689. /**
  55690. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55691. */
  55692. needStencil(): boolean;
  55693. /**
  55694. * Checks for the readiness of the element composing the layer.
  55695. * @param subMesh the mesh to check for
  55696. * @param useInstances specify wether or not to use instances to render the mesh
  55697. * @param emissiveTexture the associated emissive texture used to generate the glow
  55698. * @return true if ready otherwise, false
  55699. */
  55700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55701. /**
  55702. * Implementation specific of rendering the generating effect on the main canvas.
  55703. * @param effect The effect used to render through
  55704. */
  55705. protected _internalRender(effect: Effect): void;
  55706. /**
  55707. * Returns true if the layer contains information to display, otherwise false.
  55708. */
  55709. shouldRender(): boolean;
  55710. /**
  55711. * Returns true if the mesh should render, otherwise false.
  55712. * @param mesh The mesh to render
  55713. * @returns true if it should render otherwise false
  55714. */
  55715. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55716. /**
  55717. * Sets the required values for both the emissive texture and and the main color.
  55718. */
  55719. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55720. /**
  55721. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55722. * @param mesh The mesh to exclude from the highlight layer
  55723. */
  55724. addExcludedMesh(mesh: Mesh): void;
  55725. /**
  55726. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55727. * @param mesh The mesh to highlight
  55728. */
  55729. removeExcludedMesh(mesh: Mesh): void;
  55730. /**
  55731. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55732. * @param mesh mesh to test
  55733. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55734. */
  55735. hasMesh(mesh: AbstractMesh): boolean;
  55736. /**
  55737. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55738. * @param mesh The mesh to highlight
  55739. * @param color The color of the highlight
  55740. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55741. */
  55742. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55743. /**
  55744. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55745. * @param mesh The mesh to highlight
  55746. */
  55747. removeMesh(mesh: Mesh): void;
  55748. /**
  55749. * Force the stencil to the normal expected value for none glowing parts
  55750. */
  55751. private _defaultStencilReference;
  55752. /**
  55753. * Free any resources and references associated to a mesh.
  55754. * Internal use
  55755. * @param mesh The mesh to free.
  55756. * @hidden
  55757. */
  55758. _disposeMesh(mesh: Mesh): void;
  55759. /**
  55760. * Dispose the highlight layer and free resources.
  55761. */
  55762. dispose(): void;
  55763. /**
  55764. * Gets the class name of the effect layer
  55765. * @returns the string with the class name of the effect layer
  55766. */
  55767. getClassName(): string;
  55768. /**
  55769. * Serializes this Highlight layer
  55770. * @returns a serialized Highlight layer object
  55771. */
  55772. serialize(): any;
  55773. /**
  55774. * Creates a Highlight layer from parsed Highlight layer data
  55775. * @param parsedHightlightLayer defines the Highlight layer data
  55776. * @param scene defines the current scene
  55777. * @param rootUrl defines the root URL containing the Highlight layer information
  55778. * @returns a parsed Highlight layer
  55779. */
  55780. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55781. }
  55782. }
  55783. declare module "babylonjs/Layers/layerSceneComponent" {
  55784. import { Scene } from "babylonjs/scene";
  55785. import { ISceneComponent } from "babylonjs/sceneComponent";
  55786. import { Layer } from "babylonjs/Layers/layer";
  55787. import { AbstractScene } from "babylonjs/abstractScene";
  55788. module "babylonjs/abstractScene" {
  55789. interface AbstractScene {
  55790. /**
  55791. * The list of layers (background and foreground) of the scene
  55792. */
  55793. layers: Array<Layer>;
  55794. }
  55795. }
  55796. /**
  55797. * Defines the layer scene component responsible to manage any layers
  55798. * in a given scene.
  55799. */
  55800. export class LayerSceneComponent implements ISceneComponent {
  55801. /**
  55802. * The component name helpfull to identify the component in the list of scene components.
  55803. */
  55804. readonly name: string;
  55805. /**
  55806. * The scene the component belongs to.
  55807. */
  55808. scene: Scene;
  55809. private _engine;
  55810. /**
  55811. * Creates a new instance of the component for the given scene
  55812. * @param scene Defines the scene to register the component in
  55813. */
  55814. constructor(scene: Scene);
  55815. /**
  55816. * Registers the component in a given scene
  55817. */
  55818. register(): void;
  55819. /**
  55820. * Rebuilds the elements related to this component in case of
  55821. * context lost for instance.
  55822. */
  55823. rebuild(): void;
  55824. /**
  55825. * Disposes the component and the associated ressources.
  55826. */
  55827. dispose(): void;
  55828. private _draw;
  55829. private _drawCameraPredicate;
  55830. private _drawCameraBackground;
  55831. private _drawCameraForeground;
  55832. private _drawRenderTargetPredicate;
  55833. private _drawRenderTargetBackground;
  55834. private _drawRenderTargetForeground;
  55835. /**
  55836. * Adds all the elements from the container to the scene
  55837. * @param container the container holding the elements
  55838. */
  55839. addFromContainer(container: AbstractScene): void;
  55840. /**
  55841. * Removes all the elements in the container from the scene
  55842. * @param container contains the elements to remove
  55843. * @param dispose if the removed element should be disposed (default: false)
  55844. */
  55845. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55846. }
  55847. }
  55848. declare module "babylonjs/Shaders/layer.fragment" {
  55849. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55850. /** @hidden */
  55851. export var layerPixelShader: {
  55852. name: string;
  55853. shader: string;
  55854. };
  55855. }
  55856. declare module "babylonjs/Shaders/layer.vertex" {
  55857. /** @hidden */
  55858. export var layerVertexShader: {
  55859. name: string;
  55860. shader: string;
  55861. };
  55862. }
  55863. declare module "babylonjs/Layers/layer" {
  55864. import { Observable } from "babylonjs/Misc/observable";
  55865. import { Nullable } from "babylonjs/types";
  55866. import { Scene } from "babylonjs/scene";
  55867. import { Vector2 } from "babylonjs/Maths/math.vector";
  55868. import { Color4 } from "babylonjs/Maths/math.color";
  55869. import { Texture } from "babylonjs/Materials/Textures/texture";
  55870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55871. import "babylonjs/Shaders/layer.fragment";
  55872. import "babylonjs/Shaders/layer.vertex";
  55873. /**
  55874. * This represents a full screen 2d layer.
  55875. * This can be useful to display a picture in the background of your scene for instance.
  55876. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55877. */
  55878. export class Layer {
  55879. /**
  55880. * Define the name of the layer.
  55881. */
  55882. name: string;
  55883. /**
  55884. * Define the texture the layer should display.
  55885. */
  55886. texture: Nullable<Texture>;
  55887. /**
  55888. * Is the layer in background or foreground.
  55889. */
  55890. isBackground: boolean;
  55891. /**
  55892. * Define the color of the layer (instead of texture).
  55893. */
  55894. color: Color4;
  55895. /**
  55896. * Define the scale of the layer in order to zoom in out of the texture.
  55897. */
  55898. scale: Vector2;
  55899. /**
  55900. * Define an offset for the layer in order to shift the texture.
  55901. */
  55902. offset: Vector2;
  55903. /**
  55904. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55905. */
  55906. alphaBlendingMode: number;
  55907. /**
  55908. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55909. * Alpha test will not mix with the background color in case of transparency.
  55910. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55911. */
  55912. alphaTest: boolean;
  55913. /**
  55914. * Define a mask to restrict the layer to only some of the scene cameras.
  55915. */
  55916. layerMask: number;
  55917. /**
  55918. * Define the list of render target the layer is visible into.
  55919. */
  55920. renderTargetTextures: RenderTargetTexture[];
  55921. /**
  55922. * Define if the layer is only used in renderTarget or if it also
  55923. * renders in the main frame buffer of the canvas.
  55924. */
  55925. renderOnlyInRenderTargetTextures: boolean;
  55926. private _scene;
  55927. private _vertexBuffers;
  55928. private _indexBuffer;
  55929. private _effect;
  55930. private _previousDefines;
  55931. /**
  55932. * An event triggered when the layer is disposed.
  55933. */
  55934. onDisposeObservable: Observable<Layer>;
  55935. private _onDisposeObserver;
  55936. /**
  55937. * Back compatibility with callback before the onDisposeObservable existed.
  55938. * The set callback will be triggered when the layer has been disposed.
  55939. */
  55940. set onDispose(callback: () => void);
  55941. /**
  55942. * An event triggered before rendering the scene
  55943. */
  55944. onBeforeRenderObservable: Observable<Layer>;
  55945. private _onBeforeRenderObserver;
  55946. /**
  55947. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55948. * The set callback will be triggered just before rendering the layer.
  55949. */
  55950. set onBeforeRender(callback: () => void);
  55951. /**
  55952. * An event triggered after rendering the scene
  55953. */
  55954. onAfterRenderObservable: Observable<Layer>;
  55955. private _onAfterRenderObserver;
  55956. /**
  55957. * Back compatibility with callback before the onAfterRenderObservable existed.
  55958. * The set callback will be triggered just after rendering the layer.
  55959. */
  55960. set onAfterRender(callback: () => void);
  55961. /**
  55962. * Instantiates a new layer.
  55963. * This represents a full screen 2d layer.
  55964. * This can be useful to display a picture in the background of your scene for instance.
  55965. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55966. * @param name Define the name of the layer in the scene
  55967. * @param imgUrl Define the url of the texture to display in the layer
  55968. * @param scene Define the scene the layer belongs to
  55969. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55970. * @param color Defines a color for the layer
  55971. */
  55972. constructor(
  55973. /**
  55974. * Define the name of the layer.
  55975. */
  55976. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55977. private _createIndexBuffer;
  55978. /** @hidden */
  55979. _rebuild(): void;
  55980. /**
  55981. * Renders the layer in the scene.
  55982. */
  55983. render(): void;
  55984. /**
  55985. * Disposes and releases the associated ressources.
  55986. */
  55987. dispose(): void;
  55988. }
  55989. }
  55990. declare module "babylonjs/Layers/index" {
  55991. export * from "babylonjs/Layers/effectLayer";
  55992. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55993. export * from "babylonjs/Layers/glowLayer";
  55994. export * from "babylonjs/Layers/highlightLayer";
  55995. export * from "babylonjs/Layers/layer";
  55996. export * from "babylonjs/Layers/layerSceneComponent";
  55997. }
  55998. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55999. /** @hidden */
  56000. export var lensFlarePixelShader: {
  56001. name: string;
  56002. shader: string;
  56003. };
  56004. }
  56005. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56006. /** @hidden */
  56007. export var lensFlareVertexShader: {
  56008. name: string;
  56009. shader: string;
  56010. };
  56011. }
  56012. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56013. import { Scene } from "babylonjs/scene";
  56014. import { Vector3 } from "babylonjs/Maths/math.vector";
  56015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56016. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56017. import "babylonjs/Shaders/lensFlare.fragment";
  56018. import "babylonjs/Shaders/lensFlare.vertex";
  56019. import { Viewport } from "babylonjs/Maths/math.viewport";
  56020. /**
  56021. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56022. * It is usually composed of several `lensFlare`.
  56023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56024. */
  56025. export class LensFlareSystem {
  56026. /**
  56027. * Define the name of the lens flare system
  56028. */
  56029. name: string;
  56030. /**
  56031. * List of lens flares used in this system.
  56032. */
  56033. lensFlares: LensFlare[];
  56034. /**
  56035. * Define a limit from the border the lens flare can be visible.
  56036. */
  56037. borderLimit: number;
  56038. /**
  56039. * Define a viewport border we do not want to see the lens flare in.
  56040. */
  56041. viewportBorder: number;
  56042. /**
  56043. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56044. */
  56045. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56046. /**
  56047. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56048. */
  56049. layerMask: number;
  56050. /**
  56051. * Define the id of the lens flare system in the scene.
  56052. * (equal to name by default)
  56053. */
  56054. id: string;
  56055. private _scene;
  56056. private _emitter;
  56057. private _vertexBuffers;
  56058. private _indexBuffer;
  56059. private _effect;
  56060. private _positionX;
  56061. private _positionY;
  56062. private _isEnabled;
  56063. /** @hidden */
  56064. static _SceneComponentInitialization: (scene: Scene) => void;
  56065. /**
  56066. * Instantiates a lens flare system.
  56067. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56068. * It is usually composed of several `lensFlare`.
  56069. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56070. * @param name Define the name of the lens flare system in the scene
  56071. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56072. * @param scene Define the scene the lens flare system belongs to
  56073. */
  56074. constructor(
  56075. /**
  56076. * Define the name of the lens flare system
  56077. */
  56078. name: string, emitter: any, scene: Scene);
  56079. /**
  56080. * Define if the lens flare system is enabled.
  56081. */
  56082. get isEnabled(): boolean;
  56083. set isEnabled(value: boolean);
  56084. /**
  56085. * Get the scene the effects belongs to.
  56086. * @returns the scene holding the lens flare system
  56087. */
  56088. getScene(): Scene;
  56089. /**
  56090. * Get the emitter of the lens flare system.
  56091. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56092. * @returns the emitter of the lens flare system
  56093. */
  56094. getEmitter(): any;
  56095. /**
  56096. * Set the emitter of the lens flare system.
  56097. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56098. * @param newEmitter Define the new emitter of the system
  56099. */
  56100. setEmitter(newEmitter: any): void;
  56101. /**
  56102. * Get the lens flare system emitter position.
  56103. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56104. * @returns the position
  56105. */
  56106. getEmitterPosition(): Vector3;
  56107. /**
  56108. * @hidden
  56109. */
  56110. computeEffectivePosition(globalViewport: Viewport): boolean;
  56111. /** @hidden */
  56112. _isVisible(): boolean;
  56113. /**
  56114. * @hidden
  56115. */
  56116. render(): boolean;
  56117. /**
  56118. * Dispose and release the lens flare with its associated resources.
  56119. */
  56120. dispose(): void;
  56121. /**
  56122. * Parse a lens flare system from a JSON repressentation
  56123. * @param parsedLensFlareSystem Define the JSON to parse
  56124. * @param scene Define the scene the parsed system should be instantiated in
  56125. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56126. * @returns the parsed system
  56127. */
  56128. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56129. /**
  56130. * Serialize the current Lens Flare System into a JSON representation.
  56131. * @returns the serialized JSON
  56132. */
  56133. serialize(): any;
  56134. }
  56135. }
  56136. declare module "babylonjs/LensFlares/lensFlare" {
  56137. import { Nullable } from "babylonjs/types";
  56138. import { Color3 } from "babylonjs/Maths/math.color";
  56139. import { Texture } from "babylonjs/Materials/Textures/texture";
  56140. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56141. /**
  56142. * This represents one of the lens effect in a `lensFlareSystem`.
  56143. * It controls one of the indiviual texture used in the effect.
  56144. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56145. */
  56146. export class LensFlare {
  56147. /**
  56148. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56149. */
  56150. size: number;
  56151. /**
  56152. * 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.
  56153. */
  56154. position: number;
  56155. /**
  56156. * Define the lens color.
  56157. */
  56158. color: Color3;
  56159. /**
  56160. * Define the lens texture.
  56161. */
  56162. texture: Nullable<Texture>;
  56163. /**
  56164. * Define the alpha mode to render this particular lens.
  56165. */
  56166. alphaMode: number;
  56167. private _system;
  56168. /**
  56169. * Creates a new Lens Flare.
  56170. * This represents one of the lens effect in a `lensFlareSystem`.
  56171. * It controls one of the indiviual texture used in the effect.
  56172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56173. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56174. * @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.
  56175. * @param color Define the lens color
  56176. * @param imgUrl Define the lens texture url
  56177. * @param system Define the `lensFlareSystem` this flare is part of
  56178. * @returns The newly created Lens Flare
  56179. */
  56180. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56181. /**
  56182. * Instantiates a new Lens Flare.
  56183. * This represents one of the lens effect in a `lensFlareSystem`.
  56184. * It controls one of the indiviual texture used in the effect.
  56185. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56186. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56187. * @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.
  56188. * @param color Define the lens color
  56189. * @param imgUrl Define the lens texture url
  56190. * @param system Define the `lensFlareSystem` this flare is part of
  56191. */
  56192. constructor(
  56193. /**
  56194. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56195. */
  56196. size: number,
  56197. /**
  56198. * 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.
  56199. */
  56200. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56201. /**
  56202. * Dispose and release the lens flare with its associated resources.
  56203. */
  56204. dispose(): void;
  56205. }
  56206. }
  56207. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56208. import { Nullable } from "babylonjs/types";
  56209. import { Scene } from "babylonjs/scene";
  56210. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56211. import { AbstractScene } from "babylonjs/abstractScene";
  56212. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56213. module "babylonjs/abstractScene" {
  56214. interface AbstractScene {
  56215. /**
  56216. * The list of lens flare system added to the scene
  56217. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56218. */
  56219. lensFlareSystems: Array<LensFlareSystem>;
  56220. /**
  56221. * Removes the given lens flare system from this scene.
  56222. * @param toRemove The lens flare system to remove
  56223. * @returns The index of the removed lens flare system
  56224. */
  56225. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56226. /**
  56227. * Adds the given lens flare system to this scene
  56228. * @param newLensFlareSystem The lens flare system to add
  56229. */
  56230. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56231. /**
  56232. * Gets a lens flare system using its name
  56233. * @param name defines the name to look for
  56234. * @returns the lens flare system or null if not found
  56235. */
  56236. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56237. /**
  56238. * Gets a lens flare system using its id
  56239. * @param id defines the id to look for
  56240. * @returns the lens flare system or null if not found
  56241. */
  56242. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56243. }
  56244. }
  56245. /**
  56246. * Defines the lens flare scene component responsible to manage any lens flares
  56247. * in a given scene.
  56248. */
  56249. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56250. /**
  56251. * The component name helpfull to identify the component in the list of scene components.
  56252. */
  56253. readonly name: string;
  56254. /**
  56255. * The scene the component belongs to.
  56256. */
  56257. scene: Scene;
  56258. /**
  56259. * Creates a new instance of the component for the given scene
  56260. * @param scene Defines the scene to register the component in
  56261. */
  56262. constructor(scene: Scene);
  56263. /**
  56264. * Registers the component in a given scene
  56265. */
  56266. register(): void;
  56267. /**
  56268. * Rebuilds the elements related to this component in case of
  56269. * context lost for instance.
  56270. */
  56271. rebuild(): void;
  56272. /**
  56273. * Adds all the elements from the container to the scene
  56274. * @param container the container holding the elements
  56275. */
  56276. addFromContainer(container: AbstractScene): void;
  56277. /**
  56278. * Removes all the elements in the container from the scene
  56279. * @param container contains the elements to remove
  56280. * @param dispose if the removed element should be disposed (default: false)
  56281. */
  56282. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56283. /**
  56284. * Serializes the component data to the specified json object
  56285. * @param serializationObject The object to serialize to
  56286. */
  56287. serialize(serializationObject: any): void;
  56288. /**
  56289. * Disposes the component and the associated ressources.
  56290. */
  56291. dispose(): void;
  56292. private _draw;
  56293. }
  56294. }
  56295. declare module "babylonjs/LensFlares/index" {
  56296. export * from "babylonjs/LensFlares/lensFlare";
  56297. export * from "babylonjs/LensFlares/lensFlareSystem";
  56298. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56299. }
  56300. declare module "babylonjs/Shaders/depth.fragment" {
  56301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56302. /** @hidden */
  56303. export var depthPixelShader: {
  56304. name: string;
  56305. shader: string;
  56306. };
  56307. }
  56308. declare module "babylonjs/Shaders/depth.vertex" {
  56309. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56310. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56311. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56312. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56313. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56314. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56315. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56316. /** @hidden */
  56317. export var depthVertexShader: {
  56318. name: string;
  56319. shader: string;
  56320. };
  56321. }
  56322. declare module "babylonjs/Rendering/depthRenderer" {
  56323. import { Nullable } from "babylonjs/types";
  56324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56325. import { Scene } from "babylonjs/scene";
  56326. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56327. import { Camera } from "babylonjs/Cameras/camera";
  56328. import "babylonjs/Shaders/depth.fragment";
  56329. import "babylonjs/Shaders/depth.vertex";
  56330. /**
  56331. * This represents a depth renderer in Babylon.
  56332. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56333. */
  56334. export class DepthRenderer {
  56335. private _scene;
  56336. private _depthMap;
  56337. private _effect;
  56338. private readonly _storeNonLinearDepth;
  56339. private readonly _clearColor;
  56340. /** Get if the depth renderer is using packed depth or not */
  56341. readonly isPacked: boolean;
  56342. private _cachedDefines;
  56343. private _camera;
  56344. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56345. enabled: boolean;
  56346. /**
  56347. * Specifiess that the depth renderer will only be used within
  56348. * the camera it is created for.
  56349. * This can help forcing its rendering during the camera processing.
  56350. */
  56351. useOnlyInActiveCamera: boolean;
  56352. /** @hidden */
  56353. static _SceneComponentInitialization: (scene: Scene) => void;
  56354. /**
  56355. * Instantiates a depth renderer
  56356. * @param scene The scene the renderer belongs to
  56357. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56358. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56359. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56360. */
  56361. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56362. /**
  56363. * Creates the depth rendering effect and checks if the effect is ready.
  56364. * @param subMesh The submesh to be used to render the depth map of
  56365. * @param useInstances If multiple world instances should be used
  56366. * @returns if the depth renderer is ready to render the depth map
  56367. */
  56368. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56369. /**
  56370. * Gets the texture which the depth map will be written to.
  56371. * @returns The depth map texture
  56372. */
  56373. getDepthMap(): RenderTargetTexture;
  56374. /**
  56375. * Disposes of the depth renderer.
  56376. */
  56377. dispose(): void;
  56378. }
  56379. }
  56380. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56381. /** @hidden */
  56382. export var minmaxReduxPixelShader: {
  56383. name: string;
  56384. shader: string;
  56385. };
  56386. }
  56387. declare module "babylonjs/Misc/minMaxReducer" {
  56388. import { Nullable } from "babylonjs/types";
  56389. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56390. import { Camera } from "babylonjs/Cameras/camera";
  56391. import { Observer } from "babylonjs/Misc/observable";
  56392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56393. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56394. import { Observable } from "babylonjs/Misc/observable";
  56395. import "babylonjs/Shaders/minmaxRedux.fragment";
  56396. /**
  56397. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56398. * and maximum values from all values of the texture.
  56399. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56400. * The source values are read from the red channel of the texture.
  56401. */
  56402. export class MinMaxReducer {
  56403. /**
  56404. * Observable triggered when the computation has been performed
  56405. */
  56406. onAfterReductionPerformed: Observable<{
  56407. min: number;
  56408. max: number;
  56409. }>;
  56410. protected _camera: Camera;
  56411. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56412. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56413. protected _postProcessManager: PostProcessManager;
  56414. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56415. protected _forceFullscreenViewport: boolean;
  56416. /**
  56417. * Creates a min/max reducer
  56418. * @param camera The camera to use for the post processes
  56419. */
  56420. constructor(camera: Camera);
  56421. /**
  56422. * Gets the texture used to read the values from.
  56423. */
  56424. get sourceTexture(): Nullable<RenderTargetTexture>;
  56425. /**
  56426. * Sets the source texture to read the values from.
  56427. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56428. * because in such textures '1' value must not be taken into account to compute the maximum
  56429. * as this value is used to clear the texture.
  56430. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56431. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56432. * @param depthRedux Indicates if the texture is a depth texture or not
  56433. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56434. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56435. */
  56436. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56437. /**
  56438. * Defines the refresh rate of the computation.
  56439. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56440. */
  56441. get refreshRate(): number;
  56442. set refreshRate(value: number);
  56443. protected _activated: boolean;
  56444. /**
  56445. * Gets the activation status of the reducer
  56446. */
  56447. get activated(): boolean;
  56448. /**
  56449. * Activates the reduction computation.
  56450. * When activated, the observers registered in onAfterReductionPerformed are
  56451. * called after the compuation is performed
  56452. */
  56453. activate(): void;
  56454. /**
  56455. * Deactivates the reduction computation.
  56456. */
  56457. deactivate(): void;
  56458. /**
  56459. * Disposes the min/max reducer
  56460. * @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.
  56461. */
  56462. dispose(disposeAll?: boolean): void;
  56463. }
  56464. }
  56465. declare module "babylonjs/Misc/depthReducer" {
  56466. import { Nullable } from "babylonjs/types";
  56467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56468. import { Camera } from "babylonjs/Cameras/camera";
  56469. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56470. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56471. /**
  56472. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56473. */
  56474. export class DepthReducer extends MinMaxReducer {
  56475. private _depthRenderer;
  56476. private _depthRendererId;
  56477. /**
  56478. * Gets the depth renderer used for the computation.
  56479. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56480. */
  56481. get depthRenderer(): Nullable<DepthRenderer>;
  56482. /**
  56483. * Creates a depth reducer
  56484. * @param camera The camera used to render the depth texture
  56485. */
  56486. constructor(camera: Camera);
  56487. /**
  56488. * Sets the depth renderer to use to generate the depth map
  56489. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56490. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56491. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56492. */
  56493. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56494. /** @hidden */
  56495. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56496. /**
  56497. * Activates the reduction computation.
  56498. * When activated, the observers registered in onAfterReductionPerformed are
  56499. * called after the compuation is performed
  56500. */
  56501. activate(): void;
  56502. /**
  56503. * Deactivates the reduction computation.
  56504. */
  56505. deactivate(): void;
  56506. /**
  56507. * Disposes the depth reducer
  56508. * @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.
  56509. */
  56510. dispose(disposeAll?: boolean): void;
  56511. }
  56512. }
  56513. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56514. import { Nullable } from "babylonjs/types";
  56515. import { Scene } from "babylonjs/scene";
  56516. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56518. import { Effect } from "babylonjs/Materials/effect";
  56519. import "babylonjs/Shaders/shadowMap.fragment";
  56520. import "babylonjs/Shaders/shadowMap.vertex";
  56521. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56522. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56523. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56524. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56525. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56526. /**
  56527. * A CSM implementation allowing casting shadows on large scenes.
  56528. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56529. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56530. */
  56531. export class CascadedShadowGenerator extends ShadowGenerator {
  56532. private static readonly frustumCornersNDCSpace;
  56533. /**
  56534. * Name of the CSM class
  56535. */
  56536. static CLASSNAME: string;
  56537. /**
  56538. * Defines the default number of cascades used by the CSM.
  56539. */
  56540. static readonly DEFAULT_CASCADES_COUNT: number;
  56541. /**
  56542. * Defines the minimum number of cascades used by the CSM.
  56543. */
  56544. static readonly MIN_CASCADES_COUNT: number;
  56545. /**
  56546. * Defines the maximum number of cascades used by the CSM.
  56547. */
  56548. static readonly MAX_CASCADES_COUNT: number;
  56549. protected _validateFilter(filter: number): number;
  56550. /**
  56551. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56552. */
  56553. penumbraDarkness: number;
  56554. private _numCascades;
  56555. /**
  56556. * Gets or set the number of cascades used by the CSM.
  56557. */
  56558. get numCascades(): number;
  56559. set numCascades(value: number);
  56560. /**
  56561. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56562. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56563. */
  56564. stabilizeCascades: boolean;
  56565. private _freezeShadowCastersBoundingInfo;
  56566. private _freezeShadowCastersBoundingInfoObservable;
  56567. /**
  56568. * Enables or disables the shadow casters bounding info computation.
  56569. * If your shadow casters don't move, you can disable this feature.
  56570. * If it is enabled, the bounding box computation is done every frame.
  56571. */
  56572. get freezeShadowCastersBoundingInfo(): boolean;
  56573. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56574. private _scbiMin;
  56575. private _scbiMax;
  56576. protected _computeShadowCastersBoundingInfo(): void;
  56577. protected _shadowCastersBoundingInfo: BoundingInfo;
  56578. /**
  56579. * Gets or sets the shadow casters bounding info.
  56580. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56581. * so that the system won't overwrite the bounds you provide
  56582. */
  56583. get shadowCastersBoundingInfo(): BoundingInfo;
  56584. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56585. protected _breaksAreDirty: boolean;
  56586. protected _minDistance: number;
  56587. protected _maxDistance: number;
  56588. /**
  56589. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56590. *
  56591. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56592. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56593. * @param min minimal distance for the breaks (default to 0.)
  56594. * @param max maximal distance for the breaks (default to 1.)
  56595. */
  56596. setMinMaxDistance(min: number, max: number): void;
  56597. /** Gets the minimal distance used in the cascade break computation */
  56598. get minDistance(): number;
  56599. /** Gets the maximal distance used in the cascade break computation */
  56600. get maxDistance(): number;
  56601. /**
  56602. * Gets the class name of that object
  56603. * @returns "CascadedShadowGenerator"
  56604. */
  56605. getClassName(): string;
  56606. private _cascadeMinExtents;
  56607. private _cascadeMaxExtents;
  56608. /**
  56609. * Gets a cascade minimum extents
  56610. * @param cascadeIndex index of the cascade
  56611. * @returns the minimum cascade extents
  56612. */
  56613. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56614. /**
  56615. * Gets a cascade maximum extents
  56616. * @param cascadeIndex index of the cascade
  56617. * @returns the maximum cascade extents
  56618. */
  56619. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56620. private _cascades;
  56621. private _currentLayer;
  56622. private _viewSpaceFrustumsZ;
  56623. private _viewMatrices;
  56624. private _projectionMatrices;
  56625. private _transformMatrices;
  56626. private _transformMatricesAsArray;
  56627. private _frustumLengths;
  56628. private _lightSizeUVCorrection;
  56629. private _depthCorrection;
  56630. private _frustumCornersWorldSpace;
  56631. private _frustumCenter;
  56632. private _shadowCameraPos;
  56633. private _shadowMaxZ;
  56634. /**
  56635. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56636. * It defaults to camera.maxZ
  56637. */
  56638. get shadowMaxZ(): number;
  56639. /**
  56640. * Sets the shadow max z distance.
  56641. */
  56642. set shadowMaxZ(value: number);
  56643. protected _debug: boolean;
  56644. /**
  56645. * Gets or sets the debug flag.
  56646. * When enabled, the cascades are materialized by different colors on the screen.
  56647. */
  56648. get debug(): boolean;
  56649. set debug(dbg: boolean);
  56650. private _depthClamp;
  56651. /**
  56652. * Gets or sets the depth clamping value.
  56653. *
  56654. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56655. * to account for the shadow casters far away.
  56656. *
  56657. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56658. */
  56659. get depthClamp(): boolean;
  56660. set depthClamp(value: boolean);
  56661. private _cascadeBlendPercentage;
  56662. /**
  56663. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56664. * It defaults to 0.1 (10% blending).
  56665. */
  56666. get cascadeBlendPercentage(): number;
  56667. set cascadeBlendPercentage(value: number);
  56668. private _lambda;
  56669. /**
  56670. * Gets or set the lambda parameter.
  56671. * This parameter is used to split the camera frustum and create the cascades.
  56672. * 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.
  56673. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56674. */
  56675. get lambda(): number;
  56676. set lambda(value: number);
  56677. /**
  56678. * Gets the view matrix corresponding to a given cascade
  56679. * @param cascadeNum cascade to retrieve the view matrix from
  56680. * @returns the cascade view matrix
  56681. */
  56682. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56683. /**
  56684. * Gets the projection matrix corresponding to a given cascade
  56685. * @param cascadeNum cascade to retrieve the projection matrix from
  56686. * @returns the cascade projection matrix
  56687. */
  56688. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56689. /**
  56690. * Gets the transformation matrix corresponding to a given cascade
  56691. * @param cascadeNum cascade to retrieve the transformation matrix from
  56692. * @returns the cascade transformation matrix
  56693. */
  56694. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56695. private _depthRenderer;
  56696. /**
  56697. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56698. *
  56699. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56700. *
  56701. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56702. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56703. * @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
  56704. */
  56705. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56706. private _depthReducer;
  56707. private _autoCalcDepthBounds;
  56708. /**
  56709. * Gets or sets the autoCalcDepthBounds property.
  56710. *
  56711. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56712. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56713. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56714. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56715. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56716. */
  56717. get autoCalcDepthBounds(): boolean;
  56718. set autoCalcDepthBounds(value: boolean);
  56719. /**
  56720. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56721. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56722. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56723. * for setting the refresh rate on the renderer yourself!
  56724. */
  56725. get autoCalcDepthBoundsRefreshRate(): number;
  56726. set autoCalcDepthBoundsRefreshRate(value: number);
  56727. /**
  56728. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56729. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56730. * you change the camera near/far planes!
  56731. */
  56732. splitFrustum(): void;
  56733. private _splitFrustum;
  56734. private _computeMatrices;
  56735. private _computeFrustumInWorldSpace;
  56736. private _computeCascadeFrustum;
  56737. /** @hidden */
  56738. static _SceneComponentInitialization: (scene: Scene) => void;
  56739. /**
  56740. * Creates a Cascaded Shadow Generator object.
  56741. * A ShadowGenerator is the required tool to use the shadows.
  56742. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56743. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56744. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56745. * @param light The directional light object generating the shadows.
  56746. * @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.
  56747. */
  56748. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56749. protected _initializeGenerator(): void;
  56750. protected _createTargetRenderTexture(): void;
  56751. protected _initializeShadowMap(): void;
  56752. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56753. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56754. /**
  56755. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56756. * @param defines Defines of the material we want to update
  56757. * @param lightIndex Index of the light in the enabled light list of the material
  56758. */
  56759. prepareDefines(defines: any, lightIndex: number): void;
  56760. /**
  56761. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56762. * defined in the generator but impacting the effect).
  56763. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56764. * @param effect The effect we are binfing the information for
  56765. */
  56766. bindShadowLight(lightIndex: string, effect: Effect): void;
  56767. /**
  56768. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56769. * (eq to view projection * shadow projection matrices)
  56770. * @returns The transform matrix used to create the shadow map
  56771. */
  56772. getTransformMatrix(): Matrix;
  56773. /**
  56774. * Disposes the ShadowGenerator.
  56775. * Returns nothing.
  56776. */
  56777. dispose(): void;
  56778. /**
  56779. * Serializes the shadow generator setup to a json object.
  56780. * @returns The serialized JSON object
  56781. */
  56782. serialize(): any;
  56783. /**
  56784. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56785. * @param parsedShadowGenerator The JSON object to parse
  56786. * @param scene The scene to create the shadow map for
  56787. * @returns The parsed shadow generator
  56788. */
  56789. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56790. }
  56791. }
  56792. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56793. import { Scene } from "babylonjs/scene";
  56794. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56795. import { AbstractScene } from "babylonjs/abstractScene";
  56796. /**
  56797. * Defines the shadow generator component responsible to manage any shadow generators
  56798. * in a given scene.
  56799. */
  56800. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56801. /**
  56802. * The component name helpfull to identify the component in the list of scene components.
  56803. */
  56804. readonly name: string;
  56805. /**
  56806. * The scene the component belongs to.
  56807. */
  56808. scene: Scene;
  56809. /**
  56810. * Creates a new instance of the component for the given scene
  56811. * @param scene Defines the scene to register the component in
  56812. */
  56813. constructor(scene: Scene);
  56814. /**
  56815. * Registers the component in a given scene
  56816. */
  56817. register(): void;
  56818. /**
  56819. * Rebuilds the elements related to this component in case of
  56820. * context lost for instance.
  56821. */
  56822. rebuild(): void;
  56823. /**
  56824. * Serializes the component data to the specified json object
  56825. * @param serializationObject The object to serialize to
  56826. */
  56827. serialize(serializationObject: any): void;
  56828. /**
  56829. * Adds all the elements from the container to the scene
  56830. * @param container the container holding the elements
  56831. */
  56832. addFromContainer(container: AbstractScene): void;
  56833. /**
  56834. * Removes all the elements in the container from the scene
  56835. * @param container contains the elements to remove
  56836. * @param dispose if the removed element should be disposed (default: false)
  56837. */
  56838. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56839. /**
  56840. * Rebuilds the elements related to this component in case of
  56841. * context lost for instance.
  56842. */
  56843. dispose(): void;
  56844. private _gatherRenderTargets;
  56845. }
  56846. }
  56847. declare module "babylonjs/Lights/Shadows/index" {
  56848. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56849. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56850. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56851. }
  56852. declare module "babylonjs/Lights/pointLight" {
  56853. import { Scene } from "babylonjs/scene";
  56854. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56856. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56857. import { Effect } from "babylonjs/Materials/effect";
  56858. /**
  56859. * A point light is a light defined by an unique point in world space.
  56860. * The light is emitted in every direction from this point.
  56861. * A good example of a point light is a standard light bulb.
  56862. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56863. */
  56864. export class PointLight extends ShadowLight {
  56865. private _shadowAngle;
  56866. /**
  56867. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56868. * This specifies what angle the shadow will use to be created.
  56869. *
  56870. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56871. */
  56872. get shadowAngle(): number;
  56873. /**
  56874. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56875. * This specifies what angle the shadow will use to be created.
  56876. *
  56877. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56878. */
  56879. set shadowAngle(value: number);
  56880. /**
  56881. * Gets the direction if it has been set.
  56882. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56883. */
  56884. get direction(): Vector3;
  56885. /**
  56886. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56887. */
  56888. set direction(value: Vector3);
  56889. /**
  56890. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56891. * A PointLight emits the light in every direction.
  56892. * It can cast shadows.
  56893. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56894. * ```javascript
  56895. * var pointLight = new PointLight("pl", camera.position, scene);
  56896. * ```
  56897. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56898. * @param name The light friendly name
  56899. * @param position The position of the point light in the scene
  56900. * @param scene The scene the lights belongs to
  56901. */
  56902. constructor(name: string, position: Vector3, scene: Scene);
  56903. /**
  56904. * Returns the string "PointLight"
  56905. * @returns the class name
  56906. */
  56907. getClassName(): string;
  56908. /**
  56909. * Returns the integer 0.
  56910. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56911. */
  56912. getTypeID(): number;
  56913. /**
  56914. * Specifies wether or not the shadowmap should be a cube texture.
  56915. * @returns true if the shadowmap needs to be a cube texture.
  56916. */
  56917. needCube(): boolean;
  56918. /**
  56919. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56922. */
  56923. getShadowDirection(faceIndex?: number): Vector3;
  56924. /**
  56925. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56926. * - fov = PI / 2
  56927. * - aspect ratio : 1.0
  56928. * - z-near and far equal to the active camera minZ and maxZ.
  56929. * Returns the PointLight.
  56930. */
  56931. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56932. protected _buildUniformLayout(): void;
  56933. /**
  56934. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56935. * @param effect The effect to update
  56936. * @param lightIndex The index of the light in the effect to update
  56937. * @returns The point light
  56938. */
  56939. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56940. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56941. /**
  56942. * Prepares the list of defines specific to the light type.
  56943. * @param defines the list of defines
  56944. * @param lightIndex defines the index of the light for the effect
  56945. */
  56946. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56947. }
  56948. }
  56949. declare module "babylonjs/Lights/index" {
  56950. export * from "babylonjs/Lights/light";
  56951. export * from "babylonjs/Lights/shadowLight";
  56952. export * from "babylonjs/Lights/Shadows/index";
  56953. export * from "babylonjs/Lights/directionalLight";
  56954. export * from "babylonjs/Lights/hemisphericLight";
  56955. export * from "babylonjs/Lights/pointLight";
  56956. export * from "babylonjs/Lights/spotLight";
  56957. }
  56958. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56959. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56960. /**
  56961. * Header information of HDR texture files.
  56962. */
  56963. export interface HDRInfo {
  56964. /**
  56965. * The height of the texture in pixels.
  56966. */
  56967. height: number;
  56968. /**
  56969. * The width of the texture in pixels.
  56970. */
  56971. width: number;
  56972. /**
  56973. * The index of the beginning of the data in the binary file.
  56974. */
  56975. dataPosition: number;
  56976. }
  56977. /**
  56978. * This groups tools to convert HDR texture to native colors array.
  56979. */
  56980. export class HDRTools {
  56981. private static Ldexp;
  56982. private static Rgbe2float;
  56983. private static readStringLine;
  56984. /**
  56985. * Reads header information from an RGBE texture stored in a native array.
  56986. * More information on this format are available here:
  56987. * https://en.wikipedia.org/wiki/RGBE_image_format
  56988. *
  56989. * @param uint8array The binary file stored in native array.
  56990. * @return The header information.
  56991. */
  56992. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56993. /**
  56994. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56995. * This RGBE texture needs to store the information as a panorama.
  56996. *
  56997. * More information on this format are available here:
  56998. * https://en.wikipedia.org/wiki/RGBE_image_format
  56999. *
  57000. * @param buffer The binary file stored in an array buffer.
  57001. * @param size The expected size of the extracted cubemap.
  57002. * @return The Cube Map information.
  57003. */
  57004. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57005. /**
  57006. * Returns the pixels data extracted from an RGBE texture.
  57007. * This pixels will be stored left to right up to down in the R G B order in one array.
  57008. *
  57009. * More information on this format are available here:
  57010. * https://en.wikipedia.org/wiki/RGBE_image_format
  57011. *
  57012. * @param uint8array The binary file stored in an array buffer.
  57013. * @param hdrInfo The header information of the file.
  57014. * @return The pixels data in RGB right to left up to down order.
  57015. */
  57016. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57017. private static RGBE_ReadPixels_RLE;
  57018. }
  57019. }
  57020. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57021. import { Nullable } from "babylonjs/types";
  57022. import { Scene } from "babylonjs/scene";
  57023. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57025. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57026. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57027. /**
  57028. * This represents a texture coming from an HDR input.
  57029. *
  57030. * The only supported format is currently panorama picture stored in RGBE format.
  57031. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57032. */
  57033. export class HDRCubeTexture extends BaseTexture {
  57034. private static _facesMapping;
  57035. private _generateHarmonics;
  57036. private _noMipmap;
  57037. private _textureMatrix;
  57038. private _size;
  57039. private _onLoad;
  57040. private _onError;
  57041. /**
  57042. * The texture URL.
  57043. */
  57044. url: string;
  57045. /**
  57046. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57047. */
  57048. coordinatesMode: number;
  57049. protected _isBlocking: boolean;
  57050. /**
  57051. * Sets wether or not the texture is blocking during loading.
  57052. */
  57053. set isBlocking(value: boolean);
  57054. /**
  57055. * Gets wether or not the texture is blocking during loading.
  57056. */
  57057. get isBlocking(): boolean;
  57058. protected _rotationY: number;
  57059. /**
  57060. * Sets texture matrix rotation angle around Y axis in radians.
  57061. */
  57062. set rotationY(value: number);
  57063. /**
  57064. * Gets texture matrix rotation angle around Y axis radians.
  57065. */
  57066. get rotationY(): number;
  57067. /**
  57068. * Gets or sets the center of the bounding box associated with the cube texture
  57069. * It must define where the camera used to render the texture was set
  57070. */
  57071. boundingBoxPosition: Vector3;
  57072. private _boundingBoxSize;
  57073. /**
  57074. * Gets or sets the size of the bounding box associated with the cube texture
  57075. * When defined, the cubemap will switch to local mode
  57076. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57077. * @example https://www.babylonjs-playground.com/#RNASML
  57078. */
  57079. set boundingBoxSize(value: Vector3);
  57080. get boundingBoxSize(): Vector3;
  57081. /**
  57082. * Instantiates an HDRTexture from the following parameters.
  57083. *
  57084. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57085. * @param scene The scene the texture will be used in
  57086. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57087. * @param noMipmap Forces to not generate the mipmap if true
  57088. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57089. * @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)
  57090. * @param reserved Reserved flag for internal use.
  57091. */
  57092. 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>);
  57093. /**
  57094. * Get the current class name of the texture useful for serialization or dynamic coding.
  57095. * @returns "HDRCubeTexture"
  57096. */
  57097. getClassName(): string;
  57098. /**
  57099. * Occurs when the file is raw .hdr file.
  57100. */
  57101. private loadTexture;
  57102. clone(): HDRCubeTexture;
  57103. delayLoad(): void;
  57104. /**
  57105. * Get the texture reflection matrix used to rotate/transform the reflection.
  57106. * @returns the reflection matrix
  57107. */
  57108. getReflectionTextureMatrix(): Matrix;
  57109. /**
  57110. * Set the texture reflection matrix used to rotate/transform the reflection.
  57111. * @param value Define the reflection matrix to set
  57112. */
  57113. setReflectionTextureMatrix(value: Matrix): void;
  57114. /**
  57115. * Parses a JSON representation of an HDR Texture in order to create the texture
  57116. * @param parsedTexture Define the JSON representation
  57117. * @param scene Define the scene the texture should be created in
  57118. * @param rootUrl Define the root url in case we need to load relative dependencies
  57119. * @returns the newly created texture after parsing
  57120. */
  57121. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57122. serialize(): any;
  57123. }
  57124. }
  57125. declare module "babylonjs/Physics/physicsEngine" {
  57126. import { Nullable } from "babylonjs/types";
  57127. import { Vector3 } from "babylonjs/Maths/math.vector";
  57128. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57129. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57130. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57131. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57132. /**
  57133. * Class used to control physics engine
  57134. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57135. */
  57136. export class PhysicsEngine implements IPhysicsEngine {
  57137. private _physicsPlugin;
  57138. /**
  57139. * Global value used to control the smallest number supported by the simulation
  57140. */
  57141. static Epsilon: number;
  57142. private _impostors;
  57143. private _joints;
  57144. private _subTimeStep;
  57145. /**
  57146. * Gets the gravity vector used by the simulation
  57147. */
  57148. gravity: Vector3;
  57149. /**
  57150. * Factory used to create the default physics plugin.
  57151. * @returns The default physics plugin
  57152. */
  57153. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57154. /**
  57155. * Creates a new Physics Engine
  57156. * @param gravity defines the gravity vector used by the simulation
  57157. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57158. */
  57159. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57160. /**
  57161. * Sets the gravity vector used by the simulation
  57162. * @param gravity defines the gravity vector to use
  57163. */
  57164. setGravity(gravity: Vector3): void;
  57165. /**
  57166. * Set the time step of the physics engine.
  57167. * Default is 1/60.
  57168. * To slow it down, enter 1/600 for example.
  57169. * To speed it up, 1/30
  57170. * @param newTimeStep defines the new timestep to apply to this world.
  57171. */
  57172. setTimeStep(newTimeStep?: number): void;
  57173. /**
  57174. * Get the time step of the physics engine.
  57175. * @returns the current time step
  57176. */
  57177. getTimeStep(): number;
  57178. /**
  57179. * Set the sub time step of the physics engine.
  57180. * Default is 0 meaning there is no sub steps
  57181. * To increase physics resolution precision, set a small value (like 1 ms)
  57182. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57183. */
  57184. setSubTimeStep(subTimeStep?: number): void;
  57185. /**
  57186. * Get the sub time step of the physics engine.
  57187. * @returns the current sub time step
  57188. */
  57189. getSubTimeStep(): number;
  57190. /**
  57191. * Release all resources
  57192. */
  57193. dispose(): void;
  57194. /**
  57195. * Gets the name of the current physics plugin
  57196. * @returns the name of the plugin
  57197. */
  57198. getPhysicsPluginName(): string;
  57199. /**
  57200. * Adding a new impostor for the impostor tracking.
  57201. * This will be done by the impostor itself.
  57202. * @param impostor the impostor to add
  57203. */
  57204. addImpostor(impostor: PhysicsImpostor): void;
  57205. /**
  57206. * Remove an impostor from the engine.
  57207. * This impostor and its mesh will not longer be updated by the physics engine.
  57208. * @param impostor the impostor to remove
  57209. */
  57210. removeImpostor(impostor: PhysicsImpostor): void;
  57211. /**
  57212. * Add a joint to the physics engine
  57213. * @param mainImpostor defines the main impostor to which the joint is added.
  57214. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57215. * @param joint defines the joint that will connect both impostors.
  57216. */
  57217. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57218. /**
  57219. * Removes a joint from the simulation
  57220. * @param mainImpostor defines the impostor used with the joint
  57221. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57222. * @param joint defines the joint to remove
  57223. */
  57224. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57225. /**
  57226. * Called by the scene. No need to call it.
  57227. * @param delta defines the timespam between frames
  57228. */
  57229. _step(delta: number): void;
  57230. /**
  57231. * Gets the current plugin used to run the simulation
  57232. * @returns current plugin
  57233. */
  57234. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57235. /**
  57236. * Gets the list of physic impostors
  57237. * @returns an array of PhysicsImpostor
  57238. */
  57239. getImpostors(): Array<PhysicsImpostor>;
  57240. /**
  57241. * Gets the impostor for a physics enabled object
  57242. * @param object defines the object impersonated by the impostor
  57243. * @returns the PhysicsImpostor or null if not found
  57244. */
  57245. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57246. /**
  57247. * Gets the impostor for a physics body object
  57248. * @param body defines physics body used by the impostor
  57249. * @returns the PhysicsImpostor or null if not found
  57250. */
  57251. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57252. /**
  57253. * Does a raycast in the physics world
  57254. * @param from when should the ray start?
  57255. * @param to when should the ray end?
  57256. * @returns PhysicsRaycastResult
  57257. */
  57258. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57259. }
  57260. }
  57261. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57262. import { Nullable } from "babylonjs/types";
  57263. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57265. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57266. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57267. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57268. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57269. /** @hidden */
  57270. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57271. private _useDeltaForWorldStep;
  57272. world: any;
  57273. name: string;
  57274. private _physicsMaterials;
  57275. private _fixedTimeStep;
  57276. private _cannonRaycastResult;
  57277. private _raycastResult;
  57278. private _physicsBodysToRemoveAfterStep;
  57279. BJSCANNON: any;
  57280. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57281. setGravity(gravity: Vector3): void;
  57282. setTimeStep(timeStep: number): void;
  57283. getTimeStep(): number;
  57284. executeStep(delta: number): void;
  57285. private _removeMarkedPhysicsBodiesFromWorld;
  57286. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57287. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57289. private _processChildMeshes;
  57290. removePhysicsBody(impostor: PhysicsImpostor): void;
  57291. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57292. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57293. private _addMaterial;
  57294. private _checkWithEpsilon;
  57295. private _createShape;
  57296. private _createHeightmap;
  57297. private _minus90X;
  57298. private _plus90X;
  57299. private _tmpPosition;
  57300. private _tmpDeltaPosition;
  57301. private _tmpUnityRotation;
  57302. private _updatePhysicsBodyTransformation;
  57303. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57304. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57305. isSupported(): boolean;
  57306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57308. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57309. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57310. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57311. getBodyMass(impostor: PhysicsImpostor): number;
  57312. getBodyFriction(impostor: PhysicsImpostor): number;
  57313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57314. getBodyRestitution(impostor: PhysicsImpostor): number;
  57315. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57316. sleepBody(impostor: PhysicsImpostor): void;
  57317. wakeUpBody(impostor: PhysicsImpostor): void;
  57318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57319. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57321. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57322. getRadius(impostor: PhysicsImpostor): number;
  57323. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57324. dispose(): void;
  57325. private _extendNamespace;
  57326. /**
  57327. * Does a raycast in the physics world
  57328. * @param from when should the ray start?
  57329. * @param to when should the ray end?
  57330. * @returns PhysicsRaycastResult
  57331. */
  57332. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57333. }
  57334. }
  57335. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57336. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57337. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57338. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57340. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57341. import { Nullable } from "babylonjs/types";
  57342. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57343. /** @hidden */
  57344. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57345. world: any;
  57346. name: string;
  57347. BJSOIMO: any;
  57348. private _raycastResult;
  57349. constructor(iterations?: number, oimoInjection?: any);
  57350. setGravity(gravity: Vector3): void;
  57351. setTimeStep(timeStep: number): void;
  57352. getTimeStep(): number;
  57353. private _tmpImpostorsArray;
  57354. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57355. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57356. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57357. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57358. private _tmpPositionVector;
  57359. removePhysicsBody(impostor: PhysicsImpostor): void;
  57360. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57361. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57362. isSupported(): boolean;
  57363. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57364. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57365. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57366. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57367. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57368. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57369. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57370. getBodyMass(impostor: PhysicsImpostor): number;
  57371. getBodyFriction(impostor: PhysicsImpostor): number;
  57372. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57373. getBodyRestitution(impostor: PhysicsImpostor): number;
  57374. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57375. sleepBody(impostor: PhysicsImpostor): void;
  57376. wakeUpBody(impostor: PhysicsImpostor): void;
  57377. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57378. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57381. getRadius(impostor: PhysicsImpostor): number;
  57382. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57383. dispose(): void;
  57384. /**
  57385. * Does a raycast in the physics world
  57386. * @param from when should the ray start?
  57387. * @param to when should the ray end?
  57388. * @returns PhysicsRaycastResult
  57389. */
  57390. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57391. }
  57392. }
  57393. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57394. import { Nullable } from "babylonjs/types";
  57395. import { Scene } from "babylonjs/scene";
  57396. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57397. import { Color4 } from "babylonjs/Maths/math.color";
  57398. import { Mesh } from "babylonjs/Meshes/mesh";
  57399. /**
  57400. * Class containing static functions to help procedurally build meshes
  57401. */
  57402. export class RibbonBuilder {
  57403. /**
  57404. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57405. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57406. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57407. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57408. * * 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
  57409. * * 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
  57410. * * 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
  57411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57414. * * 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
  57415. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57416. * * 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
  57417. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57419. * @param name defines the name of the mesh
  57420. * @param options defines the options used to create the mesh
  57421. * @param scene defines the hosting scene
  57422. * @returns the ribbon mesh
  57423. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57425. */
  57426. static CreateRibbon(name: string, options: {
  57427. pathArray: Vector3[][];
  57428. closeArray?: boolean;
  57429. closePath?: boolean;
  57430. offset?: number;
  57431. updatable?: boolean;
  57432. sideOrientation?: number;
  57433. frontUVs?: Vector4;
  57434. backUVs?: Vector4;
  57435. instance?: Mesh;
  57436. invertUV?: boolean;
  57437. uvs?: Vector2[];
  57438. colors?: Color4[];
  57439. }, scene?: Nullable<Scene>): Mesh;
  57440. }
  57441. }
  57442. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57443. import { Nullable } from "babylonjs/types";
  57444. import { Scene } from "babylonjs/scene";
  57445. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57446. import { Mesh } from "babylonjs/Meshes/mesh";
  57447. /**
  57448. * Class containing static functions to help procedurally build meshes
  57449. */
  57450. export class ShapeBuilder {
  57451. /**
  57452. * 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.
  57453. * * 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.
  57454. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57455. * * 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.
  57456. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57457. * * 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
  57458. * * 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
  57459. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57464. * @param name defines the name of the mesh
  57465. * @param options defines the options used to create the mesh
  57466. * @param scene defines the hosting scene
  57467. * @returns the extruded shape mesh
  57468. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57470. */
  57471. static ExtrudeShape(name: string, options: {
  57472. shape: Vector3[];
  57473. path: Vector3[];
  57474. scale?: number;
  57475. rotation?: number;
  57476. cap?: number;
  57477. updatable?: boolean;
  57478. sideOrientation?: number;
  57479. frontUVs?: Vector4;
  57480. backUVs?: Vector4;
  57481. instance?: Mesh;
  57482. invertUV?: boolean;
  57483. }, scene?: Nullable<Scene>): Mesh;
  57484. /**
  57485. * Creates an custom extruded shape mesh.
  57486. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57487. * * 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.
  57488. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57489. * * 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
  57490. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57491. * * 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
  57492. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57493. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57494. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57495. * * 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
  57496. * * 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
  57497. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57502. * @param name defines the name of the mesh
  57503. * @param options defines the options used to create the mesh
  57504. * @param scene defines the hosting scene
  57505. * @returns the custom extruded shape mesh
  57506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57509. */
  57510. static ExtrudeShapeCustom(name: string, options: {
  57511. shape: Vector3[];
  57512. path: Vector3[];
  57513. scaleFunction?: any;
  57514. rotationFunction?: any;
  57515. ribbonCloseArray?: boolean;
  57516. ribbonClosePath?: boolean;
  57517. cap?: number;
  57518. updatable?: boolean;
  57519. sideOrientation?: number;
  57520. frontUVs?: Vector4;
  57521. backUVs?: Vector4;
  57522. instance?: Mesh;
  57523. invertUV?: boolean;
  57524. }, scene?: Nullable<Scene>): Mesh;
  57525. private static _ExtrudeShapeGeneric;
  57526. }
  57527. }
  57528. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57529. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57530. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57531. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57532. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57533. import { Nullable } from "babylonjs/types";
  57534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57535. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57536. /**
  57537. * AmmoJS Physics plugin
  57538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57539. * @see https://github.com/kripken/ammo.js/
  57540. */
  57541. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57542. private _useDeltaForWorldStep;
  57543. /**
  57544. * Reference to the Ammo library
  57545. */
  57546. bjsAMMO: any;
  57547. /**
  57548. * Created ammoJS world which physics bodies are added to
  57549. */
  57550. world: any;
  57551. /**
  57552. * Name of the plugin
  57553. */
  57554. name: string;
  57555. private _timeStep;
  57556. private _fixedTimeStep;
  57557. private _maxSteps;
  57558. private _tmpQuaternion;
  57559. private _tmpAmmoTransform;
  57560. private _tmpAmmoQuaternion;
  57561. private _tmpAmmoConcreteContactResultCallback;
  57562. private _collisionConfiguration;
  57563. private _dispatcher;
  57564. private _overlappingPairCache;
  57565. private _solver;
  57566. private _softBodySolver;
  57567. private _tmpAmmoVectorA;
  57568. private _tmpAmmoVectorB;
  57569. private _tmpAmmoVectorC;
  57570. private _tmpAmmoVectorD;
  57571. private _tmpContactCallbackResult;
  57572. private _tmpAmmoVectorRCA;
  57573. private _tmpAmmoVectorRCB;
  57574. private _raycastResult;
  57575. private static readonly DISABLE_COLLISION_FLAG;
  57576. private static readonly KINEMATIC_FLAG;
  57577. private static readonly DISABLE_DEACTIVATION_FLAG;
  57578. /**
  57579. * Initializes the ammoJS plugin
  57580. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57581. * @param ammoInjection can be used to inject your own ammo reference
  57582. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57583. */
  57584. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57585. /**
  57586. * Sets the gravity of the physics world (m/(s^2))
  57587. * @param gravity Gravity to set
  57588. */
  57589. setGravity(gravity: Vector3): void;
  57590. /**
  57591. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57592. * @param timeStep timestep to use in seconds
  57593. */
  57594. setTimeStep(timeStep: number): void;
  57595. /**
  57596. * 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)
  57597. * @param fixedTimeStep fixedTimeStep to use in seconds
  57598. */
  57599. setFixedTimeStep(fixedTimeStep: number): void;
  57600. /**
  57601. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57602. * @param maxSteps the maximum number of steps by the physics engine per frame
  57603. */
  57604. setMaxSteps(maxSteps: number): void;
  57605. /**
  57606. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57607. * @returns the current timestep in seconds
  57608. */
  57609. getTimeStep(): number;
  57610. /**
  57611. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57612. */
  57613. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57614. private _isImpostorInContact;
  57615. private _isImpostorPairInContact;
  57616. private _stepSimulation;
  57617. /**
  57618. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57619. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57620. * After the step the babylon meshes are set to the position of the physics imposters
  57621. * @param delta amount of time to step forward
  57622. * @param impostors array of imposters to update before/after the step
  57623. */
  57624. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57625. /**
  57626. * Update babylon mesh to match physics world object
  57627. * @param impostor imposter to match
  57628. */
  57629. private _afterSoftStep;
  57630. /**
  57631. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57632. * @param impostor imposter to match
  57633. */
  57634. private _ropeStep;
  57635. /**
  57636. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57637. * @param impostor imposter to match
  57638. */
  57639. private _softbodyOrClothStep;
  57640. private _tmpVector;
  57641. private _tmpMatrix;
  57642. /**
  57643. * Applies an impulse on the imposter
  57644. * @param impostor imposter to apply impulse to
  57645. * @param force amount of force to be applied to the imposter
  57646. * @param contactPoint the location to apply the impulse on the imposter
  57647. */
  57648. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57649. /**
  57650. * Applies a force on the imposter
  57651. * @param impostor imposter to apply force
  57652. * @param force amount of force to be applied to the imposter
  57653. * @param contactPoint the location to apply the force on the imposter
  57654. */
  57655. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57656. /**
  57657. * Creates a physics body using the plugin
  57658. * @param impostor the imposter to create the physics body on
  57659. */
  57660. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57661. /**
  57662. * Removes the physics body from the imposter and disposes of the body's memory
  57663. * @param impostor imposter to remove the physics body from
  57664. */
  57665. removePhysicsBody(impostor: PhysicsImpostor): void;
  57666. /**
  57667. * Generates a joint
  57668. * @param impostorJoint the imposter joint to create the joint with
  57669. */
  57670. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57671. /**
  57672. * Removes a joint
  57673. * @param impostorJoint the imposter joint to remove the joint from
  57674. */
  57675. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57676. private _addMeshVerts;
  57677. /**
  57678. * Initialise the soft body vertices to match its object's (mesh) vertices
  57679. * Softbody vertices (nodes) are in world space and to match this
  57680. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57681. * @param impostor to create the softbody for
  57682. */
  57683. private _softVertexData;
  57684. /**
  57685. * Create an impostor's soft body
  57686. * @param impostor to create the softbody for
  57687. */
  57688. private _createSoftbody;
  57689. /**
  57690. * Create cloth for an impostor
  57691. * @param impostor to create the softbody for
  57692. */
  57693. private _createCloth;
  57694. /**
  57695. * Create rope for an impostor
  57696. * @param impostor to create the softbody for
  57697. */
  57698. private _createRope;
  57699. /**
  57700. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57701. * @param impostor to create the custom physics shape for
  57702. */
  57703. private _createCustom;
  57704. private _addHullVerts;
  57705. private _createShape;
  57706. /**
  57707. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57708. * @param impostor imposter containing the physics body and babylon object
  57709. */
  57710. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57711. /**
  57712. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57713. * @param impostor imposter containing the physics body and babylon object
  57714. * @param newPosition new position
  57715. * @param newRotation new rotation
  57716. */
  57717. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57718. /**
  57719. * If this plugin is supported
  57720. * @returns true if its supported
  57721. */
  57722. isSupported(): boolean;
  57723. /**
  57724. * Sets the linear velocity of the physics body
  57725. * @param impostor imposter to set the velocity on
  57726. * @param velocity velocity to set
  57727. */
  57728. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57729. /**
  57730. * Sets the angular velocity of the physics body
  57731. * @param impostor imposter to set the velocity on
  57732. * @param velocity velocity to set
  57733. */
  57734. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57735. /**
  57736. * gets the linear velocity
  57737. * @param impostor imposter to get linear velocity from
  57738. * @returns linear velocity
  57739. */
  57740. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57741. /**
  57742. * gets the angular velocity
  57743. * @param impostor imposter to get angular velocity from
  57744. * @returns angular velocity
  57745. */
  57746. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57747. /**
  57748. * Sets the mass of physics body
  57749. * @param impostor imposter to set the mass on
  57750. * @param mass mass to set
  57751. */
  57752. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57753. /**
  57754. * Gets the mass of the physics body
  57755. * @param impostor imposter to get the mass from
  57756. * @returns mass
  57757. */
  57758. getBodyMass(impostor: PhysicsImpostor): number;
  57759. /**
  57760. * Gets friction of the impostor
  57761. * @param impostor impostor to get friction from
  57762. * @returns friction value
  57763. */
  57764. getBodyFriction(impostor: PhysicsImpostor): number;
  57765. /**
  57766. * Sets friction of the impostor
  57767. * @param impostor impostor to set friction on
  57768. * @param friction friction value
  57769. */
  57770. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57771. /**
  57772. * Gets restitution of the impostor
  57773. * @param impostor impostor to get restitution from
  57774. * @returns restitution value
  57775. */
  57776. getBodyRestitution(impostor: PhysicsImpostor): number;
  57777. /**
  57778. * Sets resitution of the impostor
  57779. * @param impostor impostor to set resitution on
  57780. * @param restitution resitution value
  57781. */
  57782. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57783. /**
  57784. * Gets pressure inside the impostor
  57785. * @param impostor impostor to get pressure from
  57786. * @returns pressure value
  57787. */
  57788. getBodyPressure(impostor: PhysicsImpostor): number;
  57789. /**
  57790. * Sets pressure inside a soft body impostor
  57791. * Cloth and rope must remain 0 pressure
  57792. * @param impostor impostor to set pressure on
  57793. * @param pressure pressure value
  57794. */
  57795. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57796. /**
  57797. * Gets stiffness of the impostor
  57798. * @param impostor impostor to get stiffness from
  57799. * @returns pressure value
  57800. */
  57801. getBodyStiffness(impostor: PhysicsImpostor): number;
  57802. /**
  57803. * Sets stiffness of the impostor
  57804. * @param impostor impostor to set stiffness on
  57805. * @param stiffness stiffness value from 0 to 1
  57806. */
  57807. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57808. /**
  57809. * Gets velocityIterations of the impostor
  57810. * @param impostor impostor to get velocity iterations from
  57811. * @returns velocityIterations value
  57812. */
  57813. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57814. /**
  57815. * Sets velocityIterations of the impostor
  57816. * @param impostor impostor to set velocity iterations on
  57817. * @param velocityIterations velocityIterations value
  57818. */
  57819. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57820. /**
  57821. * Gets positionIterations of the impostor
  57822. * @param impostor impostor to get position iterations from
  57823. * @returns positionIterations value
  57824. */
  57825. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57826. /**
  57827. * Sets positionIterations of the impostor
  57828. * @param impostor impostor to set position on
  57829. * @param positionIterations positionIterations value
  57830. */
  57831. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57832. /**
  57833. * Append an anchor to a cloth object
  57834. * @param impostor is the cloth impostor to add anchor to
  57835. * @param otherImpostor is the rigid impostor to anchor to
  57836. * @param width ratio across width from 0 to 1
  57837. * @param height ratio up height from 0 to 1
  57838. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57839. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57840. */
  57841. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57842. /**
  57843. * Append an hook to a rope object
  57844. * @param impostor is the rope impostor to add hook to
  57845. * @param otherImpostor is the rigid impostor to hook to
  57846. * @param length ratio along the rope from 0 to 1
  57847. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57848. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57849. */
  57850. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57851. /**
  57852. * Sleeps the physics body and stops it from being active
  57853. * @param impostor impostor to sleep
  57854. */
  57855. sleepBody(impostor: PhysicsImpostor): void;
  57856. /**
  57857. * Activates the physics body
  57858. * @param impostor impostor to activate
  57859. */
  57860. wakeUpBody(impostor: PhysicsImpostor): void;
  57861. /**
  57862. * Updates the distance parameters of the joint
  57863. * @param joint joint to update
  57864. * @param maxDistance maximum distance of the joint
  57865. * @param minDistance minimum distance of the joint
  57866. */
  57867. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57868. /**
  57869. * Sets a motor on the joint
  57870. * @param joint joint to set motor on
  57871. * @param speed speed of the motor
  57872. * @param maxForce maximum force of the motor
  57873. * @param motorIndex index of the motor
  57874. */
  57875. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57876. /**
  57877. * Sets the motors limit
  57878. * @param joint joint to set limit on
  57879. * @param upperLimit upper limit
  57880. * @param lowerLimit lower limit
  57881. */
  57882. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57883. /**
  57884. * Syncs the position and rotation of a mesh with the impostor
  57885. * @param mesh mesh to sync
  57886. * @param impostor impostor to update the mesh with
  57887. */
  57888. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57889. /**
  57890. * Gets the radius of the impostor
  57891. * @param impostor impostor to get radius from
  57892. * @returns the radius
  57893. */
  57894. getRadius(impostor: PhysicsImpostor): number;
  57895. /**
  57896. * Gets the box size of the impostor
  57897. * @param impostor impostor to get box size from
  57898. * @param result the resulting box size
  57899. */
  57900. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57901. /**
  57902. * Disposes of the impostor
  57903. */
  57904. dispose(): void;
  57905. /**
  57906. * Does a raycast in the physics world
  57907. * @param from when should the ray start?
  57908. * @param to when should the ray end?
  57909. * @returns PhysicsRaycastResult
  57910. */
  57911. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57912. }
  57913. }
  57914. declare module "babylonjs/Probes/reflectionProbe" {
  57915. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57916. import { Vector3 } from "babylonjs/Maths/math.vector";
  57917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57918. import { Nullable } from "babylonjs/types";
  57919. import { Scene } from "babylonjs/scene";
  57920. module "babylonjs/abstractScene" {
  57921. interface AbstractScene {
  57922. /**
  57923. * The list of reflection probes added to the scene
  57924. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57925. */
  57926. reflectionProbes: Array<ReflectionProbe>;
  57927. /**
  57928. * Removes the given reflection probe from this scene.
  57929. * @param toRemove The reflection probe to remove
  57930. * @returns The index of the removed reflection probe
  57931. */
  57932. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57933. /**
  57934. * Adds the given reflection probe to this scene.
  57935. * @param newReflectionProbe The reflection probe to add
  57936. */
  57937. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57938. }
  57939. }
  57940. /**
  57941. * Class used to generate realtime reflection / refraction cube textures
  57942. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57943. */
  57944. export class ReflectionProbe {
  57945. /** defines the name of the probe */
  57946. name: string;
  57947. private _scene;
  57948. private _renderTargetTexture;
  57949. private _projectionMatrix;
  57950. private _viewMatrix;
  57951. private _target;
  57952. private _add;
  57953. private _attachedMesh;
  57954. private _invertYAxis;
  57955. /** Gets or sets probe position (center of the cube map) */
  57956. position: Vector3;
  57957. /**
  57958. * Creates a new reflection probe
  57959. * @param name defines the name of the probe
  57960. * @param size defines the texture resolution (for each face)
  57961. * @param scene defines the hosting scene
  57962. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57963. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57964. */
  57965. constructor(
  57966. /** defines the name of the probe */
  57967. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57968. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57969. get samples(): number;
  57970. set samples(value: number);
  57971. /** Gets or sets the refresh rate to use (on every frame by default) */
  57972. get refreshRate(): number;
  57973. set refreshRate(value: number);
  57974. /**
  57975. * Gets the hosting scene
  57976. * @returns a Scene
  57977. */
  57978. getScene(): Scene;
  57979. /** Gets the internal CubeTexture used to render to */
  57980. get cubeTexture(): RenderTargetTexture;
  57981. /** Gets the list of meshes to render */
  57982. get renderList(): Nullable<AbstractMesh[]>;
  57983. /**
  57984. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57985. * @param mesh defines the mesh to attach to
  57986. */
  57987. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57988. /**
  57989. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57990. * @param renderingGroupId The rendering group id corresponding to its index
  57991. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57992. */
  57993. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57994. /**
  57995. * Clean all associated resources
  57996. */
  57997. dispose(): void;
  57998. /**
  57999. * Converts the reflection probe information to a readable string for debug purpose.
  58000. * @param fullDetails Supports for multiple levels of logging within scene loading
  58001. * @returns the human readable reflection probe info
  58002. */
  58003. toString(fullDetails?: boolean): string;
  58004. /**
  58005. * Get the class name of the relfection probe.
  58006. * @returns "ReflectionProbe"
  58007. */
  58008. getClassName(): string;
  58009. /**
  58010. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58011. * @returns The JSON representation of the texture
  58012. */
  58013. serialize(): any;
  58014. /**
  58015. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58016. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58017. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58018. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58019. * @returns The parsed reflection probe if successful
  58020. */
  58021. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58022. }
  58023. }
  58024. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58025. /** @hidden */
  58026. export var _BabylonLoaderRegistered: boolean;
  58027. /**
  58028. * Helps setting up some configuration for the babylon file loader.
  58029. */
  58030. export class BabylonFileLoaderConfiguration {
  58031. /**
  58032. * The loader does not allow injecting custom physix engine into the plugins.
  58033. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58034. * So you could set this variable to your engine import to make it work.
  58035. */
  58036. static LoaderInjectedPhysicsEngine: any;
  58037. }
  58038. }
  58039. declare module "babylonjs/Loading/Plugins/index" {
  58040. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58041. }
  58042. declare module "babylonjs/Loading/index" {
  58043. export * from "babylonjs/Loading/loadingScreen";
  58044. export * from "babylonjs/Loading/Plugins/index";
  58045. export * from "babylonjs/Loading/sceneLoader";
  58046. export * from "babylonjs/Loading/sceneLoaderFlags";
  58047. }
  58048. declare module "babylonjs/Materials/Background/index" {
  58049. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58050. }
  58051. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58052. import { Scene } from "babylonjs/scene";
  58053. import { Color3 } from "babylonjs/Maths/math.color";
  58054. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58056. /**
  58057. * The Physically based simple base material of BJS.
  58058. *
  58059. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58060. * It is used as the base class for both the specGloss and metalRough conventions.
  58061. */
  58062. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58063. /**
  58064. * Number of Simultaneous lights allowed on the material.
  58065. */
  58066. maxSimultaneousLights: number;
  58067. /**
  58068. * If sets to true, disables all the lights affecting the material.
  58069. */
  58070. disableLighting: boolean;
  58071. /**
  58072. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58073. */
  58074. environmentTexture: BaseTexture;
  58075. /**
  58076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58077. */
  58078. invertNormalMapX: boolean;
  58079. /**
  58080. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58081. */
  58082. invertNormalMapY: boolean;
  58083. /**
  58084. * Normal map used in the model.
  58085. */
  58086. normalTexture: BaseTexture;
  58087. /**
  58088. * Emissivie color used to self-illuminate the model.
  58089. */
  58090. emissiveColor: Color3;
  58091. /**
  58092. * Emissivie texture used to self-illuminate the model.
  58093. */
  58094. emissiveTexture: BaseTexture;
  58095. /**
  58096. * Occlusion Channel Strenght.
  58097. */
  58098. occlusionStrength: number;
  58099. /**
  58100. * Occlusion Texture of the material (adding extra occlusion effects).
  58101. */
  58102. occlusionTexture: BaseTexture;
  58103. /**
  58104. * Defines the alpha limits in alpha test mode.
  58105. */
  58106. alphaCutOff: number;
  58107. /**
  58108. * Gets the current double sided mode.
  58109. */
  58110. get doubleSided(): boolean;
  58111. /**
  58112. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58113. */
  58114. set doubleSided(value: boolean);
  58115. /**
  58116. * Stores the pre-calculated light information of a mesh in a texture.
  58117. */
  58118. lightmapTexture: BaseTexture;
  58119. /**
  58120. * If true, the light map contains occlusion information instead of lighting info.
  58121. */
  58122. useLightmapAsShadowmap: boolean;
  58123. /**
  58124. * Instantiates a new PBRMaterial instance.
  58125. *
  58126. * @param name The material name
  58127. * @param scene The scene the material will be use in.
  58128. */
  58129. constructor(name: string, scene: Scene);
  58130. getClassName(): string;
  58131. }
  58132. }
  58133. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58134. import { Scene } from "babylonjs/scene";
  58135. import { Color3 } from "babylonjs/Maths/math.color";
  58136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58137. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58138. /**
  58139. * The PBR material of BJS following the metal roughness convention.
  58140. *
  58141. * This fits to the PBR convention in the GLTF definition:
  58142. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58143. */
  58144. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58145. /**
  58146. * The base color has two different interpretations depending on the value of metalness.
  58147. * When the material is a metal, the base color is the specific measured reflectance value
  58148. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58149. * of the material.
  58150. */
  58151. baseColor: Color3;
  58152. /**
  58153. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58154. * well as opacity information in the alpha channel.
  58155. */
  58156. baseTexture: BaseTexture;
  58157. /**
  58158. * Specifies the metallic scalar value of the material.
  58159. * Can also be used to scale the metalness values of the metallic texture.
  58160. */
  58161. metallic: number;
  58162. /**
  58163. * Specifies the roughness scalar value of the material.
  58164. * Can also be used to scale the roughness values of the metallic texture.
  58165. */
  58166. roughness: number;
  58167. /**
  58168. * Texture containing both the metallic value in the B channel and the
  58169. * roughness value in the G channel to keep better precision.
  58170. */
  58171. metallicRoughnessTexture: BaseTexture;
  58172. /**
  58173. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58174. *
  58175. * @param name The material name
  58176. * @param scene The scene the material will be use in.
  58177. */
  58178. constructor(name: string, scene: Scene);
  58179. /**
  58180. * Return the currrent class name of the material.
  58181. */
  58182. getClassName(): string;
  58183. /**
  58184. * Makes a duplicate of the current material.
  58185. * @param name - name to use for the new material.
  58186. */
  58187. clone(name: string): PBRMetallicRoughnessMaterial;
  58188. /**
  58189. * Serialize the material to a parsable JSON object.
  58190. */
  58191. serialize(): any;
  58192. /**
  58193. * Parses a JSON object correponding to the serialize function.
  58194. */
  58195. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58196. }
  58197. }
  58198. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58199. import { Scene } from "babylonjs/scene";
  58200. import { Color3 } from "babylonjs/Maths/math.color";
  58201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58202. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58203. /**
  58204. * The PBR material of BJS following the specular glossiness convention.
  58205. *
  58206. * This fits to the PBR convention in the GLTF definition:
  58207. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58208. */
  58209. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58210. /**
  58211. * Specifies the diffuse color of the material.
  58212. */
  58213. diffuseColor: Color3;
  58214. /**
  58215. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58216. * channel.
  58217. */
  58218. diffuseTexture: BaseTexture;
  58219. /**
  58220. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58221. */
  58222. specularColor: Color3;
  58223. /**
  58224. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58225. */
  58226. glossiness: number;
  58227. /**
  58228. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58229. */
  58230. specularGlossinessTexture: BaseTexture;
  58231. /**
  58232. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58233. *
  58234. * @param name The material name
  58235. * @param scene The scene the material will be use in.
  58236. */
  58237. constructor(name: string, scene: Scene);
  58238. /**
  58239. * Return the currrent class name of the material.
  58240. */
  58241. getClassName(): string;
  58242. /**
  58243. * Makes a duplicate of the current material.
  58244. * @param name - name to use for the new material.
  58245. */
  58246. clone(name: string): PBRSpecularGlossinessMaterial;
  58247. /**
  58248. * Serialize the material to a parsable JSON object.
  58249. */
  58250. serialize(): any;
  58251. /**
  58252. * Parses a JSON object correponding to the serialize function.
  58253. */
  58254. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58255. }
  58256. }
  58257. declare module "babylonjs/Materials/PBR/index" {
  58258. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58259. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58260. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58261. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58262. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58263. }
  58264. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58265. import { Nullable } from "babylonjs/types";
  58266. import { Scene } from "babylonjs/scene";
  58267. import { Matrix } from "babylonjs/Maths/math.vector";
  58268. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58269. /**
  58270. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58271. * It can help converting any input color in a desired output one. This can then be used to create effects
  58272. * from sepia, black and white to sixties or futuristic rendering...
  58273. *
  58274. * The only supported format is currently 3dl.
  58275. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58276. */
  58277. export class ColorGradingTexture extends BaseTexture {
  58278. /**
  58279. * The current texture matrix. (will always be identity in color grading texture)
  58280. */
  58281. private _textureMatrix;
  58282. /**
  58283. * The texture URL.
  58284. */
  58285. url: string;
  58286. /**
  58287. * Empty line regex stored for GC.
  58288. */
  58289. private static _noneEmptyLineRegex;
  58290. private _engine;
  58291. /**
  58292. * Instantiates a ColorGradingTexture from the following parameters.
  58293. *
  58294. * @param url The location of the color gradind data (currently only supporting 3dl)
  58295. * @param scene The scene the texture will be used in
  58296. */
  58297. constructor(url: string, scene: Scene);
  58298. /**
  58299. * Returns the texture matrix used in most of the material.
  58300. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58301. */
  58302. getTextureMatrix(): Matrix;
  58303. /**
  58304. * Occurs when the file being loaded is a .3dl LUT file.
  58305. */
  58306. private load3dlTexture;
  58307. /**
  58308. * Starts the loading process of the texture.
  58309. */
  58310. private loadTexture;
  58311. /**
  58312. * Clones the color gradind texture.
  58313. */
  58314. clone(): ColorGradingTexture;
  58315. /**
  58316. * Called during delayed load for textures.
  58317. */
  58318. delayLoad(): void;
  58319. /**
  58320. * Parses a color grading texture serialized by Babylon.
  58321. * @param parsedTexture The texture information being parsedTexture
  58322. * @param scene The scene to load the texture in
  58323. * @param rootUrl The root url of the data assets to load
  58324. * @return A color gradind texture
  58325. */
  58326. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58327. /**
  58328. * Serializes the LUT texture to json format.
  58329. */
  58330. serialize(): any;
  58331. }
  58332. }
  58333. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58334. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58335. import { Scene } from "babylonjs/scene";
  58336. import { Nullable } from "babylonjs/types";
  58337. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58338. /**
  58339. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58340. */
  58341. export class EquiRectangularCubeTexture extends BaseTexture {
  58342. /** The six faces of the cube. */
  58343. private static _FacesMapping;
  58344. private _noMipmap;
  58345. private _onLoad;
  58346. private _onError;
  58347. /** The size of the cubemap. */
  58348. private _size;
  58349. /** The buffer of the image. */
  58350. private _buffer;
  58351. /** The width of the input image. */
  58352. private _width;
  58353. /** The height of the input image. */
  58354. private _height;
  58355. /** The URL to the image. */
  58356. url: string;
  58357. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58358. coordinatesMode: number;
  58359. /**
  58360. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58361. * @param url The location of the image
  58362. * @param scene The scene the texture will be used in
  58363. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58364. * @param noMipmap Forces to not generate the mipmap if true
  58365. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58366. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58367. * @param onLoad — defines a callback called when texture is loaded
  58368. * @param onError — defines a callback called if there is an error
  58369. */
  58370. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58371. /**
  58372. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58373. */
  58374. private loadImage;
  58375. /**
  58376. * Convert the image buffer into a cubemap and create a CubeTexture.
  58377. */
  58378. private loadTexture;
  58379. /**
  58380. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58381. * @param buffer The ArrayBuffer that should be converted.
  58382. * @returns The buffer as Float32Array.
  58383. */
  58384. private getFloat32ArrayFromArrayBuffer;
  58385. /**
  58386. * Get the current class name of the texture useful for serialization or dynamic coding.
  58387. * @returns "EquiRectangularCubeTexture"
  58388. */
  58389. getClassName(): string;
  58390. /**
  58391. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58392. * @returns A clone of the current EquiRectangularCubeTexture.
  58393. */
  58394. clone(): EquiRectangularCubeTexture;
  58395. }
  58396. }
  58397. declare module "babylonjs/Misc/tga" {
  58398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58399. /**
  58400. * Based on jsTGALoader - Javascript loader for TGA file
  58401. * By Vincent Thibault
  58402. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58403. */
  58404. export class TGATools {
  58405. private static _TYPE_INDEXED;
  58406. private static _TYPE_RGB;
  58407. private static _TYPE_GREY;
  58408. private static _TYPE_RLE_INDEXED;
  58409. private static _TYPE_RLE_RGB;
  58410. private static _TYPE_RLE_GREY;
  58411. private static _ORIGIN_MASK;
  58412. private static _ORIGIN_SHIFT;
  58413. private static _ORIGIN_BL;
  58414. private static _ORIGIN_BR;
  58415. private static _ORIGIN_UL;
  58416. private static _ORIGIN_UR;
  58417. /**
  58418. * Gets the header of a TGA file
  58419. * @param data defines the TGA data
  58420. * @returns the header
  58421. */
  58422. static GetTGAHeader(data: Uint8Array): any;
  58423. /**
  58424. * Uploads TGA content to a Babylon Texture
  58425. * @hidden
  58426. */
  58427. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58428. /** @hidden */
  58429. 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;
  58430. /** @hidden */
  58431. 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;
  58432. /** @hidden */
  58433. 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;
  58434. /** @hidden */
  58435. 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;
  58436. /** @hidden */
  58437. 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;
  58438. /** @hidden */
  58439. 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;
  58440. }
  58441. }
  58442. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58443. import { Nullable } from "babylonjs/types";
  58444. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58445. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58446. /**
  58447. * Implementation of the TGA Texture Loader.
  58448. * @hidden
  58449. */
  58450. export class _TGATextureLoader implements IInternalTextureLoader {
  58451. /**
  58452. * Defines wether the loader supports cascade loading the different faces.
  58453. */
  58454. readonly supportCascades: boolean;
  58455. /**
  58456. * This returns if the loader support the current file information.
  58457. * @param extension defines the file extension of the file being loaded
  58458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58459. * @param fallback defines the fallback internal texture if any
  58460. * @param isBase64 defines whether the texture is encoded as a base64
  58461. * @param isBuffer defines whether the texture data are stored as a buffer
  58462. * @returns true if the loader can load the specified file
  58463. */
  58464. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58465. /**
  58466. * Transform the url before loading if required.
  58467. * @param rootUrl the url of the texture
  58468. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58469. * @returns the transformed texture
  58470. */
  58471. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58472. /**
  58473. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58474. * @param rootUrl the url of the texture
  58475. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58476. * @returns the fallback texture
  58477. */
  58478. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58479. /**
  58480. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58481. * @param data contains the texture data
  58482. * @param texture defines the BabylonJS internal texture
  58483. * @param createPolynomials will be true if polynomials have been requested
  58484. * @param onLoad defines the callback to trigger once the texture is ready
  58485. * @param onError defines the callback to trigger in case of error
  58486. */
  58487. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58488. /**
  58489. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58490. * @param data contains the texture data
  58491. * @param texture defines the BabylonJS internal texture
  58492. * @param callback defines the method to call once ready to upload
  58493. */
  58494. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58495. }
  58496. }
  58497. declare module "babylonjs/Misc/basis" {
  58498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58499. /**
  58500. * Info about the .basis files
  58501. */
  58502. class BasisFileInfo {
  58503. /**
  58504. * If the file has alpha
  58505. */
  58506. hasAlpha: boolean;
  58507. /**
  58508. * Info about each image of the basis file
  58509. */
  58510. images: Array<{
  58511. levels: Array<{
  58512. width: number;
  58513. height: number;
  58514. transcodedPixels: ArrayBufferView;
  58515. }>;
  58516. }>;
  58517. }
  58518. /**
  58519. * Result of transcoding a basis file
  58520. */
  58521. class TranscodeResult {
  58522. /**
  58523. * Info about the .basis file
  58524. */
  58525. fileInfo: BasisFileInfo;
  58526. /**
  58527. * Format to use when loading the file
  58528. */
  58529. format: number;
  58530. }
  58531. /**
  58532. * Configuration options for the Basis transcoder
  58533. */
  58534. export class BasisTranscodeConfiguration {
  58535. /**
  58536. * Supported compression formats used to determine the supported output format of the transcoder
  58537. */
  58538. supportedCompressionFormats?: {
  58539. /**
  58540. * etc1 compression format
  58541. */
  58542. etc1?: boolean;
  58543. /**
  58544. * s3tc compression format
  58545. */
  58546. s3tc?: boolean;
  58547. /**
  58548. * pvrtc compression format
  58549. */
  58550. pvrtc?: boolean;
  58551. /**
  58552. * etc2 compression format
  58553. */
  58554. etc2?: boolean;
  58555. };
  58556. /**
  58557. * If mipmap levels should be loaded for transcoded images (Default: true)
  58558. */
  58559. loadMipmapLevels?: boolean;
  58560. /**
  58561. * Index of a single image to load (Default: all images)
  58562. */
  58563. loadSingleImage?: number;
  58564. }
  58565. /**
  58566. * Used to load .Basis files
  58567. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58568. */
  58569. export class BasisTools {
  58570. private static _IgnoreSupportedFormats;
  58571. /**
  58572. * URL to use when loading the basis transcoder
  58573. */
  58574. static JSModuleURL: string;
  58575. /**
  58576. * URL to use when loading the wasm module for the transcoder
  58577. */
  58578. static WasmModuleURL: string;
  58579. /**
  58580. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58581. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58582. * @returns internal format corresponding to the Basis format
  58583. */
  58584. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58585. private static _WorkerPromise;
  58586. private static _Worker;
  58587. private static _actionId;
  58588. private static _CreateWorkerAsync;
  58589. /**
  58590. * Transcodes a loaded image file to compressed pixel data
  58591. * @param data image data to transcode
  58592. * @param config configuration options for the transcoding
  58593. * @returns a promise resulting in the transcoded image
  58594. */
  58595. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58596. /**
  58597. * Loads a texture from the transcode result
  58598. * @param texture texture load to
  58599. * @param transcodeResult the result of transcoding the basis file to load from
  58600. */
  58601. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58602. }
  58603. }
  58604. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58605. import { Nullable } from "babylonjs/types";
  58606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58607. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58608. /**
  58609. * Loader for .basis file format
  58610. */
  58611. export class _BasisTextureLoader implements IInternalTextureLoader {
  58612. /**
  58613. * Defines whether the loader supports cascade loading the different faces.
  58614. */
  58615. readonly supportCascades: boolean;
  58616. /**
  58617. * This returns if the loader support the current file information.
  58618. * @param extension defines the file extension of the file being loaded
  58619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58620. * @param fallback defines the fallback internal texture if any
  58621. * @param isBase64 defines whether the texture is encoded as a base64
  58622. * @param isBuffer defines whether the texture data are stored as a buffer
  58623. * @returns true if the loader can load the specified file
  58624. */
  58625. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58626. /**
  58627. * Transform the url before loading if required.
  58628. * @param rootUrl the url of the texture
  58629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58630. * @returns the transformed texture
  58631. */
  58632. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58633. /**
  58634. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58635. * @param rootUrl the url of the texture
  58636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58637. * @returns the fallback texture
  58638. */
  58639. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58640. /**
  58641. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58642. * @param data contains the texture data
  58643. * @param texture defines the BabylonJS internal texture
  58644. * @param createPolynomials will be true if polynomials have been requested
  58645. * @param onLoad defines the callback to trigger once the texture is ready
  58646. * @param onError defines the callback to trigger in case of error
  58647. */
  58648. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58649. /**
  58650. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58651. * @param data contains the texture data
  58652. * @param texture defines the BabylonJS internal texture
  58653. * @param callback defines the method to call once ready to upload
  58654. */
  58655. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58656. }
  58657. }
  58658. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58659. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58660. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58661. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58662. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58663. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58664. }
  58665. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58666. import { Scene } from "babylonjs/scene";
  58667. import { Texture } from "babylonjs/Materials/Textures/texture";
  58668. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58669. /**
  58670. * 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.
  58671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58672. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58673. */
  58674. export class CustomProceduralTexture extends ProceduralTexture {
  58675. private _animate;
  58676. private _time;
  58677. private _config;
  58678. private _texturePath;
  58679. /**
  58680. * Instantiates a new Custom Procedural Texture.
  58681. * 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.
  58682. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58684. * @param name Define the name of the texture
  58685. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58686. * @param size Define the size of the texture to create
  58687. * @param scene Define the scene the texture belongs to
  58688. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58689. * @param generateMipMaps Define if the texture should creates mip maps or not
  58690. */
  58691. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58692. private _loadJson;
  58693. /**
  58694. * Is the texture ready to be used ? (rendered at least once)
  58695. * @returns true if ready, otherwise, false.
  58696. */
  58697. isReady(): boolean;
  58698. /**
  58699. * Render the texture to its associated render target.
  58700. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58701. */
  58702. render(useCameraPostProcess?: boolean): void;
  58703. /**
  58704. * Update the list of dependant textures samplers in the shader.
  58705. */
  58706. updateTextures(): void;
  58707. /**
  58708. * Update the uniform values of the procedural texture in the shader.
  58709. */
  58710. updateShaderUniforms(): void;
  58711. /**
  58712. * Define if the texture animates or not.
  58713. */
  58714. get animate(): boolean;
  58715. set animate(value: boolean);
  58716. }
  58717. }
  58718. declare module "babylonjs/Shaders/noise.fragment" {
  58719. /** @hidden */
  58720. export var noisePixelShader: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58726. import { Nullable } from "babylonjs/types";
  58727. import { Scene } from "babylonjs/scene";
  58728. import { Texture } from "babylonjs/Materials/Textures/texture";
  58729. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58730. import "babylonjs/Shaders/noise.fragment";
  58731. /**
  58732. * Class used to generate noise procedural textures
  58733. */
  58734. export class NoiseProceduralTexture extends ProceduralTexture {
  58735. private _time;
  58736. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58737. brightness: number;
  58738. /** Defines the number of octaves to process */
  58739. octaves: number;
  58740. /** Defines the level of persistence (0.8 by default) */
  58741. persistence: number;
  58742. /** Gets or sets animation speed factor (default is 1) */
  58743. animationSpeedFactor: number;
  58744. /**
  58745. * Creates a new NoiseProceduralTexture
  58746. * @param name defines the name fo the texture
  58747. * @param size defines the size of the texture (default is 256)
  58748. * @param scene defines the hosting scene
  58749. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58750. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58751. */
  58752. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58753. private _updateShaderUniforms;
  58754. protected _getDefines(): string;
  58755. /** Generate the current state of the procedural texture */
  58756. render(useCameraPostProcess?: boolean): void;
  58757. /**
  58758. * Serializes this noise procedural texture
  58759. * @returns a serialized noise procedural texture object
  58760. */
  58761. serialize(): any;
  58762. /**
  58763. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58764. * @param parsedTexture defines parsed texture data
  58765. * @param scene defines the current scene
  58766. * @param rootUrl defines the root URL containing noise procedural texture information
  58767. * @returns a parsed NoiseProceduralTexture
  58768. */
  58769. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58770. }
  58771. }
  58772. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58773. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58774. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58775. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58776. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58777. }
  58778. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58779. import { Nullable } from "babylonjs/types";
  58780. import { Scene } from "babylonjs/scene";
  58781. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58783. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58784. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58785. /**
  58786. * Raw cube texture where the raw buffers are passed in
  58787. */
  58788. export class RawCubeTexture extends CubeTexture {
  58789. /**
  58790. * Creates a cube texture where the raw buffers are passed in.
  58791. * @param scene defines the scene the texture is attached to
  58792. * @param data defines the array of data to use to create each face
  58793. * @param size defines the size of the textures
  58794. * @param format defines the format of the data
  58795. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58796. * @param generateMipMaps defines if the engine should generate the mip levels
  58797. * @param invertY defines if data must be stored with Y axis inverted
  58798. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58799. * @param compression defines the compression used (null by default)
  58800. */
  58801. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58802. /**
  58803. * Updates the raw cube texture.
  58804. * @param data defines the data to store
  58805. * @param format defines the data format
  58806. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58807. * @param invertY defines if data must be stored with Y axis inverted
  58808. * @param compression defines the compression used (null by default)
  58809. * @param level defines which level of the texture to update
  58810. */
  58811. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58812. /**
  58813. * Updates a raw cube texture with RGBD encoded data.
  58814. * @param data defines the array of data [mipmap][face] to use to create each face
  58815. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58816. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58817. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58818. * @returns a promsie that resolves when the operation is complete
  58819. */
  58820. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58821. /**
  58822. * Clones the raw cube texture.
  58823. * @return a new cube texture
  58824. */
  58825. clone(): CubeTexture;
  58826. /** @hidden */
  58827. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58828. }
  58829. }
  58830. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58831. import { Scene } from "babylonjs/scene";
  58832. import { Texture } from "babylonjs/Materials/Textures/texture";
  58833. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58834. /**
  58835. * Class used to store 3D textures containing user data
  58836. */
  58837. export class RawTexture3D extends Texture {
  58838. /** Gets or sets the texture format to use */
  58839. format: number;
  58840. private _engine;
  58841. /**
  58842. * Create a new RawTexture3D
  58843. * @param data defines the data of the texture
  58844. * @param width defines the width of the texture
  58845. * @param height defines the height of the texture
  58846. * @param depth defines the depth of the texture
  58847. * @param format defines the texture format to use
  58848. * @param scene defines the hosting scene
  58849. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58850. * @param invertY defines if texture must be stored with Y axis inverted
  58851. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58852. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58853. */
  58854. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58855. /** Gets or sets the texture format to use */
  58856. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58857. /**
  58858. * Update the texture with new data
  58859. * @param data defines the data to store in the texture
  58860. */
  58861. update(data: ArrayBufferView): void;
  58862. }
  58863. }
  58864. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58865. import { Scene } from "babylonjs/scene";
  58866. import { Texture } from "babylonjs/Materials/Textures/texture";
  58867. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58868. /**
  58869. * Class used to store 2D array textures containing user data
  58870. */
  58871. export class RawTexture2DArray extends Texture {
  58872. /** Gets or sets the texture format to use */
  58873. format: number;
  58874. private _engine;
  58875. /**
  58876. * Create a new RawTexture2DArray
  58877. * @param data defines the data of the texture
  58878. * @param width defines the width of the texture
  58879. * @param height defines the height of the texture
  58880. * @param depth defines the number of layers of the texture
  58881. * @param format defines the texture format to use
  58882. * @param scene defines the hosting scene
  58883. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58884. * @param invertY defines if texture must be stored with Y axis inverted
  58885. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58886. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58887. */
  58888. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58889. /** Gets or sets the texture format to use */
  58890. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58891. /**
  58892. * Update the texture with new data
  58893. * @param data defines the data to store in the texture
  58894. */
  58895. update(data: ArrayBufferView): void;
  58896. }
  58897. }
  58898. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58899. import { Scene } from "babylonjs/scene";
  58900. import { Plane } from "babylonjs/Maths/math.plane";
  58901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58902. /**
  58903. * Creates a refraction texture used by refraction channel of the standard material.
  58904. * It is like a mirror but to see through a material.
  58905. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58906. */
  58907. export class RefractionTexture extends RenderTargetTexture {
  58908. /**
  58909. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58910. * 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.
  58911. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58912. */
  58913. refractionPlane: Plane;
  58914. /**
  58915. * Define how deep under the surface we should see.
  58916. */
  58917. depth: number;
  58918. /**
  58919. * Creates a refraction texture used by refraction channel of the standard material.
  58920. * It is like a mirror but to see through a material.
  58921. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58922. * @param name Define the texture name
  58923. * @param size Define the size of the underlying texture
  58924. * @param scene Define the scene the refraction belongs to
  58925. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58926. */
  58927. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58928. /**
  58929. * Clone the refraction texture.
  58930. * @returns the cloned texture
  58931. */
  58932. clone(): RefractionTexture;
  58933. /**
  58934. * Serialize the texture to a JSON representation you could use in Parse later on
  58935. * @returns the serialized JSON representation
  58936. */
  58937. serialize(): any;
  58938. }
  58939. }
  58940. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58941. import { Nullable } from "babylonjs/types";
  58942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58943. import { Matrix } from "babylonjs/Maths/math.vector";
  58944. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58945. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58946. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58947. import { Scene } from "babylonjs/scene";
  58948. /**
  58949. * Defines the options related to the creation of an HtmlElementTexture
  58950. */
  58951. export interface IHtmlElementTextureOptions {
  58952. /**
  58953. * Defines wether mip maps should be created or not.
  58954. */
  58955. generateMipMaps?: boolean;
  58956. /**
  58957. * Defines the sampling mode of the texture.
  58958. */
  58959. samplingMode?: number;
  58960. /**
  58961. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58962. */
  58963. engine: Nullable<ThinEngine>;
  58964. /**
  58965. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58966. */
  58967. scene: Nullable<Scene>;
  58968. }
  58969. /**
  58970. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58971. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58972. * is automatically managed.
  58973. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58974. * in your application.
  58975. *
  58976. * As the update is not automatic, you need to call them manually.
  58977. */
  58978. export class HtmlElementTexture extends BaseTexture {
  58979. /**
  58980. * The texture URL.
  58981. */
  58982. element: HTMLVideoElement | HTMLCanvasElement;
  58983. private static readonly DefaultOptions;
  58984. private _textureMatrix;
  58985. private _engine;
  58986. private _isVideo;
  58987. private _generateMipMaps;
  58988. private _samplingMode;
  58989. /**
  58990. * Instantiates a HtmlElementTexture from the following parameters.
  58991. *
  58992. * @param name Defines the name of the texture
  58993. * @param element Defines the video or canvas the texture is filled with
  58994. * @param options Defines the other none mandatory texture creation options
  58995. */
  58996. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58997. private _createInternalTexture;
  58998. /**
  58999. * Returns the texture matrix used in most of the material.
  59000. */
  59001. getTextureMatrix(): Matrix;
  59002. /**
  59003. * Updates the content of the texture.
  59004. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59005. */
  59006. update(invertY?: Nullable<boolean>): void;
  59007. }
  59008. }
  59009. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59010. import { Vector2 } from "babylonjs/Maths/math.vector";
  59011. /**
  59012. * Defines the basic options interface of a TexturePacker Frame
  59013. */
  59014. export interface ITexturePackerFrame {
  59015. /**
  59016. * The frame ID
  59017. */
  59018. id: number;
  59019. /**
  59020. * The frames Scale
  59021. */
  59022. scale: Vector2;
  59023. /**
  59024. * The Frames offset
  59025. */
  59026. offset: Vector2;
  59027. }
  59028. /**
  59029. * This is a support class for frame Data on texture packer sets.
  59030. */
  59031. export class TexturePackerFrame implements ITexturePackerFrame {
  59032. /**
  59033. * The frame ID
  59034. */
  59035. id: number;
  59036. /**
  59037. * The frames Scale
  59038. */
  59039. scale: Vector2;
  59040. /**
  59041. * The Frames offset
  59042. */
  59043. offset: Vector2;
  59044. /**
  59045. * Initializes a texture package frame.
  59046. * @param id The numerical frame identifier
  59047. * @param scale Scalar Vector2 for UV frame
  59048. * @param offset Vector2 for the frame position in UV units.
  59049. * @returns TexturePackerFrame
  59050. */
  59051. constructor(id: number, scale: Vector2, offset: Vector2);
  59052. }
  59053. }
  59054. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59056. import { Scene } from "babylonjs/scene";
  59057. import { Nullable } from "babylonjs/types";
  59058. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59059. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59060. /**
  59061. * Defines the basic options interface of a TexturePacker
  59062. */
  59063. export interface ITexturePackerOptions {
  59064. /**
  59065. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59066. */
  59067. map?: string[];
  59068. /**
  59069. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59070. */
  59071. uvsIn?: string;
  59072. /**
  59073. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59074. */
  59075. uvsOut?: string;
  59076. /**
  59077. * number representing the layout style. Defaults to LAYOUT_STRIP
  59078. */
  59079. layout?: number;
  59080. /**
  59081. * number of columns if using custom column count layout(2). This defaults to 4.
  59082. */
  59083. colnum?: number;
  59084. /**
  59085. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59086. */
  59087. updateInputMeshes?: boolean;
  59088. /**
  59089. * boolean flag to dispose all the source textures. Defaults to true.
  59090. */
  59091. disposeSources?: boolean;
  59092. /**
  59093. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59094. */
  59095. fillBlanks?: boolean;
  59096. /**
  59097. * string value representing the context fill style color. Defaults to 'black'.
  59098. */
  59099. customFillColor?: string;
  59100. /**
  59101. * Width and Height Value of each Frame in the TexturePacker Sets
  59102. */
  59103. frameSize?: number;
  59104. /**
  59105. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59106. */
  59107. paddingRatio?: number;
  59108. /**
  59109. * Number that declares the fill method for the padding gutter.
  59110. */
  59111. paddingMode?: number;
  59112. /**
  59113. * If in SUBUV_COLOR padding mode what color to use.
  59114. */
  59115. paddingColor?: Color3 | Color4;
  59116. }
  59117. /**
  59118. * Defines the basic interface of a TexturePacker JSON File
  59119. */
  59120. export interface ITexturePackerJSON {
  59121. /**
  59122. * The frame ID
  59123. */
  59124. name: string;
  59125. /**
  59126. * The base64 channel data
  59127. */
  59128. sets: any;
  59129. /**
  59130. * The options of the Packer
  59131. */
  59132. options: ITexturePackerOptions;
  59133. /**
  59134. * The frame data of the Packer
  59135. */
  59136. frames: Array<number>;
  59137. }
  59138. /**
  59139. * This is a support class that generates a series of packed texture sets.
  59140. * @see https://doc.babylonjs.com/babylon101/materials
  59141. */
  59142. export class TexturePacker {
  59143. /** Packer Layout Constant 0 */
  59144. static readonly LAYOUT_STRIP: number;
  59145. /** Packer Layout Constant 1 */
  59146. static readonly LAYOUT_POWER2: number;
  59147. /** Packer Layout Constant 2 */
  59148. static readonly LAYOUT_COLNUM: number;
  59149. /** Packer Layout Constant 0 */
  59150. static readonly SUBUV_WRAP: number;
  59151. /** Packer Layout Constant 1 */
  59152. static readonly SUBUV_EXTEND: number;
  59153. /** Packer Layout Constant 2 */
  59154. static readonly SUBUV_COLOR: number;
  59155. /** The Name of the Texture Package */
  59156. name: string;
  59157. /** The scene scope of the TexturePacker */
  59158. scene: Scene;
  59159. /** The Meshes to target */
  59160. meshes: AbstractMesh[];
  59161. /** Arguments passed with the Constructor */
  59162. options: ITexturePackerOptions;
  59163. /** The promise that is started upon initialization */
  59164. promise: Nullable<Promise<TexturePacker | string>>;
  59165. /** The Container object for the channel sets that are generated */
  59166. sets: object;
  59167. /** The Container array for the frames that are generated */
  59168. frames: TexturePackerFrame[];
  59169. /** The expected number of textures the system is parsing. */
  59170. private _expecting;
  59171. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59172. private _paddingValue;
  59173. /**
  59174. * Initializes a texture package series from an array of meshes or a single mesh.
  59175. * @param name The name of the package
  59176. * @param meshes The target meshes to compose the package from
  59177. * @param options The arguments that texture packer should follow while building.
  59178. * @param scene The scene which the textures are scoped to.
  59179. * @returns TexturePacker
  59180. */
  59181. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59182. /**
  59183. * Starts the package process
  59184. * @param resolve The promises resolution function
  59185. * @returns TexturePacker
  59186. */
  59187. private _createFrames;
  59188. /**
  59189. * Calculates the Size of the Channel Sets
  59190. * @returns Vector2
  59191. */
  59192. private _calculateSize;
  59193. /**
  59194. * Calculates the UV data for the frames.
  59195. * @param baseSize the base frameSize
  59196. * @param padding the base frame padding
  59197. * @param dtSize size of the Dynamic Texture for that channel
  59198. * @param dtUnits is 1/dtSize
  59199. * @param update flag to update the input meshes
  59200. */
  59201. private _calculateMeshUVFrames;
  59202. /**
  59203. * Calculates the frames Offset.
  59204. * @param index of the frame
  59205. * @returns Vector2
  59206. */
  59207. private _getFrameOffset;
  59208. /**
  59209. * Updates a Mesh to the frame data
  59210. * @param mesh that is the target
  59211. * @param frameID or the frame index
  59212. */
  59213. private _updateMeshUV;
  59214. /**
  59215. * Updates a Meshes materials to use the texture packer channels
  59216. * @param m is the mesh to target
  59217. * @param force all channels on the packer to be set.
  59218. */
  59219. private _updateTextureReferences;
  59220. /**
  59221. * Public method to set a Mesh to a frame
  59222. * @param m that is the target
  59223. * @param frameID or the frame index
  59224. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59225. */
  59226. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59227. /**
  59228. * Starts the async promise to compile the texture packer.
  59229. * @returns Promise<void>
  59230. */
  59231. processAsync(): Promise<void>;
  59232. /**
  59233. * Disposes all textures associated with this packer
  59234. */
  59235. dispose(): void;
  59236. /**
  59237. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59238. * @param imageType is the image type to use.
  59239. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59240. */
  59241. download(imageType?: string, quality?: number): void;
  59242. /**
  59243. * Public method to load a texturePacker JSON file.
  59244. * @param data of the JSON file in string format.
  59245. */
  59246. updateFromJSON(data: string): void;
  59247. }
  59248. }
  59249. declare module "babylonjs/Materials/Textures/Packer/index" {
  59250. export * from "babylonjs/Materials/Textures/Packer/packer";
  59251. export * from "babylonjs/Materials/Textures/Packer/frame";
  59252. }
  59253. declare module "babylonjs/Materials/Textures/index" {
  59254. export * from "babylonjs/Materials/Textures/baseTexture";
  59255. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59256. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59257. export * from "babylonjs/Materials/Textures/cubeTexture";
  59258. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59259. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59260. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59261. export * from "babylonjs/Materials/Textures/internalTexture";
  59262. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59263. export * from "babylonjs/Materials/Textures/Loaders/index";
  59264. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59265. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59266. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59267. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59268. export * from "babylonjs/Materials/Textures/rawTexture";
  59269. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59270. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59271. export * from "babylonjs/Materials/Textures/refractionTexture";
  59272. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59273. export * from "babylonjs/Materials/Textures/texture";
  59274. export * from "babylonjs/Materials/Textures/videoTexture";
  59275. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59276. export * from "babylonjs/Materials/Textures/Packer/index";
  59277. }
  59278. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59279. /**
  59280. * Enum used to define the target of a block
  59281. */
  59282. export enum NodeMaterialBlockTargets {
  59283. /** Vertex shader */
  59284. Vertex = 1,
  59285. /** Fragment shader */
  59286. Fragment = 2,
  59287. /** Neutral */
  59288. Neutral = 4,
  59289. /** Vertex and Fragment */
  59290. VertexAndFragment = 3
  59291. }
  59292. }
  59293. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59294. /**
  59295. * Defines the kind of connection point for node based material
  59296. */
  59297. export enum NodeMaterialBlockConnectionPointTypes {
  59298. /** Float */
  59299. Float = 1,
  59300. /** Int */
  59301. Int = 2,
  59302. /** Vector2 */
  59303. Vector2 = 4,
  59304. /** Vector3 */
  59305. Vector3 = 8,
  59306. /** Vector4 */
  59307. Vector4 = 16,
  59308. /** Color3 */
  59309. Color3 = 32,
  59310. /** Color4 */
  59311. Color4 = 64,
  59312. /** Matrix */
  59313. Matrix = 128,
  59314. /** Detect type based on connection */
  59315. AutoDetect = 1024,
  59316. /** Output type that will be defined by input type */
  59317. BasedOnInput = 2048
  59318. }
  59319. }
  59320. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59321. /**
  59322. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59323. */
  59324. export enum NodeMaterialBlockConnectionPointMode {
  59325. /** Value is an uniform */
  59326. Uniform = 0,
  59327. /** Value is a mesh attribute */
  59328. Attribute = 1,
  59329. /** Value is a varying between vertex and fragment shaders */
  59330. Varying = 2,
  59331. /** Mode is undefined */
  59332. Undefined = 3
  59333. }
  59334. }
  59335. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59336. /**
  59337. * Enum used to define system values e.g. values automatically provided by the system
  59338. */
  59339. export enum NodeMaterialSystemValues {
  59340. /** World */
  59341. World = 1,
  59342. /** View */
  59343. View = 2,
  59344. /** Projection */
  59345. Projection = 3,
  59346. /** ViewProjection */
  59347. ViewProjection = 4,
  59348. /** WorldView */
  59349. WorldView = 5,
  59350. /** WorldViewProjection */
  59351. WorldViewProjection = 6,
  59352. /** CameraPosition */
  59353. CameraPosition = 7,
  59354. /** Fog Color */
  59355. FogColor = 8,
  59356. /** Delta time */
  59357. DeltaTime = 9
  59358. }
  59359. }
  59360. declare module "babylonjs/Materials/Node/Enums/index" {
  59361. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59362. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59363. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59364. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59365. }
  59366. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59368. /**
  59369. * Root class for all node material optimizers
  59370. */
  59371. export class NodeMaterialOptimizer {
  59372. /**
  59373. * Function used to optimize a NodeMaterial graph
  59374. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59375. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59376. */
  59377. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59378. }
  59379. }
  59380. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59384. import { Scene } from "babylonjs/scene";
  59385. /**
  59386. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59387. */
  59388. export class TransformBlock extends NodeMaterialBlock {
  59389. /**
  59390. * Defines the value to use to complement W value to transform it to a Vector4
  59391. */
  59392. complementW: number;
  59393. /**
  59394. * Defines the value to use to complement z value to transform it to a Vector4
  59395. */
  59396. complementZ: number;
  59397. /**
  59398. * Creates a new TransformBlock
  59399. * @param name defines the block name
  59400. */
  59401. constructor(name: string);
  59402. /**
  59403. * Gets the current class name
  59404. * @returns the class name
  59405. */
  59406. getClassName(): string;
  59407. /**
  59408. * Gets the vector input
  59409. */
  59410. get vector(): NodeMaterialConnectionPoint;
  59411. /**
  59412. * Gets the output component
  59413. */
  59414. get output(): NodeMaterialConnectionPoint;
  59415. /**
  59416. * Gets the matrix transform input
  59417. */
  59418. get transform(): NodeMaterialConnectionPoint;
  59419. protected _buildBlock(state: NodeMaterialBuildState): this;
  59420. serialize(): any;
  59421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59422. protected _dumpPropertiesCode(): string;
  59423. }
  59424. }
  59425. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59429. /**
  59430. * Block used to output the vertex position
  59431. */
  59432. export class VertexOutputBlock extends NodeMaterialBlock {
  59433. /**
  59434. * Creates a new VertexOutputBlock
  59435. * @param name defines the block name
  59436. */
  59437. constructor(name: string);
  59438. /**
  59439. * Gets the current class name
  59440. * @returns the class name
  59441. */
  59442. getClassName(): string;
  59443. /**
  59444. * Gets the vector input component
  59445. */
  59446. get vector(): NodeMaterialConnectionPoint;
  59447. protected _buildBlock(state: NodeMaterialBuildState): this;
  59448. }
  59449. }
  59450. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59454. /**
  59455. * Block used to output the final color
  59456. */
  59457. export class FragmentOutputBlock extends NodeMaterialBlock {
  59458. /**
  59459. * Create a new FragmentOutputBlock
  59460. * @param name defines the block name
  59461. */
  59462. constructor(name: string);
  59463. /**
  59464. * Gets the current class name
  59465. * @returns the class name
  59466. */
  59467. getClassName(): string;
  59468. /**
  59469. * Gets the rgba input component
  59470. */
  59471. get rgba(): NodeMaterialConnectionPoint;
  59472. /**
  59473. * Gets the rgb input component
  59474. */
  59475. get rgb(): NodeMaterialConnectionPoint;
  59476. /**
  59477. * Gets the a input component
  59478. */
  59479. get a(): NodeMaterialConnectionPoint;
  59480. protected _buildBlock(state: NodeMaterialBuildState): this;
  59481. }
  59482. }
  59483. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59489. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59490. import { Effect } from "babylonjs/Materials/effect";
  59491. import { Mesh } from "babylonjs/Meshes/mesh";
  59492. import { Nullable } from "babylonjs/types";
  59493. import { Scene } from "babylonjs/scene";
  59494. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59495. /**
  59496. * Block used to read a reflection texture from a sampler
  59497. */
  59498. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59499. private _define3DName;
  59500. private _defineCubicName;
  59501. private _defineExplicitName;
  59502. private _defineProjectionName;
  59503. private _defineLocalCubicName;
  59504. private _defineSphericalName;
  59505. private _definePlanarName;
  59506. private _defineEquirectangularName;
  59507. private _defineMirroredEquirectangularFixedName;
  59508. private _defineEquirectangularFixedName;
  59509. private _defineSkyboxName;
  59510. private _cubeSamplerName;
  59511. private _2DSamplerName;
  59512. private _positionUVWName;
  59513. private _directionWName;
  59514. private _reflectionCoordsName;
  59515. private _reflection2DCoordsName;
  59516. private _reflectionColorName;
  59517. private _reflectionMatrixName;
  59518. /**
  59519. * Gets or sets the texture associated with the node
  59520. */
  59521. texture: Nullable<BaseTexture>;
  59522. /**
  59523. * Create a new TextureBlock
  59524. * @param name defines the block name
  59525. */
  59526. constructor(name: string);
  59527. /**
  59528. * Gets the current class name
  59529. * @returns the class name
  59530. */
  59531. getClassName(): string;
  59532. /**
  59533. * Gets the world position input component
  59534. */
  59535. get position(): NodeMaterialConnectionPoint;
  59536. /**
  59537. * Gets the world position input component
  59538. */
  59539. get worldPosition(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the world normal input component
  59542. */
  59543. get worldNormal(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the world input component
  59546. */
  59547. get world(): NodeMaterialConnectionPoint;
  59548. /**
  59549. * Gets the camera (or eye) position component
  59550. */
  59551. get cameraPosition(): NodeMaterialConnectionPoint;
  59552. /**
  59553. * Gets the view input component
  59554. */
  59555. get view(): NodeMaterialConnectionPoint;
  59556. /**
  59557. * Gets the rgb output component
  59558. */
  59559. get rgb(): NodeMaterialConnectionPoint;
  59560. /**
  59561. * Gets the r output component
  59562. */
  59563. get r(): NodeMaterialConnectionPoint;
  59564. /**
  59565. * Gets the g output component
  59566. */
  59567. get g(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the b output component
  59570. */
  59571. get b(): NodeMaterialConnectionPoint;
  59572. autoConfigure(material: NodeMaterial): void;
  59573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59574. isReady(): boolean;
  59575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59576. private _injectVertexCode;
  59577. private _writeOutput;
  59578. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59579. protected _dumpPropertiesCode(): string;
  59580. serialize(): any;
  59581. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59582. }
  59583. }
  59584. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59585. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59586. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59587. import { Scene } from "babylonjs/scene";
  59588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59589. import { Matrix } from "babylonjs/Maths/math.vector";
  59590. import { Mesh } from "babylonjs/Meshes/mesh";
  59591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59592. import { Observable } from "babylonjs/Misc/observable";
  59593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59594. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59595. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59596. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59597. import { Nullable } from "babylonjs/types";
  59598. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59599. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59600. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59601. /**
  59602. * Interface used to configure the node material editor
  59603. */
  59604. export interface INodeMaterialEditorOptions {
  59605. /** Define the URl to load node editor script */
  59606. editorURL?: string;
  59607. }
  59608. /** @hidden */
  59609. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59610. NORMAL: boolean;
  59611. TANGENT: boolean;
  59612. UV1: boolean;
  59613. /** BONES */
  59614. NUM_BONE_INFLUENCERS: number;
  59615. BonesPerMesh: number;
  59616. BONETEXTURE: boolean;
  59617. /** MORPH TARGETS */
  59618. MORPHTARGETS: boolean;
  59619. MORPHTARGETS_NORMAL: boolean;
  59620. MORPHTARGETS_TANGENT: boolean;
  59621. MORPHTARGETS_UV: boolean;
  59622. NUM_MORPH_INFLUENCERS: number;
  59623. /** IMAGE PROCESSING */
  59624. IMAGEPROCESSING: boolean;
  59625. VIGNETTE: boolean;
  59626. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59627. VIGNETTEBLENDMODEOPAQUE: boolean;
  59628. TONEMAPPING: boolean;
  59629. TONEMAPPING_ACES: boolean;
  59630. CONTRAST: boolean;
  59631. EXPOSURE: boolean;
  59632. COLORCURVES: boolean;
  59633. COLORGRADING: boolean;
  59634. COLORGRADING3D: boolean;
  59635. SAMPLER3DGREENDEPTH: boolean;
  59636. SAMPLER3DBGRMAP: boolean;
  59637. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59638. /** MISC. */
  59639. BUMPDIRECTUV: number;
  59640. constructor();
  59641. setValue(name: string, value: boolean): void;
  59642. }
  59643. /**
  59644. * Class used to configure NodeMaterial
  59645. */
  59646. export interface INodeMaterialOptions {
  59647. /**
  59648. * Defines if blocks should emit comments
  59649. */
  59650. emitComments: boolean;
  59651. }
  59652. /**
  59653. * Class used to create a node based material built by assembling shader blocks
  59654. */
  59655. export class NodeMaterial extends PushMaterial {
  59656. private static _BuildIdGenerator;
  59657. private _options;
  59658. private _vertexCompilationState;
  59659. private _fragmentCompilationState;
  59660. private _sharedData;
  59661. private _buildId;
  59662. private _buildWasSuccessful;
  59663. private _cachedWorldViewMatrix;
  59664. private _cachedWorldViewProjectionMatrix;
  59665. private _optimizers;
  59666. private _animationFrame;
  59667. /** Define the Url to load node editor script */
  59668. static EditorURL: string;
  59669. /** Define the Url to load snippets */
  59670. static SnippetUrl: string;
  59671. private BJSNODEMATERIALEDITOR;
  59672. /** Get the inspector from bundle or global */
  59673. private _getGlobalNodeMaterialEditor;
  59674. /**
  59675. * Gets or sets data used by visual editor
  59676. * @see https://nme.babylonjs.com
  59677. */
  59678. editorData: any;
  59679. /**
  59680. * 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)
  59681. */
  59682. ignoreAlpha: boolean;
  59683. /**
  59684. * Defines the maximum number of lights that can be used in the material
  59685. */
  59686. maxSimultaneousLights: number;
  59687. /**
  59688. * Observable raised when the material is built
  59689. */
  59690. onBuildObservable: Observable<NodeMaterial>;
  59691. /**
  59692. * Gets or sets the root nodes of the material vertex shader
  59693. */
  59694. _vertexOutputNodes: NodeMaterialBlock[];
  59695. /**
  59696. * Gets or sets the root nodes of the material fragment (pixel) shader
  59697. */
  59698. _fragmentOutputNodes: NodeMaterialBlock[];
  59699. /** Gets or sets options to control the node material overall behavior */
  59700. get options(): INodeMaterialOptions;
  59701. set options(options: INodeMaterialOptions);
  59702. /**
  59703. * Default configuration related to image processing available in the standard Material.
  59704. */
  59705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59706. /**
  59707. * Gets the image processing configuration used either in this material.
  59708. */
  59709. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59710. /**
  59711. * Sets the Default image processing configuration used either in the this material.
  59712. *
  59713. * If sets to null, the scene one is in use.
  59714. */
  59715. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59716. /**
  59717. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59718. */
  59719. attachedBlocks: NodeMaterialBlock[];
  59720. /**
  59721. * Create a new node based material
  59722. * @param name defines the material name
  59723. * @param scene defines the hosting scene
  59724. * @param options defines creation option
  59725. */
  59726. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59727. /**
  59728. * Gets the current class name of the material e.g. "NodeMaterial"
  59729. * @returns the class name
  59730. */
  59731. getClassName(): string;
  59732. /**
  59733. * Keep track of the image processing observer to allow dispose and replace.
  59734. */
  59735. private _imageProcessingObserver;
  59736. /**
  59737. * Attaches a new image processing configuration to the Standard Material.
  59738. * @param configuration
  59739. */
  59740. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59741. /**
  59742. * Get a block by its name
  59743. * @param name defines the name of the block to retrieve
  59744. * @returns the required block or null if not found
  59745. */
  59746. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59747. /**
  59748. * Get a block by its name
  59749. * @param predicate defines the predicate used to find the good candidate
  59750. * @returns the required block or null if not found
  59751. */
  59752. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59753. /**
  59754. * Get an input block by its name
  59755. * @param predicate defines the predicate used to find the good candidate
  59756. * @returns the required input block or null if not found
  59757. */
  59758. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59759. /**
  59760. * Gets the list of input blocks attached to this material
  59761. * @returns an array of InputBlocks
  59762. */
  59763. getInputBlocks(): InputBlock[];
  59764. /**
  59765. * Adds a new optimizer to the list of optimizers
  59766. * @param optimizer defines the optimizers to add
  59767. * @returns the current material
  59768. */
  59769. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59770. /**
  59771. * Remove an optimizer from the list of optimizers
  59772. * @param optimizer defines the optimizers to remove
  59773. * @returns the current material
  59774. */
  59775. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59776. /**
  59777. * Add a new block to the list of output nodes
  59778. * @param node defines the node to add
  59779. * @returns the current material
  59780. */
  59781. addOutputNode(node: NodeMaterialBlock): this;
  59782. /**
  59783. * Remove a block from the list of root nodes
  59784. * @param node defines the node to remove
  59785. * @returns the current material
  59786. */
  59787. removeOutputNode(node: NodeMaterialBlock): this;
  59788. private _addVertexOutputNode;
  59789. private _removeVertexOutputNode;
  59790. private _addFragmentOutputNode;
  59791. private _removeFragmentOutputNode;
  59792. /**
  59793. * Specifies if the material will require alpha blending
  59794. * @returns a boolean specifying if alpha blending is needed
  59795. */
  59796. needAlphaBlending(): boolean;
  59797. /**
  59798. * Specifies if this material should be rendered in alpha test mode
  59799. * @returns a boolean specifying if an alpha test is needed.
  59800. */
  59801. needAlphaTesting(): boolean;
  59802. private _initializeBlock;
  59803. private _resetDualBlocks;
  59804. /**
  59805. * Remove a block from the current node material
  59806. * @param block defines the block to remove
  59807. */
  59808. removeBlock(block: NodeMaterialBlock): void;
  59809. /**
  59810. * Build the material and generates the inner effect
  59811. * @param verbose defines if the build should log activity
  59812. */
  59813. build(verbose?: boolean): void;
  59814. /**
  59815. * Runs an otpimization phase to try to improve the shader code
  59816. */
  59817. optimize(): void;
  59818. private _prepareDefinesForAttributes;
  59819. /**
  59820. * Get if the submesh is ready to be used and all its information available.
  59821. * Child classes can use it to update shaders
  59822. * @param mesh defines the mesh to check
  59823. * @param subMesh defines which submesh to check
  59824. * @param useInstances specifies that instances should be used
  59825. * @returns a boolean indicating that the submesh is ready or not
  59826. */
  59827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59828. /**
  59829. * Get a string representing the shaders built by the current node graph
  59830. */
  59831. get compiledShaders(): string;
  59832. /**
  59833. * Binds the world matrix to the material
  59834. * @param world defines the world transformation matrix
  59835. */
  59836. bindOnlyWorldMatrix(world: Matrix): void;
  59837. /**
  59838. * Binds the submesh to this material by preparing the effect and shader to draw
  59839. * @param world defines the world transformation matrix
  59840. * @param mesh defines the mesh containing the submesh
  59841. * @param subMesh defines the submesh to bind the material to
  59842. */
  59843. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59844. /**
  59845. * Gets the active textures from the material
  59846. * @returns an array of textures
  59847. */
  59848. getActiveTextures(): BaseTexture[];
  59849. /**
  59850. * Gets the list of texture blocks
  59851. * @returns an array of texture blocks
  59852. */
  59853. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59854. /**
  59855. * Specifies if the material uses a texture
  59856. * @param texture defines the texture to check against the material
  59857. * @returns a boolean specifying if the material uses the texture
  59858. */
  59859. hasTexture(texture: BaseTexture): boolean;
  59860. /**
  59861. * Disposes the material
  59862. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59863. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59864. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59865. */
  59866. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59867. /** Creates the node editor window. */
  59868. private _createNodeEditor;
  59869. /**
  59870. * Launch the node material editor
  59871. * @param config Define the configuration of the editor
  59872. * @return a promise fulfilled when the node editor is visible
  59873. */
  59874. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59875. /**
  59876. * Clear the current material
  59877. */
  59878. clear(): void;
  59879. /**
  59880. * Clear the current material and set it to a default state
  59881. */
  59882. setToDefault(): void;
  59883. /**
  59884. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59885. * @param url defines the url to load from
  59886. * @returns a promise that will fullfil when the material is fully loaded
  59887. */
  59888. loadAsync(url: string): Promise<void>;
  59889. private _gatherBlocks;
  59890. /**
  59891. * Generate a string containing the code declaration required to create an equivalent of this material
  59892. * @returns a string
  59893. */
  59894. generateCode(): string;
  59895. /**
  59896. * Serializes this material in a JSON representation
  59897. * @returns the serialized material object
  59898. */
  59899. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59900. private _restoreConnections;
  59901. /**
  59902. * Clear the current graph and load a new one from a serialization object
  59903. * @param source defines the JSON representation of the material
  59904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59905. */
  59906. loadFromSerialization(source: any, rootUrl?: string): void;
  59907. /**
  59908. * Creates a node material from parsed material data
  59909. * @param source defines the JSON representation of the material
  59910. * @param scene defines the hosting scene
  59911. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59912. * @returns a new node material
  59913. */
  59914. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59915. /**
  59916. * Creates a node material from a snippet saved in a remote file
  59917. * @param name defines the name of the material to create
  59918. * @param url defines the url to load from
  59919. * @param scene defines the hosting scene
  59920. * @returns a promise that will resolve to the new node material
  59921. */
  59922. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59923. /**
  59924. * Creates a node material from a snippet saved by the node material editor
  59925. * @param snippetId defines the snippet to load
  59926. * @param scene defines the hosting scene
  59927. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59928. * @returns a promise that will resolve to the new node material
  59929. */
  59930. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59931. /**
  59932. * Creates a new node material set to default basic configuration
  59933. * @param name defines the name of the material
  59934. * @param scene defines the hosting scene
  59935. * @returns a new NodeMaterial
  59936. */
  59937. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59938. }
  59939. }
  59940. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59943. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59946. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59947. import { Effect } from "babylonjs/Materials/effect";
  59948. import { Mesh } from "babylonjs/Meshes/mesh";
  59949. import { Nullable } from "babylonjs/types";
  59950. import { Texture } from "babylonjs/Materials/Textures/texture";
  59951. import { Scene } from "babylonjs/scene";
  59952. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59953. /**
  59954. * Block used to read a texture from a sampler
  59955. */
  59956. export class TextureBlock extends NodeMaterialBlock {
  59957. private _defineName;
  59958. private _linearDefineName;
  59959. private _tempTextureRead;
  59960. private _samplerName;
  59961. private _transformedUVName;
  59962. private _textureTransformName;
  59963. private _textureInfoName;
  59964. private _mainUVName;
  59965. private _mainUVDefineName;
  59966. /**
  59967. * Gets or sets the texture associated with the node
  59968. */
  59969. texture: Nullable<Texture>;
  59970. /**
  59971. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59972. */
  59973. convertToGammaSpace: boolean;
  59974. /**
  59975. * Create a new TextureBlock
  59976. * @param name defines the block name
  59977. */
  59978. constructor(name: string);
  59979. /**
  59980. * Gets the current class name
  59981. * @returns the class name
  59982. */
  59983. getClassName(): string;
  59984. /**
  59985. * Gets the uv input component
  59986. */
  59987. get uv(): NodeMaterialConnectionPoint;
  59988. /**
  59989. * Gets the rgba output component
  59990. */
  59991. get rgba(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the rgb output component
  59994. */
  59995. get rgb(): NodeMaterialConnectionPoint;
  59996. /**
  59997. * Gets the r output component
  59998. */
  59999. get r(): NodeMaterialConnectionPoint;
  60000. /**
  60001. * Gets the g output component
  60002. */
  60003. get g(): NodeMaterialConnectionPoint;
  60004. /**
  60005. * Gets the b output component
  60006. */
  60007. get b(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the a output component
  60010. */
  60011. get a(): NodeMaterialConnectionPoint;
  60012. get target(): NodeMaterialBlockTargets;
  60013. autoConfigure(material: NodeMaterial): void;
  60014. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60016. isReady(): boolean;
  60017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60018. private get _isMixed();
  60019. private _injectVertexCode;
  60020. private _writeTextureRead;
  60021. private _writeOutput;
  60022. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60023. protected _dumpPropertiesCode(): string;
  60024. serialize(): any;
  60025. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60026. }
  60027. }
  60028. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60031. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60032. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60033. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60034. import { Scene } from "babylonjs/scene";
  60035. /**
  60036. * Class used to store shared data between 2 NodeMaterialBuildState
  60037. */
  60038. export class NodeMaterialBuildStateSharedData {
  60039. /**
  60040. * Gets the list of emitted varyings
  60041. */
  60042. temps: string[];
  60043. /**
  60044. * Gets the list of emitted varyings
  60045. */
  60046. varyings: string[];
  60047. /**
  60048. * Gets the varying declaration string
  60049. */
  60050. varyingDeclaration: string;
  60051. /**
  60052. * Input blocks
  60053. */
  60054. inputBlocks: InputBlock[];
  60055. /**
  60056. * Input blocks
  60057. */
  60058. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60059. /**
  60060. * Bindable blocks (Blocks that need to set data to the effect)
  60061. */
  60062. bindableBlocks: NodeMaterialBlock[];
  60063. /**
  60064. * List of blocks that can provide a compilation fallback
  60065. */
  60066. blocksWithFallbacks: NodeMaterialBlock[];
  60067. /**
  60068. * List of blocks that can provide a define update
  60069. */
  60070. blocksWithDefines: NodeMaterialBlock[];
  60071. /**
  60072. * List of blocks that can provide a repeatable content
  60073. */
  60074. repeatableContentBlocks: NodeMaterialBlock[];
  60075. /**
  60076. * List of blocks that can provide a dynamic list of uniforms
  60077. */
  60078. dynamicUniformBlocks: NodeMaterialBlock[];
  60079. /**
  60080. * List of blocks that can block the isReady function for the material
  60081. */
  60082. blockingBlocks: NodeMaterialBlock[];
  60083. /**
  60084. * Gets the list of animated inputs
  60085. */
  60086. animatedInputs: InputBlock[];
  60087. /**
  60088. * Build Id used to avoid multiple recompilations
  60089. */
  60090. buildId: number;
  60091. /** List of emitted variables */
  60092. variableNames: {
  60093. [key: string]: number;
  60094. };
  60095. /** List of emitted defines */
  60096. defineNames: {
  60097. [key: string]: number;
  60098. };
  60099. /** Should emit comments? */
  60100. emitComments: boolean;
  60101. /** Emit build activity */
  60102. verbose: boolean;
  60103. /** Gets or sets the hosting scene */
  60104. scene: Scene;
  60105. /**
  60106. * Gets the compilation hints emitted at compilation time
  60107. */
  60108. hints: {
  60109. needWorldViewMatrix: boolean;
  60110. needWorldViewProjectionMatrix: boolean;
  60111. needAlphaBlending: boolean;
  60112. needAlphaTesting: boolean;
  60113. };
  60114. /**
  60115. * List of compilation checks
  60116. */
  60117. checks: {
  60118. emitVertex: boolean;
  60119. emitFragment: boolean;
  60120. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60121. };
  60122. /** Creates a new shared data */
  60123. constructor();
  60124. /**
  60125. * Emits console errors and exceptions if there is a failing check
  60126. */
  60127. emitErrors(): void;
  60128. }
  60129. }
  60130. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60131. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60132. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60133. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60134. /**
  60135. * Class used to store node based material build state
  60136. */
  60137. export class NodeMaterialBuildState {
  60138. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60139. supportUniformBuffers: boolean;
  60140. /**
  60141. * Gets the list of emitted attributes
  60142. */
  60143. attributes: string[];
  60144. /**
  60145. * Gets the list of emitted uniforms
  60146. */
  60147. uniforms: string[];
  60148. /**
  60149. * Gets the list of emitted constants
  60150. */
  60151. constants: string[];
  60152. /**
  60153. * Gets the list of emitted samplers
  60154. */
  60155. samplers: string[];
  60156. /**
  60157. * Gets the list of emitted functions
  60158. */
  60159. functions: {
  60160. [key: string]: string;
  60161. };
  60162. /**
  60163. * Gets the list of emitted extensions
  60164. */
  60165. extensions: {
  60166. [key: string]: string;
  60167. };
  60168. /**
  60169. * Gets the target of the compilation state
  60170. */
  60171. target: NodeMaterialBlockTargets;
  60172. /**
  60173. * Gets the list of emitted counters
  60174. */
  60175. counters: {
  60176. [key: string]: number;
  60177. };
  60178. /**
  60179. * Shared data between multiple NodeMaterialBuildState instances
  60180. */
  60181. sharedData: NodeMaterialBuildStateSharedData;
  60182. /** @hidden */
  60183. _vertexState: NodeMaterialBuildState;
  60184. /** @hidden */
  60185. _attributeDeclaration: string;
  60186. /** @hidden */
  60187. _uniformDeclaration: string;
  60188. /** @hidden */
  60189. _constantDeclaration: string;
  60190. /** @hidden */
  60191. _samplerDeclaration: string;
  60192. /** @hidden */
  60193. _varyingTransfer: string;
  60194. private _repeatableContentAnchorIndex;
  60195. /** @hidden */
  60196. _builtCompilationString: string;
  60197. /**
  60198. * Gets the emitted compilation strings
  60199. */
  60200. compilationString: string;
  60201. /**
  60202. * Finalize the compilation strings
  60203. * @param state defines the current compilation state
  60204. */
  60205. finalize(state: NodeMaterialBuildState): void;
  60206. /** @hidden */
  60207. get _repeatableContentAnchor(): string;
  60208. /** @hidden */
  60209. _getFreeVariableName(prefix: string): string;
  60210. /** @hidden */
  60211. _getFreeDefineName(prefix: string): string;
  60212. /** @hidden */
  60213. _excludeVariableName(name: string): void;
  60214. /** @hidden */
  60215. _emit2DSampler(name: string): void;
  60216. /** @hidden */
  60217. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60218. /** @hidden */
  60219. _emitExtension(name: string, extension: string): void;
  60220. /** @hidden */
  60221. _emitFunction(name: string, code: string, comments: string): void;
  60222. /** @hidden */
  60223. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60224. replaceStrings?: {
  60225. search: RegExp;
  60226. replace: string;
  60227. }[];
  60228. repeatKey?: string;
  60229. }): string;
  60230. /** @hidden */
  60231. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60232. repeatKey?: string;
  60233. removeAttributes?: boolean;
  60234. removeUniforms?: boolean;
  60235. removeVaryings?: boolean;
  60236. removeIfDef?: boolean;
  60237. replaceStrings?: {
  60238. search: RegExp;
  60239. replace: string;
  60240. }[];
  60241. }, storeKey?: string): void;
  60242. /** @hidden */
  60243. _registerTempVariable(name: string): boolean;
  60244. /** @hidden */
  60245. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60246. /** @hidden */
  60247. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60248. /** @hidden */
  60249. _emitFloat(value: number): string;
  60250. }
  60251. }
  60252. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60253. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60254. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60255. import { Nullable } from "babylonjs/types";
  60256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60257. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60258. import { Effect } from "babylonjs/Materials/effect";
  60259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60260. import { Mesh } from "babylonjs/Meshes/mesh";
  60261. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60262. import { Scene } from "babylonjs/scene";
  60263. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60264. /**
  60265. * Defines a block that can be used inside a node based material
  60266. */
  60267. export class NodeMaterialBlock {
  60268. private _buildId;
  60269. private _buildTarget;
  60270. private _target;
  60271. private _isFinalMerger;
  60272. private _isInput;
  60273. protected _isUnique: boolean;
  60274. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60275. inputsAreExclusive: boolean;
  60276. /** @hidden */
  60277. _codeVariableName: string;
  60278. /** @hidden */
  60279. _inputs: NodeMaterialConnectionPoint[];
  60280. /** @hidden */
  60281. _outputs: NodeMaterialConnectionPoint[];
  60282. /** @hidden */
  60283. _preparationId: number;
  60284. /**
  60285. * Gets or sets the name of the block
  60286. */
  60287. name: string;
  60288. /**
  60289. * Gets or sets the unique id of the node
  60290. */
  60291. uniqueId: number;
  60292. /**
  60293. * Gets or sets the comments associated with this block
  60294. */
  60295. comments: string;
  60296. /**
  60297. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60298. */
  60299. get isUnique(): boolean;
  60300. /**
  60301. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60302. */
  60303. get isFinalMerger(): boolean;
  60304. /**
  60305. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60306. */
  60307. get isInput(): boolean;
  60308. /**
  60309. * Gets or sets the build Id
  60310. */
  60311. get buildId(): number;
  60312. set buildId(value: number);
  60313. /**
  60314. * Gets or sets the target of the block
  60315. */
  60316. get target(): NodeMaterialBlockTargets;
  60317. set target(value: NodeMaterialBlockTargets);
  60318. /**
  60319. * Gets the list of input points
  60320. */
  60321. get inputs(): NodeMaterialConnectionPoint[];
  60322. /** Gets the list of output points */
  60323. get outputs(): NodeMaterialConnectionPoint[];
  60324. /**
  60325. * Find an input by its name
  60326. * @param name defines the name of the input to look for
  60327. * @returns the input or null if not found
  60328. */
  60329. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60330. /**
  60331. * Find an output by its name
  60332. * @param name defines the name of the outputto look for
  60333. * @returns the output or null if not found
  60334. */
  60335. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60336. /**
  60337. * Creates a new NodeMaterialBlock
  60338. * @param name defines the block name
  60339. * @param target defines the target of that block (Vertex by default)
  60340. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60341. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60342. */
  60343. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60344. /**
  60345. * Initialize the block and prepare the context for build
  60346. * @param state defines the state that will be used for the build
  60347. */
  60348. initialize(state: NodeMaterialBuildState): void;
  60349. /**
  60350. * Bind data to effect. Will only be called for blocks with isBindable === true
  60351. * @param effect defines the effect to bind data to
  60352. * @param nodeMaterial defines the hosting NodeMaterial
  60353. * @param mesh defines the mesh that will be rendered
  60354. */
  60355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60356. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60357. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60358. protected _writeFloat(value: number): string;
  60359. /**
  60360. * Gets the current class name e.g. "NodeMaterialBlock"
  60361. * @returns the class name
  60362. */
  60363. getClassName(): string;
  60364. /**
  60365. * Register a new input. Must be called inside a block constructor
  60366. * @param name defines the connection point name
  60367. * @param type defines the connection point type
  60368. * @param isOptional defines a boolean indicating that this input can be omitted
  60369. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60370. * @returns the current block
  60371. */
  60372. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60373. /**
  60374. * Register a new output. Must be called inside a block constructor
  60375. * @param name defines the connection point name
  60376. * @param type defines the connection point type
  60377. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60378. * @returns the current block
  60379. */
  60380. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60381. /**
  60382. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60383. * @param forOutput defines an optional connection point to check compatibility with
  60384. * @returns the first available input or null
  60385. */
  60386. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60387. /**
  60388. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60389. * @param forBlock defines an optional block to check compatibility with
  60390. * @returns the first available input or null
  60391. */
  60392. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60393. /**
  60394. * Gets the sibling of the given output
  60395. * @param current defines the current output
  60396. * @returns the next output in the list or null
  60397. */
  60398. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60399. /**
  60400. * Connect current block with another block
  60401. * @param other defines the block to connect with
  60402. * @param options define the various options to help pick the right connections
  60403. * @returns the current block
  60404. */
  60405. connectTo(other: NodeMaterialBlock, options?: {
  60406. input?: string;
  60407. output?: string;
  60408. outputSwizzle?: string;
  60409. }): this | undefined;
  60410. protected _buildBlock(state: NodeMaterialBuildState): void;
  60411. /**
  60412. * Add uniforms, samplers and uniform buffers at compilation time
  60413. * @param state defines the state to update
  60414. * @param nodeMaterial defines the node material requesting the update
  60415. * @param defines defines the material defines to update
  60416. * @param uniformBuffers defines the list of uniform buffer names
  60417. */
  60418. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60419. /**
  60420. * Add potential fallbacks if shader compilation fails
  60421. * @param mesh defines the mesh to be rendered
  60422. * @param fallbacks defines the current prioritized list of fallbacks
  60423. */
  60424. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60425. /**
  60426. * Initialize defines for shader compilation
  60427. * @param mesh defines the mesh to be rendered
  60428. * @param nodeMaterial defines the node material requesting the update
  60429. * @param defines defines the material defines to update
  60430. * @param useInstances specifies that instances should be used
  60431. */
  60432. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60433. /**
  60434. * Update defines for shader compilation
  60435. * @param mesh defines the mesh to be rendered
  60436. * @param nodeMaterial defines the node material requesting the update
  60437. * @param defines defines the material defines to update
  60438. * @param useInstances specifies that instances should be used
  60439. */
  60440. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60441. /**
  60442. * Lets the block try to connect some inputs automatically
  60443. * @param material defines the hosting NodeMaterial
  60444. */
  60445. autoConfigure(material: NodeMaterial): void;
  60446. /**
  60447. * Function called when a block is declared as repeatable content generator
  60448. * @param vertexShaderState defines the current compilation state for the vertex shader
  60449. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60450. * @param mesh defines the mesh to be rendered
  60451. * @param defines defines the material defines to update
  60452. */
  60453. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60454. /**
  60455. * Checks if the block is ready
  60456. * @param mesh defines the mesh to be rendered
  60457. * @param nodeMaterial defines the node material requesting the update
  60458. * @param defines defines the material defines to update
  60459. * @param useInstances specifies that instances should be used
  60460. * @returns true if the block is ready
  60461. */
  60462. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60463. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60464. private _processBuild;
  60465. /**
  60466. * Compile the current node and generate the shader code
  60467. * @param state defines the current compilation state (uniforms, samplers, current string)
  60468. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60469. * @returns true if already built
  60470. */
  60471. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60472. protected _inputRename(name: string): string;
  60473. protected _outputRename(name: string): string;
  60474. protected _dumpPropertiesCode(): string;
  60475. /** @hidden */
  60476. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60477. /** @hidden */
  60478. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60479. /**
  60480. * Clone the current block to a new identical block
  60481. * @param scene defines the hosting scene
  60482. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60483. * @returns a copy of the current block
  60484. */
  60485. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60486. /**
  60487. * Serializes this block in a JSON representation
  60488. * @returns the serialized block object
  60489. */
  60490. serialize(): any;
  60491. /** @hidden */
  60492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60493. /**
  60494. * Release resources
  60495. */
  60496. dispose(): void;
  60497. }
  60498. }
  60499. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60500. /**
  60501. * Enum defining the type of animations supported by InputBlock
  60502. */
  60503. export enum AnimatedInputBlockTypes {
  60504. /** No animation */
  60505. None = 0,
  60506. /** Time based animation. Will only work for floats */
  60507. Time = 1
  60508. }
  60509. }
  60510. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60512. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60513. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60514. import { Nullable } from "babylonjs/types";
  60515. import { Effect } from "babylonjs/Materials/effect";
  60516. import { Matrix } from "babylonjs/Maths/math.vector";
  60517. import { Scene } from "babylonjs/scene";
  60518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60520. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60521. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60522. /**
  60523. * Block used to expose an input value
  60524. */
  60525. export class InputBlock extends NodeMaterialBlock {
  60526. private _mode;
  60527. private _associatedVariableName;
  60528. private _storedValue;
  60529. private _valueCallback;
  60530. private _type;
  60531. private _animationType;
  60532. /** Gets or set a value used to limit the range of float values */
  60533. min: number;
  60534. /** Gets or set a value used to limit the range of float values */
  60535. max: number;
  60536. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60537. isBoolean: boolean;
  60538. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60539. matrixMode: number;
  60540. /** @hidden */
  60541. _systemValue: Nullable<NodeMaterialSystemValues>;
  60542. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60543. visibleInInspector: boolean;
  60544. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60545. isConstant: boolean;
  60546. /** Gets or sets the group to use to display this block in the Inspector */
  60547. groupInInspector: string;
  60548. /**
  60549. * Gets or sets the connection point type (default is float)
  60550. */
  60551. get type(): NodeMaterialBlockConnectionPointTypes;
  60552. /**
  60553. * Creates a new InputBlock
  60554. * @param name defines the block name
  60555. * @param target defines the target of that block (Vertex by default)
  60556. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60557. */
  60558. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60559. /**
  60560. * Gets the output component
  60561. */
  60562. get output(): NodeMaterialConnectionPoint;
  60563. /**
  60564. * Set the source of this connection point to a vertex attribute
  60565. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60566. * @returns the current connection point
  60567. */
  60568. setAsAttribute(attributeName?: string): InputBlock;
  60569. /**
  60570. * Set the source of this connection point to a system value
  60571. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60572. * @returns the current connection point
  60573. */
  60574. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60575. /**
  60576. * Gets or sets the value of that point.
  60577. * Please note that this value will be ignored if valueCallback is defined
  60578. */
  60579. get value(): any;
  60580. set value(value: any);
  60581. /**
  60582. * Gets or sets a callback used to get the value of that point.
  60583. * Please note that setting this value will force the connection point to ignore the value property
  60584. */
  60585. get valueCallback(): () => any;
  60586. set valueCallback(value: () => any);
  60587. /**
  60588. * Gets or sets the associated variable name in the shader
  60589. */
  60590. get associatedVariableName(): string;
  60591. set associatedVariableName(value: string);
  60592. /** Gets or sets the type of animation applied to the input */
  60593. get animationType(): AnimatedInputBlockTypes;
  60594. set animationType(value: AnimatedInputBlockTypes);
  60595. /**
  60596. * Gets a boolean indicating that this connection point not defined yet
  60597. */
  60598. get isUndefined(): boolean;
  60599. /**
  60600. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60601. * In this case the connection point name must be the name of the uniform to use.
  60602. * Can only be set on inputs
  60603. */
  60604. get isUniform(): boolean;
  60605. set isUniform(value: boolean);
  60606. /**
  60607. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60608. * In this case the connection point name must be the name of the attribute to use
  60609. * Can only be set on inputs
  60610. */
  60611. get isAttribute(): boolean;
  60612. set isAttribute(value: boolean);
  60613. /**
  60614. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60615. * Can only be set on exit points
  60616. */
  60617. get isVarying(): boolean;
  60618. set isVarying(value: boolean);
  60619. /**
  60620. * Gets a boolean indicating that the current connection point is a system value
  60621. */
  60622. get isSystemValue(): boolean;
  60623. /**
  60624. * Gets or sets the current well known value or null if not defined as a system value
  60625. */
  60626. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60627. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60628. /**
  60629. * Gets the current class name
  60630. * @returns the class name
  60631. */
  60632. getClassName(): string;
  60633. /**
  60634. * Animate the input if animationType !== None
  60635. * @param scene defines the rendering scene
  60636. */
  60637. animate(scene: Scene): void;
  60638. private _emitDefine;
  60639. initialize(state: NodeMaterialBuildState): void;
  60640. /**
  60641. * Set the input block to its default value (based on its type)
  60642. */
  60643. setDefaultValue(): void;
  60644. private _emitConstant;
  60645. private _emit;
  60646. /** @hidden */
  60647. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60648. /** @hidden */
  60649. _transmit(effect: Effect, scene: Scene): void;
  60650. protected _buildBlock(state: NodeMaterialBuildState): void;
  60651. protected _dumpPropertiesCode(): string;
  60652. serialize(): any;
  60653. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60654. }
  60655. }
  60656. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60657. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60658. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60659. import { Nullable } from "babylonjs/types";
  60660. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60661. import { Observable } from "babylonjs/Misc/observable";
  60662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60663. /**
  60664. * Enum used to define the compatibility state between two connection points
  60665. */
  60666. export enum NodeMaterialConnectionPointCompatibilityStates {
  60667. /** Points are compatibles */
  60668. Compatible = 0,
  60669. /** Points are incompatible because of their types */
  60670. TypeIncompatible = 1,
  60671. /** Points are incompatible because of their targets (vertex vs fragment) */
  60672. TargetIncompatible = 2
  60673. }
  60674. /**
  60675. * Defines the direction of a connection point
  60676. */
  60677. export enum NodeMaterialConnectionPointDirection {
  60678. /** Input */
  60679. Input = 0,
  60680. /** Output */
  60681. Output = 1
  60682. }
  60683. /**
  60684. * Defines a connection point for a block
  60685. */
  60686. export class NodeMaterialConnectionPoint {
  60687. /** @hidden */
  60688. _ownerBlock: NodeMaterialBlock;
  60689. /** @hidden */
  60690. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60691. private _endpoints;
  60692. private _associatedVariableName;
  60693. private _direction;
  60694. /** @hidden */
  60695. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60696. /** @hidden */
  60697. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60698. private _type;
  60699. /** @hidden */
  60700. _enforceAssociatedVariableName: boolean;
  60701. /** Gets the direction of the point */
  60702. get direction(): NodeMaterialConnectionPointDirection;
  60703. /**
  60704. * Gets or sets the additional types supported by this connection point
  60705. */
  60706. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60707. /**
  60708. * Gets or sets the additional types excluded by this connection point
  60709. */
  60710. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60711. /**
  60712. * Observable triggered when this point is connected
  60713. */
  60714. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60715. /**
  60716. * Gets or sets the associated variable name in the shader
  60717. */
  60718. get associatedVariableName(): string;
  60719. set associatedVariableName(value: string);
  60720. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60721. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60722. /**
  60723. * Gets or sets the connection point type (default is float)
  60724. */
  60725. get type(): NodeMaterialBlockConnectionPointTypes;
  60726. set type(value: NodeMaterialBlockConnectionPointTypes);
  60727. /**
  60728. * Gets or sets the connection point name
  60729. */
  60730. name: string;
  60731. /**
  60732. * Gets or sets a boolean indicating that this connection point can be omitted
  60733. */
  60734. isOptional: boolean;
  60735. /**
  60736. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60737. */
  60738. define: string;
  60739. /** @hidden */
  60740. _prioritizeVertex: boolean;
  60741. private _target;
  60742. /** Gets or sets the target of that connection point */
  60743. get target(): NodeMaterialBlockTargets;
  60744. set target(value: NodeMaterialBlockTargets);
  60745. /**
  60746. * Gets a boolean indicating that the current point is connected
  60747. */
  60748. get isConnected(): boolean;
  60749. /**
  60750. * Gets a boolean indicating that the current point is connected to an input block
  60751. */
  60752. get isConnectedToInputBlock(): boolean;
  60753. /**
  60754. * Gets a the connected input block (if any)
  60755. */
  60756. get connectInputBlock(): Nullable<InputBlock>;
  60757. /** Get the other side of the connection (if any) */
  60758. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60759. /** Get the block that owns this connection point */
  60760. get ownerBlock(): NodeMaterialBlock;
  60761. /** Get the block connected on the other side of this connection (if any) */
  60762. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60763. /** Get the block connected on the endpoints of this connection (if any) */
  60764. get connectedBlocks(): Array<NodeMaterialBlock>;
  60765. /** Gets the list of connected endpoints */
  60766. get endpoints(): NodeMaterialConnectionPoint[];
  60767. /** Gets a boolean indicating if that output point is connected to at least one input */
  60768. get hasEndpoints(): boolean;
  60769. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60770. get isConnectedInVertexShader(): boolean;
  60771. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60772. get isConnectedInFragmentShader(): boolean;
  60773. /**
  60774. * Creates a new connection point
  60775. * @param name defines the connection point name
  60776. * @param ownerBlock defines the block hosting this connection point
  60777. * @param direction defines the direction of the connection point
  60778. */
  60779. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60780. /**
  60781. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60782. * @returns the class name
  60783. */
  60784. getClassName(): string;
  60785. /**
  60786. * Gets a boolean indicating if the current point can be connected to another point
  60787. * @param connectionPoint defines the other connection point
  60788. * @returns a boolean
  60789. */
  60790. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60791. /**
  60792. * Gets a number indicating if the current point can be connected to another point
  60793. * @param connectionPoint defines the other connection point
  60794. * @returns a number defining the compatibility state
  60795. */
  60796. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60797. /**
  60798. * Connect this point to another connection point
  60799. * @param connectionPoint defines the other connection point
  60800. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60801. * @returns the current connection point
  60802. */
  60803. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Disconnect this point from one of his endpoint
  60806. * @param endpoint defines the other connection point
  60807. * @returns the current connection point
  60808. */
  60809. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60810. /**
  60811. * Serializes this point in a JSON representation
  60812. * @returns the serialized point object
  60813. */
  60814. serialize(): any;
  60815. /**
  60816. * Release resources
  60817. */
  60818. dispose(): void;
  60819. }
  60820. }
  60821. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60825. import { Mesh } from "babylonjs/Meshes/mesh";
  60826. import { Effect } from "babylonjs/Materials/effect";
  60827. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60828. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60829. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60830. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60831. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60832. /**
  60833. * Block used to add support for vertex skinning (bones)
  60834. */
  60835. export class BonesBlock extends NodeMaterialBlock {
  60836. /**
  60837. * Creates a new BonesBlock
  60838. * @param name defines the block name
  60839. */
  60840. constructor(name: string);
  60841. /**
  60842. * Initialize the block and prepare the context for build
  60843. * @param state defines the state that will be used for the build
  60844. */
  60845. initialize(state: NodeMaterialBuildState): void;
  60846. /**
  60847. * Gets the current class name
  60848. * @returns the class name
  60849. */
  60850. getClassName(): string;
  60851. /**
  60852. * Gets the matrix indices input component
  60853. */
  60854. get matricesIndices(): NodeMaterialConnectionPoint;
  60855. /**
  60856. * Gets the matrix weights input component
  60857. */
  60858. get matricesWeights(): NodeMaterialConnectionPoint;
  60859. /**
  60860. * Gets the extra matrix indices input component
  60861. */
  60862. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60863. /**
  60864. * Gets the extra matrix weights input component
  60865. */
  60866. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the world input component
  60869. */
  60870. get world(): NodeMaterialConnectionPoint;
  60871. /**
  60872. * Gets the output component
  60873. */
  60874. get output(): NodeMaterialConnectionPoint;
  60875. autoConfigure(material: NodeMaterial): void;
  60876. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60878. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60879. protected _buildBlock(state: NodeMaterialBuildState): this;
  60880. }
  60881. }
  60882. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60883. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60884. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60887. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60888. /**
  60889. * Block used to add support for instances
  60890. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60891. */
  60892. export class InstancesBlock extends NodeMaterialBlock {
  60893. /**
  60894. * Creates a new InstancesBlock
  60895. * @param name defines the block name
  60896. */
  60897. constructor(name: string);
  60898. /**
  60899. * Gets the current class name
  60900. * @returns the class name
  60901. */
  60902. getClassName(): string;
  60903. /**
  60904. * Gets the first world row input component
  60905. */
  60906. get world0(): NodeMaterialConnectionPoint;
  60907. /**
  60908. * Gets the second world row input component
  60909. */
  60910. get world1(): NodeMaterialConnectionPoint;
  60911. /**
  60912. * Gets the third world row input component
  60913. */
  60914. get world2(): NodeMaterialConnectionPoint;
  60915. /**
  60916. * Gets the forth world row input component
  60917. */
  60918. get world3(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the world input component
  60921. */
  60922. get world(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the output component
  60925. */
  60926. get output(): NodeMaterialConnectionPoint;
  60927. /**
  60928. * Gets the isntanceID component
  60929. */
  60930. get instanceID(): NodeMaterialConnectionPoint;
  60931. autoConfigure(material: NodeMaterial): void;
  60932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60933. protected _buildBlock(state: NodeMaterialBuildState): this;
  60934. }
  60935. }
  60936. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60939. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60941. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60942. import { Effect } from "babylonjs/Materials/effect";
  60943. import { Mesh } from "babylonjs/Meshes/mesh";
  60944. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60946. /**
  60947. * Block used to add morph targets support to vertex shader
  60948. */
  60949. export class MorphTargetsBlock extends NodeMaterialBlock {
  60950. private _repeatableContentAnchor;
  60951. /**
  60952. * Create a new MorphTargetsBlock
  60953. * @param name defines the block name
  60954. */
  60955. constructor(name: string);
  60956. /**
  60957. * Gets the current class name
  60958. * @returns the class name
  60959. */
  60960. getClassName(): string;
  60961. /**
  60962. * Gets the position input component
  60963. */
  60964. get position(): NodeMaterialConnectionPoint;
  60965. /**
  60966. * Gets the normal input component
  60967. */
  60968. get normal(): NodeMaterialConnectionPoint;
  60969. /**
  60970. * Gets the tangent input component
  60971. */
  60972. get tangent(): NodeMaterialConnectionPoint;
  60973. /**
  60974. * Gets the tangent input component
  60975. */
  60976. get uv(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the position output component
  60979. */
  60980. get positionOutput(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the normal output component
  60983. */
  60984. get normalOutput(): NodeMaterialConnectionPoint;
  60985. /**
  60986. * Gets the tangent output component
  60987. */
  60988. get tangentOutput(): NodeMaterialConnectionPoint;
  60989. /**
  60990. * Gets the tangent output component
  60991. */
  60992. get uvOutput(): NodeMaterialConnectionPoint;
  60993. initialize(state: NodeMaterialBuildState): void;
  60994. autoConfigure(material: NodeMaterial): void;
  60995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60997. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60998. protected _buildBlock(state: NodeMaterialBuildState): this;
  60999. }
  61000. }
  61001. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61005. import { Nullable } from "babylonjs/types";
  61006. import { Scene } from "babylonjs/scene";
  61007. import { Effect } from "babylonjs/Materials/effect";
  61008. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61009. import { Mesh } from "babylonjs/Meshes/mesh";
  61010. import { Light } from "babylonjs/Lights/light";
  61011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61012. /**
  61013. * Block used to get data information from a light
  61014. */
  61015. export class LightInformationBlock extends NodeMaterialBlock {
  61016. private _lightDataUniformName;
  61017. private _lightColorUniformName;
  61018. private _lightTypeDefineName;
  61019. /**
  61020. * Gets or sets the light associated with this block
  61021. */
  61022. light: Nullable<Light>;
  61023. /**
  61024. * Creates a new LightInformationBlock
  61025. * @param name defines the block name
  61026. */
  61027. constructor(name: string);
  61028. /**
  61029. * Gets the current class name
  61030. * @returns the class name
  61031. */
  61032. getClassName(): string;
  61033. /**
  61034. * Gets the world position input component
  61035. */
  61036. get worldPosition(): NodeMaterialConnectionPoint;
  61037. /**
  61038. * Gets the direction output component
  61039. */
  61040. get direction(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the direction output component
  61043. */
  61044. get color(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Gets the direction output component
  61047. */
  61048. get intensity(): NodeMaterialConnectionPoint;
  61049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61051. protected _buildBlock(state: NodeMaterialBuildState): this;
  61052. serialize(): any;
  61053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61054. }
  61055. }
  61056. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61057. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61058. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61059. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61060. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61061. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61062. }
  61063. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61068. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61069. import { Effect } from "babylonjs/Materials/effect";
  61070. import { Mesh } from "babylonjs/Meshes/mesh";
  61071. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61072. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61073. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61074. /**
  61075. * Block used to add image processing support to fragment shader
  61076. */
  61077. export class ImageProcessingBlock extends NodeMaterialBlock {
  61078. /**
  61079. * Create a new ImageProcessingBlock
  61080. * @param name defines the block name
  61081. */
  61082. constructor(name: string);
  61083. /**
  61084. * Gets the current class name
  61085. * @returns the class name
  61086. */
  61087. getClassName(): string;
  61088. /**
  61089. * Gets the color input component
  61090. */
  61091. get color(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the output component
  61094. */
  61095. get output(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Initialize the block and prepare the context for build
  61098. * @param state defines the state that will be used for the build
  61099. */
  61100. initialize(state: NodeMaterialBuildState): void;
  61101. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61102. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61104. protected _buildBlock(state: NodeMaterialBuildState): this;
  61105. }
  61106. }
  61107. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61111. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61113. import { Effect } from "babylonjs/Materials/effect";
  61114. import { Mesh } from "babylonjs/Meshes/mesh";
  61115. import { Scene } from "babylonjs/scene";
  61116. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61117. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61118. /**
  61119. * Block used to pertub normals based on a normal map
  61120. */
  61121. export class PerturbNormalBlock extends NodeMaterialBlock {
  61122. private _tangentSpaceParameterName;
  61123. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61124. invertX: boolean;
  61125. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61126. invertY: boolean;
  61127. /**
  61128. * Create a new PerturbNormalBlock
  61129. * @param name defines the block name
  61130. */
  61131. constructor(name: string);
  61132. /**
  61133. * Gets the current class name
  61134. * @returns the class name
  61135. */
  61136. getClassName(): string;
  61137. /**
  61138. * Gets the world position input component
  61139. */
  61140. get worldPosition(): NodeMaterialConnectionPoint;
  61141. /**
  61142. * Gets the world normal input component
  61143. */
  61144. get worldNormal(): NodeMaterialConnectionPoint;
  61145. /**
  61146. * Gets the world tangent input component
  61147. */
  61148. get worldTangent(): NodeMaterialConnectionPoint;
  61149. /**
  61150. * Gets the uv input component
  61151. */
  61152. get uv(): NodeMaterialConnectionPoint;
  61153. /**
  61154. * Gets the normal map color input component
  61155. */
  61156. get normalMapColor(): NodeMaterialConnectionPoint;
  61157. /**
  61158. * Gets the strength input component
  61159. */
  61160. get strength(): NodeMaterialConnectionPoint;
  61161. /**
  61162. * Gets the output component
  61163. */
  61164. get output(): NodeMaterialConnectionPoint;
  61165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61167. autoConfigure(material: NodeMaterial): void;
  61168. protected _buildBlock(state: NodeMaterialBuildState): this;
  61169. protected _dumpPropertiesCode(): string;
  61170. serialize(): any;
  61171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61172. }
  61173. }
  61174. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61178. /**
  61179. * Block used to discard a pixel if a value is smaller than a cutoff
  61180. */
  61181. export class DiscardBlock extends NodeMaterialBlock {
  61182. /**
  61183. * Create a new DiscardBlock
  61184. * @param name defines the block name
  61185. */
  61186. constructor(name: string);
  61187. /**
  61188. * Gets the current class name
  61189. * @returns the class name
  61190. */
  61191. getClassName(): string;
  61192. /**
  61193. * Gets the color input component
  61194. */
  61195. get value(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Gets the cutoff input component
  61198. */
  61199. get cutoff(): NodeMaterialConnectionPoint;
  61200. protected _buildBlock(state: NodeMaterialBuildState): this;
  61201. }
  61202. }
  61203. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61207. /**
  61208. * Block used to test if the fragment shader is front facing
  61209. */
  61210. export class FrontFacingBlock extends NodeMaterialBlock {
  61211. /**
  61212. * Creates a new FrontFacingBlock
  61213. * @param name defines the block name
  61214. */
  61215. constructor(name: string);
  61216. /**
  61217. * Gets the current class name
  61218. * @returns the class name
  61219. */
  61220. getClassName(): string;
  61221. /**
  61222. * Gets the output component
  61223. */
  61224. get output(): NodeMaterialConnectionPoint;
  61225. protected _buildBlock(state: NodeMaterialBuildState): this;
  61226. }
  61227. }
  61228. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61232. /**
  61233. * Block used to get the derivative value on x and y of a given input
  61234. */
  61235. export class DerivativeBlock extends NodeMaterialBlock {
  61236. /**
  61237. * Create a new DerivativeBlock
  61238. * @param name defines the block name
  61239. */
  61240. constructor(name: string);
  61241. /**
  61242. * Gets the current class name
  61243. * @returns the class name
  61244. */
  61245. getClassName(): string;
  61246. /**
  61247. * Gets the input component
  61248. */
  61249. get input(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the derivative output on x
  61252. */
  61253. get dx(): NodeMaterialConnectionPoint;
  61254. /**
  61255. * Gets the derivative output on y
  61256. */
  61257. get dy(): NodeMaterialConnectionPoint;
  61258. protected _buildBlock(state: NodeMaterialBuildState): this;
  61259. }
  61260. }
  61261. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61262. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61263. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61264. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61265. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61266. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61267. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61268. }
  61269. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61272. import { Mesh } from "babylonjs/Meshes/mesh";
  61273. import { Effect } from "babylonjs/Materials/effect";
  61274. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61276. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61277. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61278. /**
  61279. * Block used to add support for scene fog
  61280. */
  61281. export class FogBlock extends NodeMaterialBlock {
  61282. private _fogDistanceName;
  61283. private _fogParameters;
  61284. /**
  61285. * Create a new FogBlock
  61286. * @param name defines the block name
  61287. */
  61288. constructor(name: string);
  61289. /**
  61290. * Gets the current class name
  61291. * @returns the class name
  61292. */
  61293. getClassName(): string;
  61294. /**
  61295. * Gets the world position input component
  61296. */
  61297. get worldPosition(): NodeMaterialConnectionPoint;
  61298. /**
  61299. * Gets the view input component
  61300. */
  61301. get view(): NodeMaterialConnectionPoint;
  61302. /**
  61303. * Gets the color input component
  61304. */
  61305. get input(): NodeMaterialConnectionPoint;
  61306. /**
  61307. * Gets the fog color input component
  61308. */
  61309. get fogColor(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the output component
  61312. */
  61313. get output(): NodeMaterialConnectionPoint;
  61314. autoConfigure(material: NodeMaterial): void;
  61315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61316. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61317. protected _buildBlock(state: NodeMaterialBuildState): this;
  61318. }
  61319. }
  61320. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61325. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61326. import { Effect } from "babylonjs/Materials/effect";
  61327. import { Mesh } from "babylonjs/Meshes/mesh";
  61328. import { Light } from "babylonjs/Lights/light";
  61329. import { Nullable } from "babylonjs/types";
  61330. import { Scene } from "babylonjs/scene";
  61331. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61332. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61333. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61334. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61335. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61336. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61337. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61338. /**
  61339. * Block used to add light in the fragment shader
  61340. */
  61341. export class LightBlock extends NodeMaterialBlock {
  61342. private _lightId;
  61343. /**
  61344. * Gets or sets the light associated with this block
  61345. */
  61346. light: Nullable<Light>;
  61347. /**
  61348. * Create a new LightBlock
  61349. * @param name defines the block name
  61350. */
  61351. constructor(name: string);
  61352. /**
  61353. * Gets the current class name
  61354. * @returns the class name
  61355. */
  61356. getClassName(): string;
  61357. /**
  61358. * Gets the world position input component
  61359. */
  61360. get worldPosition(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the world normal input component
  61363. */
  61364. get worldNormal(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the camera (or eye) position component
  61367. */
  61368. get cameraPosition(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the glossiness component
  61371. */
  61372. get glossiness(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the glossinness power component
  61375. */
  61376. get glossPower(): NodeMaterialConnectionPoint;
  61377. /**
  61378. * Gets the diffuse color component
  61379. */
  61380. get diffuseColor(): NodeMaterialConnectionPoint;
  61381. /**
  61382. * Gets the specular color component
  61383. */
  61384. get specularColor(): NodeMaterialConnectionPoint;
  61385. /**
  61386. * Gets the diffuse output component
  61387. */
  61388. get diffuseOutput(): NodeMaterialConnectionPoint;
  61389. /**
  61390. * Gets the specular output component
  61391. */
  61392. get specularOutput(): NodeMaterialConnectionPoint;
  61393. /**
  61394. * Gets the shadow output component
  61395. */
  61396. get shadow(): NodeMaterialConnectionPoint;
  61397. autoConfigure(material: NodeMaterial): void;
  61398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61399. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61400. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61401. private _injectVertexCode;
  61402. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61403. serialize(): any;
  61404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61405. }
  61406. }
  61407. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61408. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61409. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61410. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61411. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61412. }
  61413. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61414. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61415. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61416. }
  61417. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61418. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61419. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61420. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61421. /**
  61422. * Block used to multiply 2 values
  61423. */
  61424. export class MultiplyBlock extends NodeMaterialBlock {
  61425. /**
  61426. * Creates a new MultiplyBlock
  61427. * @param name defines the block name
  61428. */
  61429. constructor(name: string);
  61430. /**
  61431. * Gets the current class name
  61432. * @returns the class name
  61433. */
  61434. getClassName(): string;
  61435. /**
  61436. * Gets the left operand input component
  61437. */
  61438. get left(): NodeMaterialConnectionPoint;
  61439. /**
  61440. * Gets the right operand input component
  61441. */
  61442. get right(): NodeMaterialConnectionPoint;
  61443. /**
  61444. * Gets the output component
  61445. */
  61446. get output(): NodeMaterialConnectionPoint;
  61447. protected _buildBlock(state: NodeMaterialBuildState): this;
  61448. }
  61449. }
  61450. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61451. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61452. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61454. /**
  61455. * Block used to add 2 vectors
  61456. */
  61457. export class AddBlock extends NodeMaterialBlock {
  61458. /**
  61459. * Creates a new AddBlock
  61460. * @param name defines the block name
  61461. */
  61462. constructor(name: string);
  61463. /**
  61464. * Gets the current class name
  61465. * @returns the class name
  61466. */
  61467. getClassName(): string;
  61468. /**
  61469. * Gets the left operand input component
  61470. */
  61471. get left(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the right operand input component
  61474. */
  61475. get right(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the output component
  61478. */
  61479. get output(): NodeMaterialConnectionPoint;
  61480. protected _buildBlock(state: NodeMaterialBuildState): this;
  61481. }
  61482. }
  61483. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61485. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61486. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61487. /**
  61488. * Block used to scale a vector by a float
  61489. */
  61490. export class ScaleBlock extends NodeMaterialBlock {
  61491. /**
  61492. * Creates a new ScaleBlock
  61493. * @param name defines the block name
  61494. */
  61495. constructor(name: string);
  61496. /**
  61497. * Gets the current class name
  61498. * @returns the class name
  61499. */
  61500. getClassName(): string;
  61501. /**
  61502. * Gets the input component
  61503. */
  61504. get input(): NodeMaterialConnectionPoint;
  61505. /**
  61506. * Gets the factor input component
  61507. */
  61508. get factor(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the output component
  61511. */
  61512. get output(): NodeMaterialConnectionPoint;
  61513. protected _buildBlock(state: NodeMaterialBuildState): this;
  61514. }
  61515. }
  61516. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61520. import { Scene } from "babylonjs/scene";
  61521. /**
  61522. * Block used to clamp a float
  61523. */
  61524. export class ClampBlock extends NodeMaterialBlock {
  61525. /** Gets or sets the minimum range */
  61526. minimum: number;
  61527. /** Gets or sets the maximum range */
  61528. maximum: number;
  61529. /**
  61530. * Creates a new ClampBlock
  61531. * @param name defines the block name
  61532. */
  61533. constructor(name: string);
  61534. /**
  61535. * Gets the current class name
  61536. * @returns the class name
  61537. */
  61538. getClassName(): string;
  61539. /**
  61540. * Gets the value input component
  61541. */
  61542. get value(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the output component
  61545. */
  61546. get output(): NodeMaterialConnectionPoint;
  61547. protected _buildBlock(state: NodeMaterialBuildState): this;
  61548. protected _dumpPropertiesCode(): string;
  61549. serialize(): any;
  61550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61551. }
  61552. }
  61553. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61557. /**
  61558. * Block used to apply a cross product between 2 vectors
  61559. */
  61560. export class CrossBlock extends NodeMaterialBlock {
  61561. /**
  61562. * Creates a new CrossBlock
  61563. * @param name defines the block name
  61564. */
  61565. constructor(name: string);
  61566. /**
  61567. * Gets the current class name
  61568. * @returns the class name
  61569. */
  61570. getClassName(): string;
  61571. /**
  61572. * Gets the left operand input component
  61573. */
  61574. get left(): NodeMaterialConnectionPoint;
  61575. /**
  61576. * Gets the right operand input component
  61577. */
  61578. get right(): NodeMaterialConnectionPoint;
  61579. /**
  61580. * Gets the output component
  61581. */
  61582. get output(): NodeMaterialConnectionPoint;
  61583. protected _buildBlock(state: NodeMaterialBuildState): this;
  61584. }
  61585. }
  61586. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61590. /**
  61591. * Block used to apply a dot product between 2 vectors
  61592. */
  61593. export class DotBlock extends NodeMaterialBlock {
  61594. /**
  61595. * Creates a new DotBlock
  61596. * @param name defines the block name
  61597. */
  61598. constructor(name: string);
  61599. /**
  61600. * Gets the current class name
  61601. * @returns the class name
  61602. */
  61603. getClassName(): string;
  61604. /**
  61605. * Gets the left operand input component
  61606. */
  61607. get left(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Gets the right operand input component
  61610. */
  61611. get right(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the output component
  61614. */
  61615. get output(): NodeMaterialConnectionPoint;
  61616. protected _buildBlock(state: NodeMaterialBuildState): this;
  61617. }
  61618. }
  61619. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61623. import { Vector2 } from "babylonjs/Maths/math.vector";
  61624. import { Scene } from "babylonjs/scene";
  61625. /**
  61626. * Block used to remap a float from a range to a new one
  61627. */
  61628. export class RemapBlock extends NodeMaterialBlock {
  61629. /**
  61630. * Gets or sets the source range
  61631. */
  61632. sourceRange: Vector2;
  61633. /**
  61634. * Gets or sets the target range
  61635. */
  61636. targetRange: Vector2;
  61637. /**
  61638. * Creates a new RemapBlock
  61639. * @param name defines the block name
  61640. */
  61641. constructor(name: string);
  61642. /**
  61643. * Gets the current class name
  61644. * @returns the class name
  61645. */
  61646. getClassName(): string;
  61647. /**
  61648. * Gets the input component
  61649. */
  61650. get input(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the source min input component
  61653. */
  61654. get sourceMin(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the source max input component
  61657. */
  61658. get sourceMax(): NodeMaterialConnectionPoint;
  61659. /**
  61660. * Gets the target min input component
  61661. */
  61662. get targetMin(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the target max input component
  61665. */
  61666. get targetMax(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the output component
  61669. */
  61670. get output(): NodeMaterialConnectionPoint;
  61671. protected _buildBlock(state: NodeMaterialBuildState): this;
  61672. protected _dumpPropertiesCode(): string;
  61673. serialize(): any;
  61674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61675. }
  61676. }
  61677. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61681. /**
  61682. * Block used to normalize a vector
  61683. */
  61684. export class NormalizeBlock extends NodeMaterialBlock {
  61685. /**
  61686. * Creates a new NormalizeBlock
  61687. * @param name defines the block name
  61688. */
  61689. constructor(name: string);
  61690. /**
  61691. * Gets the current class name
  61692. * @returns the class name
  61693. */
  61694. getClassName(): string;
  61695. /**
  61696. * Gets the input component
  61697. */
  61698. get input(): NodeMaterialConnectionPoint;
  61699. /**
  61700. * Gets the output component
  61701. */
  61702. get output(): NodeMaterialConnectionPoint;
  61703. protected _buildBlock(state: NodeMaterialBuildState): this;
  61704. }
  61705. }
  61706. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61710. import { Scene } from "babylonjs/scene";
  61711. /**
  61712. * Operations supported by the Trigonometry block
  61713. */
  61714. export enum TrigonometryBlockOperations {
  61715. /** Cos */
  61716. Cos = 0,
  61717. /** Sin */
  61718. Sin = 1,
  61719. /** Abs */
  61720. Abs = 2,
  61721. /** Exp */
  61722. Exp = 3,
  61723. /** Exp2 */
  61724. Exp2 = 4,
  61725. /** Round */
  61726. Round = 5,
  61727. /** Floor */
  61728. Floor = 6,
  61729. /** Ceiling */
  61730. Ceiling = 7,
  61731. /** Square root */
  61732. Sqrt = 8,
  61733. /** Log */
  61734. Log = 9,
  61735. /** Tangent */
  61736. Tan = 10,
  61737. /** Arc tangent */
  61738. ArcTan = 11,
  61739. /** Arc cosinus */
  61740. ArcCos = 12,
  61741. /** Arc sinus */
  61742. ArcSin = 13,
  61743. /** Fraction */
  61744. Fract = 14,
  61745. /** Sign */
  61746. Sign = 15,
  61747. /** To radians (from degrees) */
  61748. Radians = 16,
  61749. /** To degrees (from radians) */
  61750. Degrees = 17
  61751. }
  61752. /**
  61753. * Block used to apply trigonometry operation to floats
  61754. */
  61755. export class TrigonometryBlock extends NodeMaterialBlock {
  61756. /**
  61757. * Gets or sets the operation applied by the block
  61758. */
  61759. operation: TrigonometryBlockOperations;
  61760. /**
  61761. * Creates a new TrigonometryBlock
  61762. * @param name defines the block name
  61763. */
  61764. constructor(name: string);
  61765. /**
  61766. * Gets the current class name
  61767. * @returns the class name
  61768. */
  61769. getClassName(): string;
  61770. /**
  61771. * Gets the input component
  61772. */
  61773. get input(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the output component
  61776. */
  61777. get output(): NodeMaterialConnectionPoint;
  61778. protected _buildBlock(state: NodeMaterialBuildState): this;
  61779. serialize(): any;
  61780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61781. protected _dumpPropertiesCode(): string;
  61782. }
  61783. }
  61784. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61785. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61786. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61787. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61788. /**
  61789. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61790. */
  61791. export class ColorMergerBlock extends NodeMaterialBlock {
  61792. /**
  61793. * Create a new ColorMergerBlock
  61794. * @param name defines the block name
  61795. */
  61796. constructor(name: string);
  61797. /**
  61798. * Gets the current class name
  61799. * @returns the class name
  61800. */
  61801. getClassName(): string;
  61802. /**
  61803. * Gets the rgb component (input)
  61804. */
  61805. get rgbIn(): NodeMaterialConnectionPoint;
  61806. /**
  61807. * Gets the r component (input)
  61808. */
  61809. get r(): NodeMaterialConnectionPoint;
  61810. /**
  61811. * Gets the g component (input)
  61812. */
  61813. get g(): NodeMaterialConnectionPoint;
  61814. /**
  61815. * Gets the b component (input)
  61816. */
  61817. get b(): NodeMaterialConnectionPoint;
  61818. /**
  61819. * Gets the a component (input)
  61820. */
  61821. get a(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the rgba component (output)
  61824. */
  61825. get rgba(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the rgb component (output)
  61828. */
  61829. get rgbOut(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the rgb component (output)
  61832. * @deprecated Please use rgbOut instead.
  61833. */
  61834. get rgb(): NodeMaterialConnectionPoint;
  61835. protected _buildBlock(state: NodeMaterialBuildState): this;
  61836. }
  61837. }
  61838. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61842. /**
  61843. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61844. */
  61845. export class VectorMergerBlock extends NodeMaterialBlock {
  61846. /**
  61847. * Create a new VectorMergerBlock
  61848. * @param name defines the block name
  61849. */
  61850. constructor(name: string);
  61851. /**
  61852. * Gets the current class name
  61853. * @returns the class name
  61854. */
  61855. getClassName(): string;
  61856. /**
  61857. * Gets the xyz component (input)
  61858. */
  61859. get xyzIn(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the xy component (input)
  61862. */
  61863. get xyIn(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the x component (input)
  61866. */
  61867. get x(): NodeMaterialConnectionPoint;
  61868. /**
  61869. * Gets the y component (input)
  61870. */
  61871. get y(): NodeMaterialConnectionPoint;
  61872. /**
  61873. * Gets the z component (input)
  61874. */
  61875. get z(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the w component (input)
  61878. */
  61879. get w(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the xyzw component (output)
  61882. */
  61883. get xyzw(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the xyz component (output)
  61886. */
  61887. get xyzOut(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the xy component (output)
  61890. */
  61891. get xyOut(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the xy component (output)
  61894. * @deprecated Please use xyOut instead.
  61895. */
  61896. get xy(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the xyz component (output)
  61899. * @deprecated Please use xyzOut instead.
  61900. */
  61901. get xyz(): NodeMaterialConnectionPoint;
  61902. protected _buildBlock(state: NodeMaterialBuildState): this;
  61903. }
  61904. }
  61905. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61909. /**
  61910. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61911. */
  61912. export class ColorSplitterBlock extends NodeMaterialBlock {
  61913. /**
  61914. * Create a new ColorSplitterBlock
  61915. * @param name defines the block name
  61916. */
  61917. constructor(name: string);
  61918. /**
  61919. * Gets the current class name
  61920. * @returns the class name
  61921. */
  61922. getClassName(): string;
  61923. /**
  61924. * Gets the rgba component (input)
  61925. */
  61926. get rgba(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the rgb component (input)
  61929. */
  61930. get rgbIn(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the rgb component (output)
  61933. */
  61934. get rgbOut(): NodeMaterialConnectionPoint;
  61935. /**
  61936. * Gets the r component (output)
  61937. */
  61938. get r(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the g component (output)
  61941. */
  61942. get g(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the b component (output)
  61945. */
  61946. get b(): NodeMaterialConnectionPoint;
  61947. /**
  61948. * Gets the a component (output)
  61949. */
  61950. get a(): NodeMaterialConnectionPoint;
  61951. protected _inputRename(name: string): string;
  61952. protected _outputRename(name: string): string;
  61953. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61954. }
  61955. }
  61956. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61960. /**
  61961. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61962. */
  61963. export class VectorSplitterBlock extends NodeMaterialBlock {
  61964. /**
  61965. * Create a new VectorSplitterBlock
  61966. * @param name defines the block name
  61967. */
  61968. constructor(name: string);
  61969. /**
  61970. * Gets the current class name
  61971. * @returns the class name
  61972. */
  61973. getClassName(): string;
  61974. /**
  61975. * Gets the xyzw component (input)
  61976. */
  61977. get xyzw(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the xyz component (input)
  61980. */
  61981. get xyzIn(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the xy component (input)
  61984. */
  61985. get xyIn(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the xyz component (output)
  61988. */
  61989. get xyzOut(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the xy component (output)
  61992. */
  61993. get xyOut(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the x component (output)
  61996. */
  61997. get x(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the y component (output)
  62000. */
  62001. get y(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the z component (output)
  62004. */
  62005. get z(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the w component (output)
  62008. */
  62009. get w(): NodeMaterialConnectionPoint;
  62010. protected _inputRename(name: string): string;
  62011. protected _outputRename(name: string): string;
  62012. protected _buildBlock(state: NodeMaterialBuildState): this;
  62013. }
  62014. }
  62015. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62017. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62019. /**
  62020. * Block used to lerp between 2 values
  62021. */
  62022. export class LerpBlock extends NodeMaterialBlock {
  62023. /**
  62024. * Creates a new LerpBlock
  62025. * @param name defines the block name
  62026. */
  62027. constructor(name: string);
  62028. /**
  62029. * Gets the current class name
  62030. * @returns the class name
  62031. */
  62032. getClassName(): string;
  62033. /**
  62034. * Gets the left operand input component
  62035. */
  62036. get left(): NodeMaterialConnectionPoint;
  62037. /**
  62038. * Gets the right operand input component
  62039. */
  62040. get right(): NodeMaterialConnectionPoint;
  62041. /**
  62042. * Gets the gradient operand input component
  62043. */
  62044. get gradient(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the output component
  62047. */
  62048. get output(): NodeMaterialConnectionPoint;
  62049. protected _buildBlock(state: NodeMaterialBuildState): this;
  62050. }
  62051. }
  62052. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62056. /**
  62057. * Block used to divide 2 vectors
  62058. */
  62059. export class DivideBlock extends NodeMaterialBlock {
  62060. /**
  62061. * Creates a new DivideBlock
  62062. * @param name defines the block name
  62063. */
  62064. constructor(name: string);
  62065. /**
  62066. * Gets the current class name
  62067. * @returns the class name
  62068. */
  62069. getClassName(): string;
  62070. /**
  62071. * Gets the left operand input component
  62072. */
  62073. get left(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the right operand input component
  62076. */
  62077. get right(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the output component
  62080. */
  62081. get output(): NodeMaterialConnectionPoint;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62089. /**
  62090. * Block used to subtract 2 vectors
  62091. */
  62092. export class SubtractBlock extends NodeMaterialBlock {
  62093. /**
  62094. * Creates a new SubtractBlock
  62095. * @param name defines the block name
  62096. */
  62097. constructor(name: string);
  62098. /**
  62099. * Gets the current class name
  62100. * @returns the class name
  62101. */
  62102. getClassName(): string;
  62103. /**
  62104. * Gets the left operand input component
  62105. */
  62106. get left(): NodeMaterialConnectionPoint;
  62107. /**
  62108. * Gets the right operand input component
  62109. */
  62110. get right(): NodeMaterialConnectionPoint;
  62111. /**
  62112. * Gets the output component
  62113. */
  62114. get output(): NodeMaterialConnectionPoint;
  62115. protected _buildBlock(state: NodeMaterialBuildState): this;
  62116. }
  62117. }
  62118. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62119. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62120. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62121. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62122. /**
  62123. * Block used to step a value
  62124. */
  62125. export class StepBlock extends NodeMaterialBlock {
  62126. /**
  62127. * Creates a new StepBlock
  62128. * @param name defines the block name
  62129. */
  62130. constructor(name: string);
  62131. /**
  62132. * Gets the current class name
  62133. * @returns the class name
  62134. */
  62135. getClassName(): string;
  62136. /**
  62137. * Gets the value operand input component
  62138. */
  62139. get value(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the edge operand input component
  62142. */
  62143. get edge(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the output component
  62146. */
  62147. get output(): NodeMaterialConnectionPoint;
  62148. protected _buildBlock(state: NodeMaterialBuildState): this;
  62149. }
  62150. }
  62151. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62155. /**
  62156. * Block used to get the opposite (1 - x) of a value
  62157. */
  62158. export class OneMinusBlock extends NodeMaterialBlock {
  62159. /**
  62160. * Creates a new OneMinusBlock
  62161. * @param name defines the block name
  62162. */
  62163. constructor(name: string);
  62164. /**
  62165. * Gets the current class name
  62166. * @returns the class name
  62167. */
  62168. getClassName(): string;
  62169. /**
  62170. * Gets the input component
  62171. */
  62172. get input(): NodeMaterialConnectionPoint;
  62173. /**
  62174. * Gets the output component
  62175. */
  62176. get output(): NodeMaterialConnectionPoint;
  62177. protected _buildBlock(state: NodeMaterialBuildState): this;
  62178. }
  62179. }
  62180. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62181. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62182. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62183. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62184. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62185. /**
  62186. * Block used to get the view direction
  62187. */
  62188. export class ViewDirectionBlock extends NodeMaterialBlock {
  62189. /**
  62190. * Creates a new ViewDirectionBlock
  62191. * @param name defines the block name
  62192. */
  62193. constructor(name: string);
  62194. /**
  62195. * Gets the current class name
  62196. * @returns the class name
  62197. */
  62198. getClassName(): string;
  62199. /**
  62200. * Gets the world position component
  62201. */
  62202. get worldPosition(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the camera position component
  62205. */
  62206. get cameraPosition(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the output component
  62209. */
  62210. get output(): NodeMaterialConnectionPoint;
  62211. autoConfigure(material: NodeMaterial): void;
  62212. protected _buildBlock(state: NodeMaterialBuildState): this;
  62213. }
  62214. }
  62215. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62216. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62217. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62218. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62219. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62220. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62221. /**
  62222. * Block used to compute fresnel value
  62223. */
  62224. export class FresnelBlock extends NodeMaterialBlock {
  62225. /**
  62226. * Create a new FresnelBlock
  62227. * @param name defines the block name
  62228. */
  62229. constructor(name: string);
  62230. /**
  62231. * Gets the current class name
  62232. * @returns the class name
  62233. */
  62234. getClassName(): string;
  62235. /**
  62236. * Gets the world normal input component
  62237. */
  62238. get worldNormal(): NodeMaterialConnectionPoint;
  62239. /**
  62240. * Gets the view direction input component
  62241. */
  62242. get viewDirection(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the bias input component
  62245. */
  62246. get bias(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the camera (or eye) position component
  62249. */
  62250. get power(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the fresnel output component
  62253. */
  62254. get fresnel(): NodeMaterialConnectionPoint;
  62255. autoConfigure(material: NodeMaterial): void;
  62256. protected _buildBlock(state: NodeMaterialBuildState): this;
  62257. }
  62258. }
  62259. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62260. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62261. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62262. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62263. /**
  62264. * Block used to get the max of 2 values
  62265. */
  62266. export class MaxBlock extends NodeMaterialBlock {
  62267. /**
  62268. * Creates a new MaxBlock
  62269. * @param name defines the block name
  62270. */
  62271. constructor(name: string);
  62272. /**
  62273. * Gets the current class name
  62274. * @returns the class name
  62275. */
  62276. getClassName(): string;
  62277. /**
  62278. * Gets the left operand input component
  62279. */
  62280. get left(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the right operand input component
  62283. */
  62284. get right(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the output component
  62287. */
  62288. get output(): NodeMaterialConnectionPoint;
  62289. protected _buildBlock(state: NodeMaterialBuildState): this;
  62290. }
  62291. }
  62292. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62296. /**
  62297. * Block used to get the min of 2 values
  62298. */
  62299. export class MinBlock extends NodeMaterialBlock {
  62300. /**
  62301. * Creates a new MinBlock
  62302. * @param name defines the block name
  62303. */
  62304. constructor(name: string);
  62305. /**
  62306. * Gets the current class name
  62307. * @returns the class name
  62308. */
  62309. getClassName(): string;
  62310. /**
  62311. * Gets the left operand input component
  62312. */
  62313. get left(): NodeMaterialConnectionPoint;
  62314. /**
  62315. * Gets the right operand input component
  62316. */
  62317. get right(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the output component
  62320. */
  62321. get output(): NodeMaterialConnectionPoint;
  62322. protected _buildBlock(state: NodeMaterialBuildState): this;
  62323. }
  62324. }
  62325. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62329. /**
  62330. * Block used to get the distance between 2 values
  62331. */
  62332. export class DistanceBlock extends NodeMaterialBlock {
  62333. /**
  62334. * Creates a new DistanceBlock
  62335. * @param name defines the block name
  62336. */
  62337. constructor(name: string);
  62338. /**
  62339. * Gets the current class name
  62340. * @returns the class name
  62341. */
  62342. getClassName(): string;
  62343. /**
  62344. * Gets the left operand input component
  62345. */
  62346. get left(): NodeMaterialConnectionPoint;
  62347. /**
  62348. * Gets the right operand input component
  62349. */
  62350. get right(): NodeMaterialConnectionPoint;
  62351. /**
  62352. * Gets the output component
  62353. */
  62354. get output(): NodeMaterialConnectionPoint;
  62355. protected _buildBlock(state: NodeMaterialBuildState): this;
  62356. }
  62357. }
  62358. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62362. /**
  62363. * Block used to get the length of a vector
  62364. */
  62365. export class LengthBlock extends NodeMaterialBlock {
  62366. /**
  62367. * Creates a new LengthBlock
  62368. * @param name defines the block name
  62369. */
  62370. constructor(name: string);
  62371. /**
  62372. * Gets the current class name
  62373. * @returns the class name
  62374. */
  62375. getClassName(): string;
  62376. /**
  62377. * Gets the value input component
  62378. */
  62379. get value(): NodeMaterialConnectionPoint;
  62380. /**
  62381. * Gets the output component
  62382. */
  62383. get output(): NodeMaterialConnectionPoint;
  62384. protected _buildBlock(state: NodeMaterialBuildState): this;
  62385. }
  62386. }
  62387. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62388. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62391. /**
  62392. * Block used to get negative version of a value (i.e. x * -1)
  62393. */
  62394. export class NegateBlock extends NodeMaterialBlock {
  62395. /**
  62396. * Creates a new NegateBlock
  62397. * @param name defines the block name
  62398. */
  62399. constructor(name: string);
  62400. /**
  62401. * Gets the current class name
  62402. * @returns the class name
  62403. */
  62404. getClassName(): string;
  62405. /**
  62406. * Gets the value input component
  62407. */
  62408. get value(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the output component
  62411. */
  62412. get output(): NodeMaterialConnectionPoint;
  62413. protected _buildBlock(state: NodeMaterialBuildState): this;
  62414. }
  62415. }
  62416. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62420. /**
  62421. * Block used to get the value of the first parameter raised to the power of the second
  62422. */
  62423. export class PowBlock extends NodeMaterialBlock {
  62424. /**
  62425. * Creates a new PowBlock
  62426. * @param name defines the block name
  62427. */
  62428. constructor(name: string);
  62429. /**
  62430. * Gets the current class name
  62431. * @returns the class name
  62432. */
  62433. getClassName(): string;
  62434. /**
  62435. * Gets the value operand input component
  62436. */
  62437. get value(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the power operand input component
  62440. */
  62441. get power(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the output component
  62444. */
  62445. get output(): NodeMaterialConnectionPoint;
  62446. protected _buildBlock(state: NodeMaterialBuildState): this;
  62447. }
  62448. }
  62449. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62454. /**
  62455. * Block used to get a random number
  62456. */
  62457. export class RandomNumberBlock extends NodeMaterialBlock {
  62458. /**
  62459. * Creates a new RandomNumberBlock
  62460. * @param name defines the block name
  62461. */
  62462. constructor(name: string);
  62463. /**
  62464. * Gets the current class name
  62465. * @returns the class name
  62466. */
  62467. getClassName(): string;
  62468. /**
  62469. * Gets the seed input component
  62470. */
  62471. get seed(): NodeMaterialConnectionPoint;
  62472. /**
  62473. * Gets the output component
  62474. */
  62475. get output(): NodeMaterialConnectionPoint;
  62476. protected _buildBlock(state: NodeMaterialBuildState): this;
  62477. }
  62478. }
  62479. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62483. /**
  62484. * Block used to compute arc tangent of 2 values
  62485. */
  62486. export class ArcTan2Block extends NodeMaterialBlock {
  62487. /**
  62488. * Creates a new ArcTan2Block
  62489. * @param name defines the block name
  62490. */
  62491. constructor(name: string);
  62492. /**
  62493. * Gets the current class name
  62494. * @returns the class name
  62495. */
  62496. getClassName(): string;
  62497. /**
  62498. * Gets the x operand input component
  62499. */
  62500. get x(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the y operand input component
  62503. */
  62504. get y(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the output component
  62507. */
  62508. get output(): NodeMaterialConnectionPoint;
  62509. protected _buildBlock(state: NodeMaterialBuildState): this;
  62510. }
  62511. }
  62512. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62516. /**
  62517. * Block used to smooth step a value
  62518. */
  62519. export class SmoothStepBlock extends NodeMaterialBlock {
  62520. /**
  62521. * Creates a new SmoothStepBlock
  62522. * @param name defines the block name
  62523. */
  62524. constructor(name: string);
  62525. /**
  62526. * Gets the current class name
  62527. * @returns the class name
  62528. */
  62529. getClassName(): string;
  62530. /**
  62531. * Gets the value operand input component
  62532. */
  62533. get value(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the first edge operand input component
  62536. */
  62537. get edge0(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the second edge operand input component
  62540. */
  62541. get edge1(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the output component
  62544. */
  62545. get output(): NodeMaterialConnectionPoint;
  62546. protected _buildBlock(state: NodeMaterialBuildState): this;
  62547. }
  62548. }
  62549. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62550. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62551. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62552. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62553. /**
  62554. * Block used to get the reciprocal (1 / x) of a value
  62555. */
  62556. export class ReciprocalBlock extends NodeMaterialBlock {
  62557. /**
  62558. * Creates a new ReciprocalBlock
  62559. * @param name defines the block name
  62560. */
  62561. constructor(name: string);
  62562. /**
  62563. * Gets the current class name
  62564. * @returns the class name
  62565. */
  62566. getClassName(): string;
  62567. /**
  62568. * Gets the input component
  62569. */
  62570. get input(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the output component
  62573. */
  62574. get output(): NodeMaterialConnectionPoint;
  62575. protected _buildBlock(state: NodeMaterialBuildState): this;
  62576. }
  62577. }
  62578. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62582. /**
  62583. * Block used to replace a color by another one
  62584. */
  62585. export class ReplaceColorBlock extends NodeMaterialBlock {
  62586. /**
  62587. * Creates a new ReplaceColorBlock
  62588. * @param name defines the block name
  62589. */
  62590. constructor(name: string);
  62591. /**
  62592. * Gets the current class name
  62593. * @returns the class name
  62594. */
  62595. getClassName(): string;
  62596. /**
  62597. * Gets the value input component
  62598. */
  62599. get value(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the reference input component
  62602. */
  62603. get reference(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the distance input component
  62606. */
  62607. get distance(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the replacement input component
  62610. */
  62611. get replacement(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the output component
  62614. */
  62615. get output(): NodeMaterialConnectionPoint;
  62616. protected _buildBlock(state: NodeMaterialBuildState): this;
  62617. }
  62618. }
  62619. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62623. /**
  62624. * Block used to posterize a value
  62625. * @see https://en.wikipedia.org/wiki/Posterization
  62626. */
  62627. export class PosterizeBlock extends NodeMaterialBlock {
  62628. /**
  62629. * Creates a new PosterizeBlock
  62630. * @param name defines the block name
  62631. */
  62632. constructor(name: string);
  62633. /**
  62634. * Gets the current class name
  62635. * @returns the class name
  62636. */
  62637. getClassName(): string;
  62638. /**
  62639. * Gets the value input component
  62640. */
  62641. get value(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the steps input component
  62644. */
  62645. get steps(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the output component
  62648. */
  62649. get output(): NodeMaterialConnectionPoint;
  62650. protected _buildBlock(state: NodeMaterialBuildState): this;
  62651. }
  62652. }
  62653. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62657. import { Scene } from "babylonjs/scene";
  62658. /**
  62659. * Operations supported by the Wave block
  62660. */
  62661. export enum WaveBlockKind {
  62662. /** SawTooth */
  62663. SawTooth = 0,
  62664. /** Square */
  62665. Square = 1,
  62666. /** Triangle */
  62667. Triangle = 2
  62668. }
  62669. /**
  62670. * Block used to apply wave operation to floats
  62671. */
  62672. export class WaveBlock extends NodeMaterialBlock {
  62673. /**
  62674. * Gets or sets the kibnd of wave to be applied by the block
  62675. */
  62676. kind: WaveBlockKind;
  62677. /**
  62678. * Creates a new WaveBlock
  62679. * @param name defines the block name
  62680. */
  62681. constructor(name: string);
  62682. /**
  62683. * Gets the current class name
  62684. * @returns the class name
  62685. */
  62686. getClassName(): string;
  62687. /**
  62688. * Gets the input component
  62689. */
  62690. get input(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the output component
  62693. */
  62694. get output(): NodeMaterialConnectionPoint;
  62695. protected _buildBlock(state: NodeMaterialBuildState): this;
  62696. serialize(): any;
  62697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62698. }
  62699. }
  62700. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62704. import { Color3 } from "babylonjs/Maths/math.color";
  62705. import { Scene } from "babylonjs/scene";
  62706. /**
  62707. * Class used to store a color step for the GradientBlock
  62708. */
  62709. export class GradientBlockColorStep {
  62710. /**
  62711. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62712. */
  62713. step: number;
  62714. /**
  62715. * Gets or sets the color associated with this step
  62716. */
  62717. color: Color3;
  62718. /**
  62719. * Creates a new GradientBlockColorStep
  62720. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62721. * @param color defines the color associated with this step
  62722. */
  62723. constructor(
  62724. /**
  62725. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62726. */
  62727. step: number,
  62728. /**
  62729. * Gets or sets the color associated with this step
  62730. */
  62731. color: Color3);
  62732. }
  62733. /**
  62734. * Block used to return a color from a gradient based on an input value between 0 and 1
  62735. */
  62736. export class GradientBlock extends NodeMaterialBlock {
  62737. /**
  62738. * Gets or sets the list of color steps
  62739. */
  62740. colorSteps: GradientBlockColorStep[];
  62741. /**
  62742. * Creates a new GradientBlock
  62743. * @param name defines the block name
  62744. */
  62745. constructor(name: string);
  62746. /**
  62747. * Gets the current class name
  62748. * @returns the class name
  62749. */
  62750. getClassName(): string;
  62751. /**
  62752. * Gets the gradient input component
  62753. */
  62754. get gradient(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the output component
  62757. */
  62758. get output(): NodeMaterialConnectionPoint;
  62759. private _writeColorConstant;
  62760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62761. serialize(): any;
  62762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62763. protected _dumpPropertiesCode(): string;
  62764. }
  62765. }
  62766. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62770. /**
  62771. * Block used to normalize lerp between 2 values
  62772. */
  62773. export class NLerpBlock extends NodeMaterialBlock {
  62774. /**
  62775. * Creates a new NLerpBlock
  62776. * @param name defines the block name
  62777. */
  62778. constructor(name: string);
  62779. /**
  62780. * Gets the current class name
  62781. * @returns the class name
  62782. */
  62783. getClassName(): string;
  62784. /**
  62785. * Gets the left operand input component
  62786. */
  62787. get left(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the right operand input component
  62790. */
  62791. get right(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the gradient operand input component
  62794. */
  62795. get gradient(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the output component
  62798. */
  62799. get output(): NodeMaterialConnectionPoint;
  62800. protected _buildBlock(state: NodeMaterialBuildState): this;
  62801. }
  62802. }
  62803. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62807. import { Scene } from "babylonjs/scene";
  62808. /**
  62809. * block used to Generate a Worley Noise 3D Noise Pattern
  62810. */
  62811. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62812. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62813. manhattanDistance: boolean;
  62814. /**
  62815. * Creates a new WorleyNoise3DBlock
  62816. * @param name defines the block name
  62817. */
  62818. constructor(name: string);
  62819. /**
  62820. * Gets the current class name
  62821. * @returns the class name
  62822. */
  62823. getClassName(): string;
  62824. /**
  62825. * Gets the seed input component
  62826. */
  62827. get seed(): NodeMaterialConnectionPoint;
  62828. /**
  62829. * Gets the jitter input component
  62830. */
  62831. get jitter(): NodeMaterialConnectionPoint;
  62832. /**
  62833. * Gets the output component
  62834. */
  62835. get output(): NodeMaterialConnectionPoint;
  62836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62837. /**
  62838. * Exposes the properties to the UI?
  62839. */
  62840. protected _dumpPropertiesCode(): string;
  62841. /**
  62842. * Exposes the properties to the Seralize?
  62843. */
  62844. serialize(): any;
  62845. /**
  62846. * Exposes the properties to the deseralize?
  62847. */
  62848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62849. }
  62850. }
  62851. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62855. /**
  62856. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62857. */
  62858. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62859. /**
  62860. * Creates a new SimplexPerlin3DBlock
  62861. * @param name defines the block name
  62862. */
  62863. constructor(name: string);
  62864. /**
  62865. * Gets the current class name
  62866. * @returns the class name
  62867. */
  62868. getClassName(): string;
  62869. /**
  62870. * Gets the seed operand input component
  62871. */
  62872. get seed(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the output component
  62875. */
  62876. get output(): NodeMaterialConnectionPoint;
  62877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62878. }
  62879. }
  62880. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62884. /**
  62885. * Block used to blend normals
  62886. */
  62887. export class NormalBlendBlock extends NodeMaterialBlock {
  62888. /**
  62889. * Creates a new NormalBlendBlock
  62890. * @param name defines the block name
  62891. */
  62892. constructor(name: string);
  62893. /**
  62894. * Gets the current class name
  62895. * @returns the class name
  62896. */
  62897. getClassName(): string;
  62898. /**
  62899. * Gets the first input component
  62900. */
  62901. get normalMap0(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the second input component
  62904. */
  62905. get normalMap1(): NodeMaterialConnectionPoint;
  62906. /**
  62907. * Gets the output component
  62908. */
  62909. get output(): NodeMaterialConnectionPoint;
  62910. protected _buildBlock(state: NodeMaterialBuildState): this;
  62911. }
  62912. }
  62913. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62917. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62918. /**
  62919. * Block used to rotate a 2d vector by a given angle
  62920. */
  62921. export class Rotate2dBlock extends NodeMaterialBlock {
  62922. /**
  62923. * Creates a new Rotate2dBlock
  62924. * @param name defines the block name
  62925. */
  62926. constructor(name: string);
  62927. /**
  62928. * Gets the current class name
  62929. * @returns the class name
  62930. */
  62931. getClassName(): string;
  62932. /**
  62933. * Gets the input vector
  62934. */
  62935. get input(): NodeMaterialConnectionPoint;
  62936. /**
  62937. * Gets the input angle
  62938. */
  62939. get angle(): NodeMaterialConnectionPoint;
  62940. /**
  62941. * Gets the output component
  62942. */
  62943. get output(): NodeMaterialConnectionPoint;
  62944. autoConfigure(material: NodeMaterial): void;
  62945. protected _buildBlock(state: NodeMaterialBuildState): this;
  62946. }
  62947. }
  62948. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62949. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62950. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62951. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62952. /**
  62953. * Block used to get the reflected vector from a direction and a normal
  62954. */
  62955. export class ReflectBlock extends NodeMaterialBlock {
  62956. /**
  62957. * Creates a new ReflectBlock
  62958. * @param name defines the block name
  62959. */
  62960. constructor(name: string);
  62961. /**
  62962. * Gets the current class name
  62963. * @returns the class name
  62964. */
  62965. getClassName(): string;
  62966. /**
  62967. * Gets the incident component
  62968. */
  62969. get incident(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the normal component
  62972. */
  62973. get normal(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the output component
  62976. */
  62977. get output(): NodeMaterialConnectionPoint;
  62978. protected _buildBlock(state: NodeMaterialBuildState): this;
  62979. }
  62980. }
  62981. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62985. /**
  62986. * Block used to get the refracted vector from a direction and a normal
  62987. */
  62988. export class RefractBlock extends NodeMaterialBlock {
  62989. /**
  62990. * Creates a new RefractBlock
  62991. * @param name defines the block name
  62992. */
  62993. constructor(name: string);
  62994. /**
  62995. * Gets the current class name
  62996. * @returns the class name
  62997. */
  62998. getClassName(): string;
  62999. /**
  63000. * Gets the incident component
  63001. */
  63002. get incident(): NodeMaterialConnectionPoint;
  63003. /**
  63004. * Gets the normal component
  63005. */
  63006. get normal(): NodeMaterialConnectionPoint;
  63007. /**
  63008. * Gets the index of refraction component
  63009. */
  63010. get ior(): NodeMaterialConnectionPoint;
  63011. /**
  63012. * Gets the output component
  63013. */
  63014. get output(): NodeMaterialConnectionPoint;
  63015. protected _buildBlock(state: NodeMaterialBuildState): this;
  63016. }
  63017. }
  63018. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63022. /**
  63023. * Block used to desaturate a color
  63024. */
  63025. export class DesaturateBlock extends NodeMaterialBlock {
  63026. /**
  63027. * Creates a new DesaturateBlock
  63028. * @param name defines the block name
  63029. */
  63030. constructor(name: string);
  63031. /**
  63032. * Gets the current class name
  63033. * @returns the class name
  63034. */
  63035. getClassName(): string;
  63036. /**
  63037. * Gets the color operand input component
  63038. */
  63039. get color(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the level operand input component
  63042. */
  63043. get level(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the output component
  63046. */
  63047. get output(): NodeMaterialConnectionPoint;
  63048. protected _buildBlock(state: NodeMaterialBuildState): this;
  63049. }
  63050. }
  63051. declare module "babylonjs/Materials/Node/Blocks/index" {
  63052. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63053. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63054. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63055. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63056. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63057. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63058. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63059. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63060. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63061. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63062. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63063. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63064. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63065. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63066. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63067. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63068. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63069. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63070. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63071. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63072. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63073. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63074. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63075. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63076. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63077. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63078. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63079. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63080. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63081. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63082. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63083. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63084. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63085. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63086. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63087. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63088. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63089. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63090. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63091. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63092. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63093. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63094. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63095. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63096. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63097. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63098. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63099. }
  63100. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63101. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63102. }
  63103. declare module "babylonjs/Materials/Node/index" {
  63104. export * from "babylonjs/Materials/Node/Enums/index";
  63105. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63106. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63107. export * from "babylonjs/Materials/Node/nodeMaterial";
  63108. export * from "babylonjs/Materials/Node/Blocks/index";
  63109. export * from "babylonjs/Materials/Node/Optimizers/index";
  63110. }
  63111. declare module "babylonjs/Materials/effectRenderer" {
  63112. import { Nullable } from "babylonjs/types";
  63113. import { Texture } from "babylonjs/Materials/Textures/texture";
  63114. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63115. import { Viewport } from "babylonjs/Maths/math.viewport";
  63116. import { Observable } from "babylonjs/Misc/observable";
  63117. import { Effect } from "babylonjs/Materials/effect";
  63118. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63119. import "babylonjs/Shaders/postprocess.vertex";
  63120. /**
  63121. * Effect Render Options
  63122. */
  63123. export interface IEffectRendererOptions {
  63124. /**
  63125. * Defines the vertices positions.
  63126. */
  63127. positions?: number[];
  63128. /**
  63129. * Defines the indices.
  63130. */
  63131. indices?: number[];
  63132. }
  63133. /**
  63134. * Helper class to render one or more effects
  63135. */
  63136. export class EffectRenderer {
  63137. private engine;
  63138. private static _DefaultOptions;
  63139. private _vertexBuffers;
  63140. private _indexBuffer;
  63141. private _ringBufferIndex;
  63142. private _ringScreenBuffer;
  63143. private _fullscreenViewport;
  63144. private _getNextFrameBuffer;
  63145. /**
  63146. * Creates an effect renderer
  63147. * @param engine the engine to use for rendering
  63148. * @param options defines the options of the effect renderer
  63149. */
  63150. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63151. /**
  63152. * Sets the current viewport in normalized coordinates 0-1
  63153. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63154. */
  63155. setViewport(viewport?: Viewport): void;
  63156. /**
  63157. * Binds the embedded attributes buffer to the effect.
  63158. * @param effect Defines the effect to bind the attributes for
  63159. */
  63160. bindBuffers(effect: Effect): void;
  63161. /**
  63162. * Sets the current effect wrapper to use during draw.
  63163. * The effect needs to be ready before calling this api.
  63164. * This also sets the default full screen position attribute.
  63165. * @param effectWrapper Defines the effect to draw with
  63166. */
  63167. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63168. /**
  63169. * Draws a full screen quad.
  63170. */
  63171. draw(): void;
  63172. /**
  63173. * renders one or more effects to a specified texture
  63174. * @param effectWrappers list of effects to renderer
  63175. * @param outputTexture texture to draw to, if null it will render to the screen
  63176. */
  63177. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63178. /**
  63179. * Disposes of the effect renderer
  63180. */
  63181. dispose(): void;
  63182. }
  63183. /**
  63184. * Options to create an EffectWrapper
  63185. */
  63186. interface EffectWrapperCreationOptions {
  63187. /**
  63188. * Engine to use to create the effect
  63189. */
  63190. engine: ThinEngine;
  63191. /**
  63192. * Fragment shader for the effect
  63193. */
  63194. fragmentShader: string;
  63195. /**
  63196. * Vertex shader for the effect
  63197. */
  63198. vertexShader?: string;
  63199. /**
  63200. * Attributes to use in the shader
  63201. */
  63202. attributeNames?: Array<string>;
  63203. /**
  63204. * Uniforms to use in the shader
  63205. */
  63206. uniformNames?: Array<string>;
  63207. /**
  63208. * Texture sampler names to use in the shader
  63209. */
  63210. samplerNames?: Array<string>;
  63211. /**
  63212. * The friendly name of the effect displayed in Spector.
  63213. */
  63214. name?: string;
  63215. }
  63216. /**
  63217. * Wraps an effect to be used for rendering
  63218. */
  63219. export class EffectWrapper {
  63220. /**
  63221. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63222. */
  63223. onApplyObservable: Observable<{}>;
  63224. /**
  63225. * The underlying effect
  63226. */
  63227. effect: Effect;
  63228. /**
  63229. * Creates an effect to be renderer
  63230. * @param creationOptions options to create the effect
  63231. */
  63232. constructor(creationOptions: EffectWrapperCreationOptions);
  63233. /**
  63234. * Disposes of the effect wrapper
  63235. */
  63236. dispose(): void;
  63237. }
  63238. }
  63239. declare module "babylonjs/Materials/index" {
  63240. export * from "babylonjs/Materials/Background/index";
  63241. export * from "babylonjs/Materials/colorCurves";
  63242. export * from "babylonjs/Materials/iEffectFallbacks";
  63243. export * from "babylonjs/Materials/effectFallbacks";
  63244. export * from "babylonjs/Materials/effect";
  63245. export * from "babylonjs/Materials/fresnelParameters";
  63246. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63247. export * from "babylonjs/Materials/material";
  63248. export * from "babylonjs/Materials/materialDefines";
  63249. export * from "babylonjs/Materials/materialHelper";
  63250. export * from "babylonjs/Materials/multiMaterial";
  63251. export * from "babylonjs/Materials/PBR/index";
  63252. export * from "babylonjs/Materials/pushMaterial";
  63253. export * from "babylonjs/Materials/shaderMaterial";
  63254. export * from "babylonjs/Materials/standardMaterial";
  63255. export * from "babylonjs/Materials/Textures/index";
  63256. export * from "babylonjs/Materials/uniformBuffer";
  63257. export * from "babylonjs/Materials/materialFlags";
  63258. export * from "babylonjs/Materials/Node/index";
  63259. export * from "babylonjs/Materials/effectRenderer";
  63260. }
  63261. declare module "babylonjs/Maths/index" {
  63262. export * from "babylonjs/Maths/math.scalar";
  63263. export * from "babylonjs/Maths/math";
  63264. export * from "babylonjs/Maths/sphericalPolynomial";
  63265. }
  63266. declare module "babylonjs/Misc/workerPool" {
  63267. import { IDisposable } from "babylonjs/scene";
  63268. /**
  63269. * Helper class to push actions to a pool of workers.
  63270. */
  63271. export class WorkerPool implements IDisposable {
  63272. private _workerInfos;
  63273. private _pendingActions;
  63274. /**
  63275. * Constructor
  63276. * @param workers Array of workers to use for actions
  63277. */
  63278. constructor(workers: Array<Worker>);
  63279. /**
  63280. * Terminates all workers and clears any pending actions.
  63281. */
  63282. dispose(): void;
  63283. /**
  63284. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63285. * pended until a worker has completed its action.
  63286. * @param action The action to perform. Call onComplete when the action is complete.
  63287. */
  63288. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63289. private _execute;
  63290. }
  63291. }
  63292. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63293. import { IDisposable } from "babylonjs/scene";
  63294. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63295. /**
  63296. * Configuration for Draco compression
  63297. */
  63298. export interface IDracoCompressionConfiguration {
  63299. /**
  63300. * Configuration for the decoder.
  63301. */
  63302. decoder: {
  63303. /**
  63304. * The url to the WebAssembly module.
  63305. */
  63306. wasmUrl?: string;
  63307. /**
  63308. * The url to the WebAssembly binary.
  63309. */
  63310. wasmBinaryUrl?: string;
  63311. /**
  63312. * The url to the fallback JavaScript module.
  63313. */
  63314. fallbackUrl?: string;
  63315. };
  63316. }
  63317. /**
  63318. * Draco compression (https://google.github.io/draco/)
  63319. *
  63320. * This class wraps the Draco module.
  63321. *
  63322. * **Encoder**
  63323. *
  63324. * The encoder is not currently implemented.
  63325. *
  63326. * **Decoder**
  63327. *
  63328. * 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.
  63329. *
  63330. * To update the configuration, use the following code:
  63331. * ```javascript
  63332. * DracoCompression.Configuration = {
  63333. * decoder: {
  63334. * wasmUrl: "<url to the WebAssembly library>",
  63335. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63336. * fallbackUrl: "<url to the fallback JavaScript library>",
  63337. * }
  63338. * };
  63339. * ```
  63340. *
  63341. * 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.
  63342. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63343. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63344. *
  63345. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63346. * ```javascript
  63347. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63348. * ```
  63349. *
  63350. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63351. */
  63352. export class DracoCompression implements IDisposable {
  63353. private _workerPoolPromise?;
  63354. private _decoderModulePromise?;
  63355. /**
  63356. * The configuration. Defaults to the following urls:
  63357. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63358. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63359. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63360. */
  63361. static Configuration: IDracoCompressionConfiguration;
  63362. /**
  63363. * Returns true if the decoder configuration is available.
  63364. */
  63365. static get DecoderAvailable(): boolean;
  63366. /**
  63367. * Default number of workers to create when creating the draco compression object.
  63368. */
  63369. static DefaultNumWorkers: number;
  63370. private static GetDefaultNumWorkers;
  63371. private static _Default;
  63372. /**
  63373. * Default instance for the draco compression object.
  63374. */
  63375. static get Default(): DracoCompression;
  63376. /**
  63377. * Constructor
  63378. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63379. */
  63380. constructor(numWorkers?: number);
  63381. /**
  63382. * Stop all async operations and release resources.
  63383. */
  63384. dispose(): void;
  63385. /**
  63386. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63387. * @returns a promise that resolves when ready
  63388. */
  63389. whenReadyAsync(): Promise<void>;
  63390. /**
  63391. * Decode Draco compressed mesh data to vertex data.
  63392. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63393. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63394. * @returns A promise that resolves with the decoded vertex data
  63395. */
  63396. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63397. [kind: string]: number;
  63398. }): Promise<VertexData>;
  63399. }
  63400. }
  63401. declare module "babylonjs/Meshes/Compression/index" {
  63402. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63403. }
  63404. declare module "babylonjs/Meshes/csg" {
  63405. import { Nullable } from "babylonjs/types";
  63406. import { Scene } from "babylonjs/scene";
  63407. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63408. import { Mesh } from "babylonjs/Meshes/mesh";
  63409. import { Material } from "babylonjs/Materials/material";
  63410. /**
  63411. * Class for building Constructive Solid Geometry
  63412. */
  63413. export class CSG {
  63414. private polygons;
  63415. /**
  63416. * The world matrix
  63417. */
  63418. matrix: Matrix;
  63419. /**
  63420. * Stores the position
  63421. */
  63422. position: Vector3;
  63423. /**
  63424. * Stores the rotation
  63425. */
  63426. rotation: Vector3;
  63427. /**
  63428. * Stores the rotation quaternion
  63429. */
  63430. rotationQuaternion: Nullable<Quaternion>;
  63431. /**
  63432. * Stores the scaling vector
  63433. */
  63434. scaling: Vector3;
  63435. /**
  63436. * Convert the Mesh to CSG
  63437. * @param mesh The Mesh to convert to CSG
  63438. * @returns A new CSG from the Mesh
  63439. */
  63440. static FromMesh(mesh: Mesh): CSG;
  63441. /**
  63442. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63443. * @param polygons Polygons used to construct a CSG solid
  63444. */
  63445. private static FromPolygons;
  63446. /**
  63447. * Clones, or makes a deep copy, of the CSG
  63448. * @returns A new CSG
  63449. */
  63450. clone(): CSG;
  63451. /**
  63452. * Unions this CSG with another CSG
  63453. * @param csg The CSG to union against this CSG
  63454. * @returns The unioned CSG
  63455. */
  63456. union(csg: CSG): CSG;
  63457. /**
  63458. * Unions this CSG with another CSG in place
  63459. * @param csg The CSG to union against this CSG
  63460. */
  63461. unionInPlace(csg: CSG): void;
  63462. /**
  63463. * Subtracts this CSG with another CSG
  63464. * @param csg The CSG to subtract against this CSG
  63465. * @returns A new CSG
  63466. */
  63467. subtract(csg: CSG): CSG;
  63468. /**
  63469. * Subtracts this CSG with another CSG in place
  63470. * @param csg The CSG to subtact against this CSG
  63471. */
  63472. subtractInPlace(csg: CSG): void;
  63473. /**
  63474. * Intersect this CSG with another CSG
  63475. * @param csg The CSG to intersect against this CSG
  63476. * @returns A new CSG
  63477. */
  63478. intersect(csg: CSG): CSG;
  63479. /**
  63480. * Intersects this CSG with another CSG in place
  63481. * @param csg The CSG to intersect against this CSG
  63482. */
  63483. intersectInPlace(csg: CSG): void;
  63484. /**
  63485. * Return a new CSG solid with solid and empty space switched. This solid is
  63486. * not modified.
  63487. * @returns A new CSG solid with solid and empty space switched
  63488. */
  63489. inverse(): CSG;
  63490. /**
  63491. * Inverses the CSG in place
  63492. */
  63493. inverseInPlace(): void;
  63494. /**
  63495. * This is used to keep meshes transformations so they can be restored
  63496. * when we build back a Babylon Mesh
  63497. * NB : All CSG operations are performed in world coordinates
  63498. * @param csg The CSG to copy the transform attributes from
  63499. * @returns This CSG
  63500. */
  63501. copyTransformAttributes(csg: CSG): CSG;
  63502. /**
  63503. * Build Raw mesh from CSG
  63504. * Coordinates here are in world space
  63505. * @param name The name of the mesh geometry
  63506. * @param scene The Scene
  63507. * @param keepSubMeshes Specifies if the submeshes should be kept
  63508. * @returns A new Mesh
  63509. */
  63510. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63511. /**
  63512. * Build Mesh from CSG taking material and transforms into account
  63513. * @param name The name of the Mesh
  63514. * @param material The material of the Mesh
  63515. * @param scene The Scene
  63516. * @param keepSubMeshes Specifies if submeshes should be kept
  63517. * @returns The new Mesh
  63518. */
  63519. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63520. }
  63521. }
  63522. declare module "babylonjs/Meshes/trailMesh" {
  63523. import { Mesh } from "babylonjs/Meshes/mesh";
  63524. import { Scene } from "babylonjs/scene";
  63525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63526. /**
  63527. * Class used to create a trail following a mesh
  63528. */
  63529. export class TrailMesh extends Mesh {
  63530. private _generator;
  63531. private _autoStart;
  63532. private _running;
  63533. private _diameter;
  63534. private _length;
  63535. private _sectionPolygonPointsCount;
  63536. private _sectionVectors;
  63537. private _sectionNormalVectors;
  63538. private _beforeRenderObserver;
  63539. /**
  63540. * @constructor
  63541. * @param name The value used by scene.getMeshByName() to do a lookup.
  63542. * @param generator The mesh or transform node to generate a trail.
  63543. * @param scene The scene to add this mesh to.
  63544. * @param diameter Diameter of trailing mesh. Default is 1.
  63545. * @param length Length of trailing mesh. Default is 60.
  63546. * @param autoStart Automatically start trailing mesh. Default true.
  63547. */
  63548. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63549. /**
  63550. * "TrailMesh"
  63551. * @returns "TrailMesh"
  63552. */
  63553. getClassName(): string;
  63554. private _createMesh;
  63555. /**
  63556. * Start trailing mesh.
  63557. */
  63558. start(): void;
  63559. /**
  63560. * Stop trailing mesh.
  63561. */
  63562. stop(): void;
  63563. /**
  63564. * Update trailing mesh geometry.
  63565. */
  63566. update(): void;
  63567. /**
  63568. * Returns a new TrailMesh object.
  63569. * @param name is a string, the name given to the new mesh
  63570. * @param newGenerator use new generator object for cloned trail mesh
  63571. * @returns a new mesh
  63572. */
  63573. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63574. /**
  63575. * Serializes this trail mesh
  63576. * @param serializationObject object to write serialization to
  63577. */
  63578. serialize(serializationObject: any): void;
  63579. /**
  63580. * Parses a serialized trail mesh
  63581. * @param parsedMesh the serialized mesh
  63582. * @param scene the scene to create the trail mesh in
  63583. * @returns the created trail mesh
  63584. */
  63585. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63586. }
  63587. }
  63588. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63589. import { Nullable } from "babylonjs/types";
  63590. import { Scene } from "babylonjs/scene";
  63591. import { Vector4 } from "babylonjs/Maths/math.vector";
  63592. import { Color4 } from "babylonjs/Maths/math.color";
  63593. import { Mesh } from "babylonjs/Meshes/mesh";
  63594. /**
  63595. * Class containing static functions to help procedurally build meshes
  63596. */
  63597. export class TiledBoxBuilder {
  63598. /**
  63599. * Creates a box mesh
  63600. * 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)
  63601. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63605. * @param name defines the name of the mesh
  63606. * @param options defines the options used to create the mesh
  63607. * @param scene defines the hosting scene
  63608. * @returns the box mesh
  63609. */
  63610. static CreateTiledBox(name: string, options: {
  63611. pattern?: number;
  63612. width?: number;
  63613. height?: number;
  63614. depth?: number;
  63615. tileSize?: number;
  63616. tileWidth?: number;
  63617. tileHeight?: number;
  63618. alignHorizontal?: number;
  63619. alignVertical?: number;
  63620. faceUV?: Vector4[];
  63621. faceColors?: Color4[];
  63622. sideOrientation?: number;
  63623. updatable?: boolean;
  63624. }, scene?: Nullable<Scene>): Mesh;
  63625. }
  63626. }
  63627. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63628. import { Vector4 } from "babylonjs/Maths/math.vector";
  63629. import { Mesh } from "babylonjs/Meshes/mesh";
  63630. /**
  63631. * Class containing static functions to help procedurally build meshes
  63632. */
  63633. export class TorusKnotBuilder {
  63634. /**
  63635. * Creates a torus knot mesh
  63636. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63637. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63638. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63639. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63643. * @param name defines the name of the mesh
  63644. * @param options defines the options used to create the mesh
  63645. * @param scene defines the hosting scene
  63646. * @returns the torus knot mesh
  63647. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63648. */
  63649. static CreateTorusKnot(name: string, options: {
  63650. radius?: number;
  63651. tube?: number;
  63652. radialSegments?: number;
  63653. tubularSegments?: number;
  63654. p?: number;
  63655. q?: number;
  63656. updatable?: boolean;
  63657. sideOrientation?: number;
  63658. frontUVs?: Vector4;
  63659. backUVs?: Vector4;
  63660. }, scene: any): Mesh;
  63661. }
  63662. }
  63663. declare module "babylonjs/Meshes/polygonMesh" {
  63664. import { Scene } from "babylonjs/scene";
  63665. import { Vector2 } from "babylonjs/Maths/math.vector";
  63666. import { Mesh } from "babylonjs/Meshes/mesh";
  63667. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63668. import { Path2 } from "babylonjs/Maths/math.path";
  63669. /**
  63670. * Polygon
  63671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63672. */
  63673. export class Polygon {
  63674. /**
  63675. * Creates a rectangle
  63676. * @param xmin bottom X coord
  63677. * @param ymin bottom Y coord
  63678. * @param xmax top X coord
  63679. * @param ymax top Y coord
  63680. * @returns points that make the resulting rectation
  63681. */
  63682. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63683. /**
  63684. * Creates a circle
  63685. * @param radius radius of circle
  63686. * @param cx scale in x
  63687. * @param cy scale in y
  63688. * @param numberOfSides number of sides that make up the circle
  63689. * @returns points that make the resulting circle
  63690. */
  63691. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63692. /**
  63693. * Creates a polygon from input string
  63694. * @param input Input polygon data
  63695. * @returns the parsed points
  63696. */
  63697. static Parse(input: string): Vector2[];
  63698. /**
  63699. * Starts building a polygon from x and y coordinates
  63700. * @param x x coordinate
  63701. * @param y y coordinate
  63702. * @returns the started path2
  63703. */
  63704. static StartingAt(x: number, y: number): Path2;
  63705. }
  63706. /**
  63707. * Builds a polygon
  63708. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63709. */
  63710. export class PolygonMeshBuilder {
  63711. private _points;
  63712. private _outlinepoints;
  63713. private _holes;
  63714. private _name;
  63715. private _scene;
  63716. private _epoints;
  63717. private _eholes;
  63718. private _addToepoint;
  63719. /**
  63720. * Babylon reference to the earcut plugin.
  63721. */
  63722. bjsEarcut: any;
  63723. /**
  63724. * Creates a PolygonMeshBuilder
  63725. * @param name name of the builder
  63726. * @param contours Path of the polygon
  63727. * @param scene scene to add to when creating the mesh
  63728. * @param earcutInjection can be used to inject your own earcut reference
  63729. */
  63730. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63731. /**
  63732. * Adds a whole within the polygon
  63733. * @param hole Array of points defining the hole
  63734. * @returns this
  63735. */
  63736. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63737. /**
  63738. * Creates the polygon
  63739. * @param updatable If the mesh should be updatable
  63740. * @param depth The depth of the mesh created
  63741. * @returns the created mesh
  63742. */
  63743. build(updatable?: boolean, depth?: number): Mesh;
  63744. /**
  63745. * Creates the polygon
  63746. * @param depth The depth of the mesh created
  63747. * @returns the created VertexData
  63748. */
  63749. buildVertexData(depth?: number): VertexData;
  63750. /**
  63751. * Adds a side to the polygon
  63752. * @param positions points that make the polygon
  63753. * @param normals normals of the polygon
  63754. * @param uvs uvs of the polygon
  63755. * @param indices indices of the polygon
  63756. * @param bounds bounds of the polygon
  63757. * @param points points of the polygon
  63758. * @param depth depth of the polygon
  63759. * @param flip flip of the polygon
  63760. */
  63761. private addSide;
  63762. }
  63763. }
  63764. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63765. import { Scene } from "babylonjs/scene";
  63766. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63767. import { Color4 } from "babylonjs/Maths/math.color";
  63768. import { Mesh } from "babylonjs/Meshes/mesh";
  63769. import { Nullable } from "babylonjs/types";
  63770. /**
  63771. * Class containing static functions to help procedurally build meshes
  63772. */
  63773. export class PolygonBuilder {
  63774. /**
  63775. * Creates a polygon mesh
  63776. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63777. * * 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
  63778. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63781. * * Remember you can only change the shape positions, not their number when updating a polygon
  63782. * @param name defines the name of the mesh
  63783. * @param options defines the options used to create the mesh
  63784. * @param scene defines the hosting scene
  63785. * @param earcutInjection can be used to inject your own earcut reference
  63786. * @returns the polygon mesh
  63787. */
  63788. static CreatePolygon(name: string, options: {
  63789. shape: Vector3[];
  63790. holes?: Vector3[][];
  63791. depth?: number;
  63792. faceUV?: Vector4[];
  63793. faceColors?: Color4[];
  63794. updatable?: boolean;
  63795. sideOrientation?: number;
  63796. frontUVs?: Vector4;
  63797. backUVs?: Vector4;
  63798. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63799. /**
  63800. * Creates an extruded polygon mesh, with depth in the Y direction.
  63801. * * 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)
  63802. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63803. * @param name defines the name of the mesh
  63804. * @param options defines the options used to create the mesh
  63805. * @param scene defines the hosting scene
  63806. * @param earcutInjection can be used to inject your own earcut reference
  63807. * @returns the polygon mesh
  63808. */
  63809. static ExtrudePolygon(name: string, options: {
  63810. shape: Vector3[];
  63811. holes?: Vector3[][];
  63812. depth?: number;
  63813. faceUV?: Vector4[];
  63814. faceColors?: Color4[];
  63815. updatable?: boolean;
  63816. sideOrientation?: number;
  63817. frontUVs?: Vector4;
  63818. backUVs?: Vector4;
  63819. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63820. }
  63821. }
  63822. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63823. import { Scene } from "babylonjs/scene";
  63824. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63825. import { Mesh } from "babylonjs/Meshes/mesh";
  63826. import { Nullable } from "babylonjs/types";
  63827. /**
  63828. * Class containing static functions to help procedurally build meshes
  63829. */
  63830. export class LatheBuilder {
  63831. /**
  63832. * Creates lathe mesh.
  63833. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63834. * * 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
  63835. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63836. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63837. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63838. * * 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
  63839. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63840. * * 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
  63841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63845. * @param name defines the name of the mesh
  63846. * @param options defines the options used to create the mesh
  63847. * @param scene defines the hosting scene
  63848. * @returns the lathe mesh
  63849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63850. */
  63851. static CreateLathe(name: string, options: {
  63852. shape: Vector3[];
  63853. radius?: number;
  63854. tessellation?: number;
  63855. clip?: number;
  63856. arc?: number;
  63857. closed?: boolean;
  63858. updatable?: boolean;
  63859. sideOrientation?: number;
  63860. frontUVs?: Vector4;
  63861. backUVs?: Vector4;
  63862. cap?: number;
  63863. invertUV?: boolean;
  63864. }, scene?: Nullable<Scene>): Mesh;
  63865. }
  63866. }
  63867. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63868. import { Nullable } from "babylonjs/types";
  63869. import { Scene } from "babylonjs/scene";
  63870. import { Vector4 } from "babylonjs/Maths/math.vector";
  63871. import { Mesh } from "babylonjs/Meshes/mesh";
  63872. /**
  63873. * Class containing static functions to help procedurally build meshes
  63874. */
  63875. export class TiledPlaneBuilder {
  63876. /**
  63877. * Creates a tiled plane mesh
  63878. * * The parameter `pattern` will, depending on value, do nothing or
  63879. * * * flip (reflect about central vertical) alternate tiles across and up
  63880. * * * flip every tile on alternate rows
  63881. * * * rotate (180 degs) alternate tiles across and up
  63882. * * * rotate every tile on alternate rows
  63883. * * * flip and rotate alternate tiles across and up
  63884. * * * flip and rotate every tile on alternate rows
  63885. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63886. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63889. * * 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)
  63890. * * 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)
  63891. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63892. * @param name defines the name of the mesh
  63893. * @param options defines the options used to create the mesh
  63894. * @param scene defines the hosting scene
  63895. * @returns the box mesh
  63896. */
  63897. static CreateTiledPlane(name: string, options: {
  63898. pattern?: number;
  63899. tileSize?: number;
  63900. tileWidth?: number;
  63901. tileHeight?: number;
  63902. size?: number;
  63903. width?: number;
  63904. height?: number;
  63905. alignHorizontal?: number;
  63906. alignVertical?: number;
  63907. sideOrientation?: number;
  63908. frontUVs?: Vector4;
  63909. backUVs?: Vector4;
  63910. updatable?: boolean;
  63911. }, scene?: Nullable<Scene>): Mesh;
  63912. }
  63913. }
  63914. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63915. import { Nullable } from "babylonjs/types";
  63916. import { Scene } from "babylonjs/scene";
  63917. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63918. import { Mesh } from "babylonjs/Meshes/mesh";
  63919. /**
  63920. * Class containing static functions to help procedurally build meshes
  63921. */
  63922. export class TubeBuilder {
  63923. /**
  63924. * Creates a tube mesh.
  63925. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63926. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63927. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63928. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63929. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63930. * * 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)
  63931. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63932. * * 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
  63933. * * 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
  63934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63938. * @param name defines the name of the mesh
  63939. * @param options defines the options used to create the mesh
  63940. * @param scene defines the hosting scene
  63941. * @returns the tube mesh
  63942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63943. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63944. */
  63945. static CreateTube(name: string, options: {
  63946. path: Vector3[];
  63947. radius?: number;
  63948. tessellation?: number;
  63949. radiusFunction?: {
  63950. (i: number, distance: number): number;
  63951. };
  63952. cap?: number;
  63953. arc?: number;
  63954. updatable?: boolean;
  63955. sideOrientation?: number;
  63956. frontUVs?: Vector4;
  63957. backUVs?: Vector4;
  63958. instance?: Mesh;
  63959. invertUV?: boolean;
  63960. }, scene?: Nullable<Scene>): Mesh;
  63961. }
  63962. }
  63963. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63964. import { Scene } from "babylonjs/scene";
  63965. import { Vector4 } from "babylonjs/Maths/math.vector";
  63966. import { Mesh } from "babylonjs/Meshes/mesh";
  63967. import { Nullable } from "babylonjs/types";
  63968. /**
  63969. * Class containing static functions to help procedurally build meshes
  63970. */
  63971. export class IcoSphereBuilder {
  63972. /**
  63973. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63974. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63975. * * 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`)
  63976. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63977. * * 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
  63978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63979. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63981. * @param name defines the name of the mesh
  63982. * @param options defines the options used to create the mesh
  63983. * @param scene defines the hosting scene
  63984. * @returns the icosahedron mesh
  63985. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63986. */
  63987. static CreateIcoSphere(name: string, options: {
  63988. radius?: number;
  63989. radiusX?: number;
  63990. radiusY?: number;
  63991. radiusZ?: number;
  63992. flat?: boolean;
  63993. subdivisions?: number;
  63994. sideOrientation?: number;
  63995. frontUVs?: Vector4;
  63996. backUVs?: Vector4;
  63997. updatable?: boolean;
  63998. }, scene?: Nullable<Scene>): Mesh;
  63999. }
  64000. }
  64001. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64002. import { Vector3 } from "babylonjs/Maths/math.vector";
  64003. import { Mesh } from "babylonjs/Meshes/mesh";
  64004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64005. /**
  64006. * Class containing static functions to help procedurally build meshes
  64007. */
  64008. export class DecalBuilder {
  64009. /**
  64010. * Creates a decal mesh.
  64011. * 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
  64012. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64013. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64014. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64015. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64016. * @param name defines the name of the mesh
  64017. * @param sourceMesh defines the mesh where the decal must be applied
  64018. * @param options defines the options used to create the mesh
  64019. * @param scene defines the hosting scene
  64020. * @returns the decal mesh
  64021. * @see https://doc.babylonjs.com/how_to/decals
  64022. */
  64023. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64024. position?: Vector3;
  64025. normal?: Vector3;
  64026. size?: Vector3;
  64027. angle?: number;
  64028. }): Mesh;
  64029. }
  64030. }
  64031. declare module "babylonjs/Meshes/meshBuilder" {
  64032. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64033. import { Nullable } from "babylonjs/types";
  64034. import { Scene } from "babylonjs/scene";
  64035. import { Mesh } from "babylonjs/Meshes/mesh";
  64036. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64037. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64039. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64040. import { Plane } from "babylonjs/Maths/math.plane";
  64041. /**
  64042. * Class containing static functions to help procedurally build meshes
  64043. */
  64044. export class MeshBuilder {
  64045. /**
  64046. * Creates a box mesh
  64047. * * The parameter `size` sets the size (float) of each box side (default 1)
  64048. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64049. * * 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)
  64050. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64055. * @param name defines the name of the mesh
  64056. * @param options defines the options used to create the mesh
  64057. * @param scene defines the hosting scene
  64058. * @returns the box mesh
  64059. */
  64060. static CreateBox(name: string, options: {
  64061. size?: number;
  64062. width?: number;
  64063. height?: number;
  64064. depth?: number;
  64065. faceUV?: Vector4[];
  64066. faceColors?: Color4[];
  64067. sideOrientation?: number;
  64068. frontUVs?: Vector4;
  64069. backUVs?: Vector4;
  64070. updatable?: boolean;
  64071. }, scene?: Nullable<Scene>): Mesh;
  64072. /**
  64073. * Creates a tiled box mesh
  64074. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64076. * @param name defines the name of the mesh
  64077. * @param options defines the options used to create the mesh
  64078. * @param scene defines the hosting scene
  64079. * @returns the tiled box mesh
  64080. */
  64081. static CreateTiledBox(name: string, options: {
  64082. pattern?: number;
  64083. size?: number;
  64084. width?: number;
  64085. height?: number;
  64086. depth: number;
  64087. tileSize?: number;
  64088. tileWidth?: number;
  64089. tileHeight?: number;
  64090. faceUV?: Vector4[];
  64091. faceColors?: Color4[];
  64092. alignHorizontal?: number;
  64093. alignVertical?: number;
  64094. sideOrientation?: number;
  64095. updatable?: boolean;
  64096. }, scene?: Nullable<Scene>): Mesh;
  64097. /**
  64098. * Creates a sphere mesh
  64099. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64100. * * 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`)
  64101. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64102. * * 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
  64103. * * 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)
  64104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64107. * @param name defines the name of the mesh
  64108. * @param options defines the options used to create the mesh
  64109. * @param scene defines the hosting scene
  64110. * @returns the sphere mesh
  64111. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64112. */
  64113. static CreateSphere(name: string, options: {
  64114. segments?: number;
  64115. diameter?: number;
  64116. diameterX?: number;
  64117. diameterY?: number;
  64118. diameterZ?: number;
  64119. arc?: number;
  64120. slice?: number;
  64121. sideOrientation?: number;
  64122. frontUVs?: Vector4;
  64123. backUVs?: Vector4;
  64124. updatable?: boolean;
  64125. }, scene?: Nullable<Scene>): Mesh;
  64126. /**
  64127. * Creates a plane polygonal mesh. By default, this is a disc
  64128. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64129. * * 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
  64130. * * 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
  64131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64134. * @param name defines the name of the mesh
  64135. * @param options defines the options used to create the mesh
  64136. * @param scene defines the hosting scene
  64137. * @returns the plane polygonal mesh
  64138. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64139. */
  64140. static CreateDisc(name: string, options: {
  64141. radius?: number;
  64142. tessellation?: number;
  64143. arc?: number;
  64144. updatable?: boolean;
  64145. sideOrientation?: number;
  64146. frontUVs?: Vector4;
  64147. backUVs?: Vector4;
  64148. }, scene?: Nullable<Scene>): Mesh;
  64149. /**
  64150. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64151. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64152. * * 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`)
  64153. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64154. * * 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
  64155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64158. * @param name defines the name of the mesh
  64159. * @param options defines the options used to create the mesh
  64160. * @param scene defines the hosting scene
  64161. * @returns the icosahedron mesh
  64162. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64163. */
  64164. static CreateIcoSphere(name: string, options: {
  64165. radius?: number;
  64166. radiusX?: number;
  64167. radiusY?: number;
  64168. radiusZ?: number;
  64169. flat?: boolean;
  64170. subdivisions?: number;
  64171. sideOrientation?: number;
  64172. frontUVs?: Vector4;
  64173. backUVs?: Vector4;
  64174. updatable?: boolean;
  64175. }, scene?: Nullable<Scene>): Mesh;
  64176. /**
  64177. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64178. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64179. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64180. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64181. * * 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
  64182. * * 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
  64183. * * 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
  64184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64187. * * 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
  64188. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64189. * * 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
  64190. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64192. * @param name defines the name of the mesh
  64193. * @param options defines the options used to create the mesh
  64194. * @param scene defines the hosting scene
  64195. * @returns the ribbon mesh
  64196. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64198. */
  64199. static CreateRibbon(name: string, options: {
  64200. pathArray: Vector3[][];
  64201. closeArray?: boolean;
  64202. closePath?: boolean;
  64203. offset?: number;
  64204. updatable?: boolean;
  64205. sideOrientation?: number;
  64206. frontUVs?: Vector4;
  64207. backUVs?: Vector4;
  64208. instance?: Mesh;
  64209. invertUV?: boolean;
  64210. uvs?: Vector2[];
  64211. colors?: Color4[];
  64212. }, scene?: Nullable<Scene>): Mesh;
  64213. /**
  64214. * Creates a cylinder or a cone mesh
  64215. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64216. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64217. * * 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.
  64218. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64219. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64220. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64221. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64222. * * 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).
  64223. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64224. * * 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).
  64225. * * 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
  64226. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64227. * * 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
  64228. * * 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.
  64229. * * If `enclose` is false, a ring surface is one element.
  64230. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64231. * * 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
  64232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64235. * @param name defines the name of the mesh
  64236. * @param options defines the options used to create the mesh
  64237. * @param scene defines the hosting scene
  64238. * @returns the cylinder mesh
  64239. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64240. */
  64241. static CreateCylinder(name: string, options: {
  64242. height?: number;
  64243. diameterTop?: number;
  64244. diameterBottom?: number;
  64245. diameter?: number;
  64246. tessellation?: number;
  64247. subdivisions?: number;
  64248. arc?: number;
  64249. faceColors?: Color4[];
  64250. faceUV?: Vector4[];
  64251. updatable?: boolean;
  64252. hasRings?: boolean;
  64253. enclose?: boolean;
  64254. cap?: number;
  64255. sideOrientation?: number;
  64256. frontUVs?: Vector4;
  64257. backUVs?: Vector4;
  64258. }, scene?: Nullable<Scene>): Mesh;
  64259. /**
  64260. * Creates a torus mesh
  64261. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64262. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64263. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64265. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64267. * @param name defines the name of the mesh
  64268. * @param options defines the options used to create the mesh
  64269. * @param scene defines the hosting scene
  64270. * @returns the torus mesh
  64271. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64272. */
  64273. static CreateTorus(name: string, options: {
  64274. diameter?: number;
  64275. thickness?: number;
  64276. tessellation?: number;
  64277. updatable?: boolean;
  64278. sideOrientation?: number;
  64279. frontUVs?: Vector4;
  64280. backUVs?: Vector4;
  64281. }, scene?: Nullable<Scene>): Mesh;
  64282. /**
  64283. * Creates a torus knot mesh
  64284. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64285. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64286. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64287. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64291. * @param name defines the name of the mesh
  64292. * @param options defines the options used to create the mesh
  64293. * @param scene defines the hosting scene
  64294. * @returns the torus knot mesh
  64295. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64296. */
  64297. static CreateTorusKnot(name: string, options: {
  64298. radius?: number;
  64299. tube?: number;
  64300. radialSegments?: number;
  64301. tubularSegments?: number;
  64302. p?: number;
  64303. q?: number;
  64304. updatable?: boolean;
  64305. sideOrientation?: number;
  64306. frontUVs?: Vector4;
  64307. backUVs?: Vector4;
  64308. }, scene?: Nullable<Scene>): Mesh;
  64309. /**
  64310. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64311. * * 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
  64312. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64313. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64314. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64315. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64316. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64317. * * 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
  64318. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64321. * @param name defines the name of the new line system
  64322. * @param options defines the options used to create the line system
  64323. * @param scene defines the hosting scene
  64324. * @returns a new line system mesh
  64325. */
  64326. static CreateLineSystem(name: string, options: {
  64327. lines: Vector3[][];
  64328. updatable?: boolean;
  64329. instance?: Nullable<LinesMesh>;
  64330. colors?: Nullable<Color4[][]>;
  64331. useVertexAlpha?: boolean;
  64332. }, scene: Nullable<Scene>): LinesMesh;
  64333. /**
  64334. * Creates a line mesh
  64335. * 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
  64336. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64337. * * The parameter `points` is an array successive Vector3
  64338. * * 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
  64339. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64340. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64341. * * When updating an instance, remember that only point positions can change, not the number of points
  64342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64344. * @param name defines the name of the new line system
  64345. * @param options defines the options used to create the line system
  64346. * @param scene defines the hosting scene
  64347. * @returns a new line mesh
  64348. */
  64349. static CreateLines(name: string, options: {
  64350. points: Vector3[];
  64351. updatable?: boolean;
  64352. instance?: Nullable<LinesMesh>;
  64353. colors?: Color4[];
  64354. useVertexAlpha?: boolean;
  64355. }, scene?: Nullable<Scene>): LinesMesh;
  64356. /**
  64357. * Creates a dashed line mesh
  64358. * * 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
  64359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64360. * * The parameter `points` is an array successive Vector3
  64361. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64362. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64363. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64364. * * 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
  64365. * * When updating an instance, remember that only point positions can change, not the number of points
  64366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64367. * @param name defines the name of the mesh
  64368. * @param options defines the options used to create the mesh
  64369. * @param scene defines the hosting scene
  64370. * @returns the dashed line mesh
  64371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64372. */
  64373. static CreateDashedLines(name: string, options: {
  64374. points: Vector3[];
  64375. dashSize?: number;
  64376. gapSize?: number;
  64377. dashNb?: number;
  64378. updatable?: boolean;
  64379. instance?: LinesMesh;
  64380. }, scene?: Nullable<Scene>): LinesMesh;
  64381. /**
  64382. * 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.
  64383. * * 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.
  64384. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64385. * * 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.
  64386. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64387. * * 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
  64388. * * 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
  64389. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64390. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64391. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64392. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64394. * @param name defines the name of the mesh
  64395. * @param options defines the options used to create the mesh
  64396. * @param scene defines the hosting scene
  64397. * @returns the extruded shape mesh
  64398. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64400. */
  64401. static ExtrudeShape(name: string, options: {
  64402. shape: Vector3[];
  64403. path: Vector3[];
  64404. scale?: number;
  64405. rotation?: number;
  64406. cap?: number;
  64407. updatable?: boolean;
  64408. sideOrientation?: number;
  64409. frontUVs?: Vector4;
  64410. backUVs?: Vector4;
  64411. instance?: Mesh;
  64412. invertUV?: boolean;
  64413. }, scene?: Nullable<Scene>): Mesh;
  64414. /**
  64415. * Creates an custom extruded shape mesh.
  64416. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64417. * * 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.
  64418. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64419. * * 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
  64420. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64421. * * 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
  64422. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64423. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64424. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64425. * * 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
  64426. * * 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
  64427. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64430. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64432. * @param name defines the name of the mesh
  64433. * @param options defines the options used to create the mesh
  64434. * @param scene defines the hosting scene
  64435. * @returns the custom extruded shape mesh
  64436. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64437. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64438. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64439. */
  64440. static ExtrudeShapeCustom(name: string, options: {
  64441. shape: Vector3[];
  64442. path: Vector3[];
  64443. scaleFunction?: any;
  64444. rotationFunction?: any;
  64445. ribbonCloseArray?: boolean;
  64446. ribbonClosePath?: boolean;
  64447. cap?: number;
  64448. updatable?: boolean;
  64449. sideOrientation?: number;
  64450. frontUVs?: Vector4;
  64451. backUVs?: Vector4;
  64452. instance?: Mesh;
  64453. invertUV?: boolean;
  64454. }, scene?: Nullable<Scene>): Mesh;
  64455. /**
  64456. * Creates lathe mesh.
  64457. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64458. * * 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
  64459. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64460. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64461. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64462. * * 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
  64463. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64464. * * 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
  64465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64467. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64469. * @param name defines the name of the mesh
  64470. * @param options defines the options used to create the mesh
  64471. * @param scene defines the hosting scene
  64472. * @returns the lathe mesh
  64473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64474. */
  64475. static CreateLathe(name: string, options: {
  64476. shape: Vector3[];
  64477. radius?: number;
  64478. tessellation?: number;
  64479. clip?: number;
  64480. arc?: number;
  64481. closed?: boolean;
  64482. updatable?: boolean;
  64483. sideOrientation?: number;
  64484. frontUVs?: Vector4;
  64485. backUVs?: Vector4;
  64486. cap?: number;
  64487. invertUV?: boolean;
  64488. }, scene?: Nullable<Scene>): Mesh;
  64489. /**
  64490. * Creates a tiled plane mesh
  64491. * * You can set a limited pattern arrangement with the tiles
  64492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64495. * @param name defines the name of the mesh
  64496. * @param options defines the options used to create the mesh
  64497. * @param scene defines the hosting scene
  64498. * @returns the plane mesh
  64499. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64500. */
  64501. static CreateTiledPlane(name: string, options: {
  64502. pattern?: number;
  64503. tileSize?: number;
  64504. tileWidth?: number;
  64505. tileHeight?: number;
  64506. size?: number;
  64507. width?: number;
  64508. height?: number;
  64509. alignHorizontal?: number;
  64510. alignVertical?: number;
  64511. sideOrientation?: number;
  64512. frontUVs?: Vector4;
  64513. backUVs?: Vector4;
  64514. updatable?: boolean;
  64515. }, scene?: Nullable<Scene>): Mesh;
  64516. /**
  64517. * Creates a plane mesh
  64518. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64519. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64520. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64524. * @param name defines the name of the mesh
  64525. * @param options defines the options used to create the mesh
  64526. * @param scene defines the hosting scene
  64527. * @returns the plane mesh
  64528. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64529. */
  64530. static CreatePlane(name: string, options: {
  64531. size?: number;
  64532. width?: number;
  64533. height?: number;
  64534. sideOrientation?: number;
  64535. frontUVs?: Vector4;
  64536. backUVs?: Vector4;
  64537. updatable?: boolean;
  64538. sourcePlane?: Plane;
  64539. }, scene?: Nullable<Scene>): Mesh;
  64540. /**
  64541. * Creates a ground mesh
  64542. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64543. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64545. * @param name defines the name of the mesh
  64546. * @param options defines the options used to create the mesh
  64547. * @param scene defines the hosting scene
  64548. * @returns the ground mesh
  64549. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64550. */
  64551. static CreateGround(name: string, options: {
  64552. width?: number;
  64553. height?: number;
  64554. subdivisions?: number;
  64555. subdivisionsX?: number;
  64556. subdivisionsY?: number;
  64557. updatable?: boolean;
  64558. }, scene?: Nullable<Scene>): Mesh;
  64559. /**
  64560. * Creates a tiled ground mesh
  64561. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64562. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64563. * * 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
  64564. * * 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
  64565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64566. * @param name defines the name of the mesh
  64567. * @param options defines the options used to create the mesh
  64568. * @param scene defines the hosting scene
  64569. * @returns the tiled ground mesh
  64570. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64571. */
  64572. static CreateTiledGround(name: string, options: {
  64573. xmin: number;
  64574. zmin: number;
  64575. xmax: number;
  64576. zmax: number;
  64577. subdivisions?: {
  64578. w: number;
  64579. h: number;
  64580. };
  64581. precision?: {
  64582. w: number;
  64583. h: number;
  64584. };
  64585. updatable?: boolean;
  64586. }, scene?: Nullable<Scene>): Mesh;
  64587. /**
  64588. * Creates a ground mesh from a height map
  64589. * * The parameter `url` sets the URL of the height map image resource.
  64590. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64591. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64592. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64593. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64594. * * 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.
  64595. * * 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).
  64596. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64598. * @param name defines the name of the mesh
  64599. * @param url defines the url to the height map
  64600. * @param options defines the options used to create the mesh
  64601. * @param scene defines the hosting scene
  64602. * @returns the ground mesh
  64603. * @see https://doc.babylonjs.com/babylon101/height_map
  64604. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64605. */
  64606. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64607. width?: number;
  64608. height?: number;
  64609. subdivisions?: number;
  64610. minHeight?: number;
  64611. maxHeight?: number;
  64612. colorFilter?: Color3;
  64613. alphaFilter?: number;
  64614. updatable?: boolean;
  64615. onReady?: (mesh: GroundMesh) => void;
  64616. }, scene?: Nullable<Scene>): GroundMesh;
  64617. /**
  64618. * Creates a polygon mesh
  64619. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64620. * * 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
  64621. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64624. * * Remember you can only change the shape positions, not their number when updating a polygon
  64625. * @param name defines the name of the mesh
  64626. * @param options defines the options used to create the mesh
  64627. * @param scene defines the hosting scene
  64628. * @param earcutInjection can be used to inject your own earcut reference
  64629. * @returns the polygon mesh
  64630. */
  64631. static CreatePolygon(name: string, options: {
  64632. shape: Vector3[];
  64633. holes?: Vector3[][];
  64634. depth?: number;
  64635. faceUV?: Vector4[];
  64636. faceColors?: Color4[];
  64637. updatable?: boolean;
  64638. sideOrientation?: number;
  64639. frontUVs?: Vector4;
  64640. backUVs?: Vector4;
  64641. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64642. /**
  64643. * Creates an extruded polygon mesh, with depth in the Y direction.
  64644. * * 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)
  64645. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64646. * @param name defines the name of the mesh
  64647. * @param options defines the options used to create the mesh
  64648. * @param scene defines the hosting scene
  64649. * @param earcutInjection can be used to inject your own earcut reference
  64650. * @returns the polygon mesh
  64651. */
  64652. static ExtrudePolygon(name: string, options: {
  64653. shape: Vector3[];
  64654. holes?: Vector3[][];
  64655. depth?: number;
  64656. faceUV?: Vector4[];
  64657. faceColors?: Color4[];
  64658. updatable?: boolean;
  64659. sideOrientation?: number;
  64660. frontUVs?: Vector4;
  64661. backUVs?: Vector4;
  64662. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64663. /**
  64664. * Creates a tube mesh.
  64665. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64666. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64667. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64668. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64669. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64670. * * 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)
  64671. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64672. * * 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
  64673. * * 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
  64674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64678. * @param name defines the name of the mesh
  64679. * @param options defines the options used to create the mesh
  64680. * @param scene defines the hosting scene
  64681. * @returns the tube mesh
  64682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64683. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64684. */
  64685. static CreateTube(name: string, options: {
  64686. path: Vector3[];
  64687. radius?: number;
  64688. tessellation?: number;
  64689. radiusFunction?: {
  64690. (i: number, distance: number): number;
  64691. };
  64692. cap?: number;
  64693. arc?: number;
  64694. updatable?: boolean;
  64695. sideOrientation?: number;
  64696. frontUVs?: Vector4;
  64697. backUVs?: Vector4;
  64698. instance?: Mesh;
  64699. invertUV?: boolean;
  64700. }, scene?: Nullable<Scene>): Mesh;
  64701. /**
  64702. * Creates a polyhedron mesh
  64703. * * 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
  64704. * * The parameter `size` (positive float, default 1) sets the polygon size
  64705. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64706. * * 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`
  64707. * * 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
  64708. * * 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)`)
  64709. * * 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
  64710. * * 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
  64711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64714. * @param name defines the name of the mesh
  64715. * @param options defines the options used to create the mesh
  64716. * @param scene defines the hosting scene
  64717. * @returns the polyhedron mesh
  64718. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64719. */
  64720. static CreatePolyhedron(name: string, options: {
  64721. type?: number;
  64722. size?: number;
  64723. sizeX?: number;
  64724. sizeY?: number;
  64725. sizeZ?: number;
  64726. custom?: any;
  64727. faceUV?: Vector4[];
  64728. faceColors?: Color4[];
  64729. flat?: boolean;
  64730. updatable?: boolean;
  64731. sideOrientation?: number;
  64732. frontUVs?: Vector4;
  64733. backUVs?: Vector4;
  64734. }, scene?: Nullable<Scene>): Mesh;
  64735. /**
  64736. * Creates a decal mesh.
  64737. * 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
  64738. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64739. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64740. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64741. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64742. * @param name defines the name of the mesh
  64743. * @param sourceMesh defines the mesh where the decal must be applied
  64744. * @param options defines the options used to create the mesh
  64745. * @param scene defines the hosting scene
  64746. * @returns the decal mesh
  64747. * @see https://doc.babylonjs.com/how_to/decals
  64748. */
  64749. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64750. position?: Vector3;
  64751. normal?: Vector3;
  64752. size?: Vector3;
  64753. angle?: number;
  64754. }): Mesh;
  64755. }
  64756. }
  64757. declare module "babylonjs/Meshes/meshSimplification" {
  64758. import { Mesh } from "babylonjs/Meshes/mesh";
  64759. /**
  64760. * A simplifier interface for future simplification implementations
  64761. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64762. */
  64763. export interface ISimplifier {
  64764. /**
  64765. * Simplification of a given mesh according to the given settings.
  64766. * Since this requires computation, it is assumed that the function runs async.
  64767. * @param settings The settings of the simplification, including quality and distance
  64768. * @param successCallback A callback that will be called after the mesh was simplified.
  64769. * @param errorCallback in case of an error, this callback will be called. optional.
  64770. */
  64771. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64772. }
  64773. /**
  64774. * Expected simplification settings.
  64775. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64776. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64777. */
  64778. export interface ISimplificationSettings {
  64779. /**
  64780. * Gets or sets the expected quality
  64781. */
  64782. quality: number;
  64783. /**
  64784. * Gets or sets the distance when this optimized version should be used
  64785. */
  64786. distance: number;
  64787. /**
  64788. * Gets an already optimized mesh
  64789. */
  64790. optimizeMesh?: boolean;
  64791. }
  64792. /**
  64793. * Class used to specify simplification options
  64794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64795. */
  64796. export class SimplificationSettings implements ISimplificationSettings {
  64797. /** expected quality */
  64798. quality: number;
  64799. /** distance when this optimized version should be used */
  64800. distance: number;
  64801. /** already optimized mesh */
  64802. optimizeMesh?: boolean | undefined;
  64803. /**
  64804. * Creates a SimplificationSettings
  64805. * @param quality expected quality
  64806. * @param distance distance when this optimized version should be used
  64807. * @param optimizeMesh already optimized mesh
  64808. */
  64809. constructor(
  64810. /** expected quality */
  64811. quality: number,
  64812. /** distance when this optimized version should be used */
  64813. distance: number,
  64814. /** already optimized mesh */
  64815. optimizeMesh?: boolean | undefined);
  64816. }
  64817. /**
  64818. * Interface used to define a simplification task
  64819. */
  64820. export interface ISimplificationTask {
  64821. /**
  64822. * Array of settings
  64823. */
  64824. settings: Array<ISimplificationSettings>;
  64825. /**
  64826. * Simplification type
  64827. */
  64828. simplificationType: SimplificationType;
  64829. /**
  64830. * Mesh to simplify
  64831. */
  64832. mesh: Mesh;
  64833. /**
  64834. * Callback called on success
  64835. */
  64836. successCallback?: () => void;
  64837. /**
  64838. * Defines if parallel processing can be used
  64839. */
  64840. parallelProcessing: boolean;
  64841. }
  64842. /**
  64843. * Queue used to order the simplification tasks
  64844. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64845. */
  64846. export class SimplificationQueue {
  64847. private _simplificationArray;
  64848. /**
  64849. * Gets a boolean indicating that the process is still running
  64850. */
  64851. running: boolean;
  64852. /**
  64853. * Creates a new queue
  64854. */
  64855. constructor();
  64856. /**
  64857. * Adds a new simplification task
  64858. * @param task defines a task to add
  64859. */
  64860. addTask(task: ISimplificationTask): void;
  64861. /**
  64862. * Execute next task
  64863. */
  64864. executeNext(): void;
  64865. /**
  64866. * Execute a simplification task
  64867. * @param task defines the task to run
  64868. */
  64869. runSimplification(task: ISimplificationTask): void;
  64870. private getSimplifier;
  64871. }
  64872. /**
  64873. * The implemented types of simplification
  64874. * At the moment only Quadratic Error Decimation is implemented
  64875. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64876. */
  64877. export enum SimplificationType {
  64878. /** Quadratic error decimation */
  64879. QUADRATIC = 0
  64880. }
  64881. }
  64882. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64883. import { Scene } from "babylonjs/scene";
  64884. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64885. import { ISceneComponent } from "babylonjs/sceneComponent";
  64886. module "babylonjs/scene" {
  64887. interface Scene {
  64888. /** @hidden (Backing field) */
  64889. _simplificationQueue: SimplificationQueue;
  64890. /**
  64891. * Gets or sets the simplification queue attached to the scene
  64892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64893. */
  64894. simplificationQueue: SimplificationQueue;
  64895. }
  64896. }
  64897. module "babylonjs/Meshes/mesh" {
  64898. interface Mesh {
  64899. /**
  64900. * Simplify the mesh according to the given array of settings.
  64901. * Function will return immediately and will simplify async
  64902. * @param settings a collection of simplification settings
  64903. * @param parallelProcessing should all levels calculate parallel or one after the other
  64904. * @param simplificationType the type of simplification to run
  64905. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64906. * @returns the current mesh
  64907. */
  64908. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64909. }
  64910. }
  64911. /**
  64912. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64913. * created in a scene
  64914. */
  64915. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64916. /**
  64917. * The component name helpfull to identify the component in the list of scene components.
  64918. */
  64919. readonly name: string;
  64920. /**
  64921. * The scene the component belongs to.
  64922. */
  64923. scene: Scene;
  64924. /**
  64925. * Creates a new instance of the component for the given scene
  64926. * @param scene Defines the scene to register the component in
  64927. */
  64928. constructor(scene: Scene);
  64929. /**
  64930. * Registers the component in a given scene
  64931. */
  64932. register(): void;
  64933. /**
  64934. * Rebuilds the elements related to this component in case of
  64935. * context lost for instance.
  64936. */
  64937. rebuild(): void;
  64938. /**
  64939. * Disposes the component and the associated ressources
  64940. */
  64941. dispose(): void;
  64942. private _beforeCameraUpdate;
  64943. }
  64944. }
  64945. declare module "babylonjs/Meshes/Builders/index" {
  64946. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64947. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64948. export * from "babylonjs/Meshes/Builders/discBuilder";
  64949. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64950. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64951. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64952. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64953. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64954. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64955. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64956. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64957. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64958. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64959. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64960. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64961. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64962. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64963. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64964. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64965. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64966. }
  64967. declare module "babylonjs/Meshes/index" {
  64968. export * from "babylonjs/Meshes/abstractMesh";
  64969. export * from "babylonjs/Meshes/buffer";
  64970. export * from "babylonjs/Meshes/Compression/index";
  64971. export * from "babylonjs/Meshes/csg";
  64972. export * from "babylonjs/Meshes/geometry";
  64973. export * from "babylonjs/Meshes/groundMesh";
  64974. export * from "babylonjs/Meshes/trailMesh";
  64975. export * from "babylonjs/Meshes/instancedMesh";
  64976. export * from "babylonjs/Meshes/linesMesh";
  64977. export * from "babylonjs/Meshes/mesh";
  64978. export * from "babylonjs/Meshes/mesh.vertexData";
  64979. export * from "babylonjs/Meshes/meshBuilder";
  64980. export * from "babylonjs/Meshes/meshSimplification";
  64981. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64982. export * from "babylonjs/Meshes/polygonMesh";
  64983. export * from "babylonjs/Meshes/subMesh";
  64984. export * from "babylonjs/Meshes/meshLODLevel";
  64985. export * from "babylonjs/Meshes/transformNode";
  64986. export * from "babylonjs/Meshes/Builders/index";
  64987. export * from "babylonjs/Meshes/dataBuffer";
  64988. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64989. }
  64990. declare module "babylonjs/Morph/index" {
  64991. export * from "babylonjs/Morph/morphTarget";
  64992. export * from "babylonjs/Morph/morphTargetManager";
  64993. }
  64994. declare module "babylonjs/Navigation/INavigationEngine" {
  64995. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64996. import { Vector3 } from "babylonjs/Maths/math";
  64997. import { Mesh } from "babylonjs/Meshes/mesh";
  64998. import { Scene } from "babylonjs/scene";
  64999. /**
  65000. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65001. */
  65002. export interface INavigationEnginePlugin {
  65003. /**
  65004. * plugin name
  65005. */
  65006. name: string;
  65007. /**
  65008. * Creates a navigation mesh
  65009. * @param meshes array of all the geometry used to compute the navigatio mesh
  65010. * @param parameters bunch of parameters used to filter geometry
  65011. */
  65012. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65013. /**
  65014. * Create a navigation mesh debug mesh
  65015. * @param scene is where the mesh will be added
  65016. * @returns debug display mesh
  65017. */
  65018. createDebugNavMesh(scene: Scene): Mesh;
  65019. /**
  65020. * Get a navigation mesh constrained position, closest to the parameter position
  65021. * @param position world position
  65022. * @returns the closest point to position constrained by the navigation mesh
  65023. */
  65024. getClosestPoint(position: Vector3): Vector3;
  65025. /**
  65026. * Get a navigation mesh constrained position, within a particular radius
  65027. * @param position world position
  65028. * @param maxRadius the maximum distance to the constrained world position
  65029. * @returns the closest point to position constrained by the navigation mesh
  65030. */
  65031. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65032. /**
  65033. * Compute the final position from a segment made of destination-position
  65034. * @param position world position
  65035. * @param destination world position
  65036. * @returns the resulting point along the navmesh
  65037. */
  65038. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65039. /**
  65040. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65041. * @param start world position
  65042. * @param end world position
  65043. * @returns array containing world position composing the path
  65044. */
  65045. computePath(start: Vector3, end: Vector3): Vector3[];
  65046. /**
  65047. * If this plugin is supported
  65048. * @returns true if plugin is supported
  65049. */
  65050. isSupported(): boolean;
  65051. /**
  65052. * Create a new Crowd so you can add agents
  65053. * @param maxAgents the maximum agent count in the crowd
  65054. * @param maxAgentRadius the maximum radius an agent can have
  65055. * @param scene to attach the crowd to
  65056. * @returns the crowd you can add agents to
  65057. */
  65058. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65059. /**
  65060. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65061. * The queries will try to find a solution within those bounds
  65062. * default is (1,1,1)
  65063. * @param extent x,y,z value that define the extent around the queries point of reference
  65064. */
  65065. setDefaultQueryExtent(extent: Vector3): void;
  65066. /**
  65067. * Get the Bounding box extent specified by setDefaultQueryExtent
  65068. * @returns the box extent values
  65069. */
  65070. getDefaultQueryExtent(): Vector3;
  65071. /**
  65072. * Release all resources
  65073. */
  65074. dispose(): void;
  65075. }
  65076. /**
  65077. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65078. */
  65079. export interface ICrowd {
  65080. /**
  65081. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65082. * You can attach anything to that node. The node position is updated in the scene update tick.
  65083. * @param pos world position that will be constrained by the navigation mesh
  65084. * @param parameters agent parameters
  65085. * @param transform hooked to the agent that will be update by the scene
  65086. * @returns agent index
  65087. */
  65088. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65089. /**
  65090. * Returns the agent position in world space
  65091. * @param index agent index returned by addAgent
  65092. * @returns world space position
  65093. */
  65094. getAgentPosition(index: number): Vector3;
  65095. /**
  65096. * Gets the agent velocity in world space
  65097. * @param index agent index returned by addAgent
  65098. * @returns world space velocity
  65099. */
  65100. getAgentVelocity(index: number): Vector3;
  65101. /**
  65102. * remove a particular agent previously created
  65103. * @param index agent index returned by addAgent
  65104. */
  65105. removeAgent(index: number): void;
  65106. /**
  65107. * get the list of all agents attached to this crowd
  65108. * @returns list of agent indices
  65109. */
  65110. getAgents(): number[];
  65111. /**
  65112. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65113. * @param deltaTime in seconds
  65114. */
  65115. update(deltaTime: number): void;
  65116. /**
  65117. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65118. * @param index agent index returned by addAgent
  65119. * @param destination targeted world position
  65120. */
  65121. agentGoto(index: number, destination: Vector3): void;
  65122. /**
  65123. * Teleport the agent to a new position
  65124. * @param index agent index returned by addAgent
  65125. * @param destination targeted world position
  65126. */
  65127. agentTeleport(index: number, destination: Vector3): void;
  65128. /**
  65129. * Update agent parameters
  65130. * @param index agent index returned by addAgent
  65131. * @param parameters agent parameters
  65132. */
  65133. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65134. /**
  65135. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65136. * The queries will try to find a solution within those bounds
  65137. * default is (1,1,1)
  65138. * @param extent x,y,z value that define the extent around the queries point of reference
  65139. */
  65140. setDefaultQueryExtent(extent: Vector3): void;
  65141. /**
  65142. * Get the Bounding box extent specified by setDefaultQueryExtent
  65143. * @returns the box extent values
  65144. */
  65145. getDefaultQueryExtent(): Vector3;
  65146. /**
  65147. * Release all resources
  65148. */
  65149. dispose(): void;
  65150. }
  65151. /**
  65152. * Configures an agent
  65153. */
  65154. export interface IAgentParameters {
  65155. /**
  65156. * Agent radius. [Limit: >= 0]
  65157. */
  65158. radius: number;
  65159. /**
  65160. * Agent height. [Limit: > 0]
  65161. */
  65162. height: number;
  65163. /**
  65164. * Maximum allowed acceleration. [Limit: >= 0]
  65165. */
  65166. maxAcceleration: number;
  65167. /**
  65168. * Maximum allowed speed. [Limit: >= 0]
  65169. */
  65170. maxSpeed: number;
  65171. /**
  65172. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65173. */
  65174. collisionQueryRange: number;
  65175. /**
  65176. * The path visibility optimization range. [Limit: > 0]
  65177. */
  65178. pathOptimizationRange: number;
  65179. /**
  65180. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65181. */
  65182. separationWeight: number;
  65183. }
  65184. /**
  65185. * Configures the navigation mesh creation
  65186. */
  65187. export interface INavMeshParameters {
  65188. /**
  65189. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65190. */
  65191. cs: number;
  65192. /**
  65193. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65194. */
  65195. ch: number;
  65196. /**
  65197. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65198. */
  65199. walkableSlopeAngle: number;
  65200. /**
  65201. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65202. * be considered walkable. [Limit: >= 3] [Units: vx]
  65203. */
  65204. walkableHeight: number;
  65205. /**
  65206. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65207. */
  65208. walkableClimb: number;
  65209. /**
  65210. * The distance to erode/shrink the walkable area of the heightfield away from
  65211. * obstructions. [Limit: >=0] [Units: vx]
  65212. */
  65213. walkableRadius: number;
  65214. /**
  65215. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65216. */
  65217. maxEdgeLen: number;
  65218. /**
  65219. * The maximum distance a simplfied contour's border edges should deviate
  65220. * the original raw contour. [Limit: >=0] [Units: vx]
  65221. */
  65222. maxSimplificationError: number;
  65223. /**
  65224. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65225. */
  65226. minRegionArea: number;
  65227. /**
  65228. * Any regions with a span count smaller than this value will, if possible,
  65229. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65230. */
  65231. mergeRegionArea: number;
  65232. /**
  65233. * The maximum number of vertices allowed for polygons generated during the
  65234. * contour to polygon conversion process. [Limit: >= 3]
  65235. */
  65236. maxVertsPerPoly: number;
  65237. /**
  65238. * Sets the sampling distance to use when generating the detail mesh.
  65239. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65240. */
  65241. detailSampleDist: number;
  65242. /**
  65243. * The maximum distance the detail mesh surface should deviate from heightfield
  65244. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65245. */
  65246. detailSampleMaxError: number;
  65247. }
  65248. }
  65249. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65250. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65251. import { Mesh } from "babylonjs/Meshes/mesh";
  65252. import { Scene } from "babylonjs/scene";
  65253. import { Vector3 } from "babylonjs/Maths/math";
  65254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65255. /**
  65256. * RecastJS navigation plugin
  65257. */
  65258. export class RecastJSPlugin implements INavigationEnginePlugin {
  65259. /**
  65260. * Reference to the Recast library
  65261. */
  65262. bjsRECAST: any;
  65263. /**
  65264. * plugin name
  65265. */
  65266. name: string;
  65267. /**
  65268. * the first navmesh created. We might extend this to support multiple navmeshes
  65269. */
  65270. navMesh: any;
  65271. /**
  65272. * Initializes the recastJS plugin
  65273. * @param recastInjection can be used to inject your own recast reference
  65274. */
  65275. constructor(recastInjection?: any);
  65276. /**
  65277. * Creates a navigation mesh
  65278. * @param meshes array of all the geometry used to compute the navigatio mesh
  65279. * @param parameters bunch of parameters used to filter geometry
  65280. */
  65281. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65282. /**
  65283. * Create a navigation mesh debug mesh
  65284. * @param scene is where the mesh will be added
  65285. * @returns debug display mesh
  65286. */
  65287. createDebugNavMesh(scene: Scene): Mesh;
  65288. /**
  65289. * Get a navigation mesh constrained position, closest to the parameter position
  65290. * @param position world position
  65291. * @returns the closest point to position constrained by the navigation mesh
  65292. */
  65293. getClosestPoint(position: Vector3): Vector3;
  65294. /**
  65295. * Get a navigation mesh constrained position, within a particular radius
  65296. * @param position world position
  65297. * @param maxRadius the maximum distance to the constrained world position
  65298. * @returns the closest point to position constrained by the navigation mesh
  65299. */
  65300. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65301. /**
  65302. * Compute the final position from a segment made of destination-position
  65303. * @param position world position
  65304. * @param destination world position
  65305. * @returns the resulting point along the navmesh
  65306. */
  65307. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65308. /**
  65309. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65310. * @param start world position
  65311. * @param end world position
  65312. * @returns array containing world position composing the path
  65313. */
  65314. computePath(start: Vector3, end: Vector3): Vector3[];
  65315. /**
  65316. * Create a new Crowd so you can add agents
  65317. * @param maxAgents the maximum agent count in the crowd
  65318. * @param maxAgentRadius the maximum radius an agent can have
  65319. * @param scene to attach the crowd to
  65320. * @returns the crowd you can add agents to
  65321. */
  65322. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65323. /**
  65324. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65325. * The queries will try to find a solution within those bounds
  65326. * default is (1,1,1)
  65327. * @param extent x,y,z value that define the extent around the queries point of reference
  65328. */
  65329. setDefaultQueryExtent(extent: Vector3): void;
  65330. /**
  65331. * Get the Bounding box extent specified by setDefaultQueryExtent
  65332. * @returns the box extent values
  65333. */
  65334. getDefaultQueryExtent(): Vector3;
  65335. /**
  65336. * Disposes
  65337. */
  65338. dispose(): void;
  65339. /**
  65340. * If this plugin is supported
  65341. * @returns true if plugin is supported
  65342. */
  65343. isSupported(): boolean;
  65344. }
  65345. /**
  65346. * Recast detour crowd implementation
  65347. */
  65348. export class RecastJSCrowd implements ICrowd {
  65349. /**
  65350. * Recast/detour plugin
  65351. */
  65352. bjsRECASTPlugin: RecastJSPlugin;
  65353. /**
  65354. * Link to the detour crowd
  65355. */
  65356. recastCrowd: any;
  65357. /**
  65358. * One transform per agent
  65359. */
  65360. transforms: TransformNode[];
  65361. /**
  65362. * All agents created
  65363. */
  65364. agents: number[];
  65365. /**
  65366. * Link to the scene is kept to unregister the crowd from the scene
  65367. */
  65368. private _scene;
  65369. /**
  65370. * Observer for crowd updates
  65371. */
  65372. private _onBeforeAnimationsObserver;
  65373. /**
  65374. * Constructor
  65375. * @param plugin recastJS plugin
  65376. * @param maxAgents the maximum agent count in the crowd
  65377. * @param maxAgentRadius the maximum radius an agent can have
  65378. * @param scene to attach the crowd to
  65379. * @returns the crowd you can add agents to
  65380. */
  65381. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65382. /**
  65383. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65384. * You can attach anything to that node. The node position is updated in the scene update tick.
  65385. * @param pos world position that will be constrained by the navigation mesh
  65386. * @param parameters agent parameters
  65387. * @param transform hooked to the agent that will be update by the scene
  65388. * @returns agent index
  65389. */
  65390. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65391. /**
  65392. * Returns the agent position in world space
  65393. * @param index agent index returned by addAgent
  65394. * @returns world space position
  65395. */
  65396. getAgentPosition(index: number): Vector3;
  65397. /**
  65398. * Returns the agent velocity in world space
  65399. * @param index agent index returned by addAgent
  65400. * @returns world space velocity
  65401. */
  65402. getAgentVelocity(index: number): Vector3;
  65403. /**
  65404. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65405. * @param index agent index returned by addAgent
  65406. * @param destination targeted world position
  65407. */
  65408. agentGoto(index: number, destination: Vector3): void;
  65409. /**
  65410. * Teleport the agent to a new position
  65411. * @param index agent index returned by addAgent
  65412. * @param destination targeted world position
  65413. */
  65414. agentTeleport(index: number, destination: Vector3): void;
  65415. /**
  65416. * Update agent parameters
  65417. * @param index agent index returned by addAgent
  65418. * @param parameters agent parameters
  65419. */
  65420. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65421. /**
  65422. * remove a particular agent previously created
  65423. * @param index agent index returned by addAgent
  65424. */
  65425. removeAgent(index: number): void;
  65426. /**
  65427. * get the list of all agents attached to this crowd
  65428. * @returns list of agent indices
  65429. */
  65430. getAgents(): number[];
  65431. /**
  65432. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65433. * @param deltaTime in seconds
  65434. */
  65435. update(deltaTime: number): void;
  65436. /**
  65437. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65438. * The queries will try to find a solution within those bounds
  65439. * default is (1,1,1)
  65440. * @param extent x,y,z value that define the extent around the queries point of reference
  65441. */
  65442. setDefaultQueryExtent(extent: Vector3): void;
  65443. /**
  65444. * Get the Bounding box extent specified by setDefaultQueryExtent
  65445. * @returns the box extent values
  65446. */
  65447. getDefaultQueryExtent(): Vector3;
  65448. /**
  65449. * Release all resources
  65450. */
  65451. dispose(): void;
  65452. }
  65453. }
  65454. declare module "babylonjs/Navigation/Plugins/index" {
  65455. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65456. }
  65457. declare module "babylonjs/Navigation/index" {
  65458. export * from "babylonjs/Navigation/INavigationEngine";
  65459. export * from "babylonjs/Navigation/Plugins/index";
  65460. }
  65461. declare module "babylonjs/Offline/database" {
  65462. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65463. /**
  65464. * Class used to enable access to IndexedDB
  65465. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65466. */
  65467. export class Database implements IOfflineProvider {
  65468. private _callbackManifestChecked;
  65469. private _currentSceneUrl;
  65470. private _db;
  65471. private _enableSceneOffline;
  65472. private _enableTexturesOffline;
  65473. private _manifestVersionFound;
  65474. private _mustUpdateRessources;
  65475. private _hasReachedQuota;
  65476. private _isSupported;
  65477. private _idbFactory;
  65478. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65479. private static IsUASupportingBlobStorage;
  65480. /**
  65481. * Gets a boolean indicating if Database storate is enabled (off by default)
  65482. */
  65483. static IDBStorageEnabled: boolean;
  65484. /**
  65485. * Gets a boolean indicating if scene must be saved in the database
  65486. */
  65487. get enableSceneOffline(): boolean;
  65488. /**
  65489. * Gets a boolean indicating if textures must be saved in the database
  65490. */
  65491. get enableTexturesOffline(): boolean;
  65492. /**
  65493. * Creates a new Database
  65494. * @param urlToScene defines the url to load the scene
  65495. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65496. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65497. */
  65498. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65499. private static _ParseURL;
  65500. private static _ReturnFullUrlLocation;
  65501. private _checkManifestFile;
  65502. /**
  65503. * Open the database and make it available
  65504. * @param successCallback defines the callback to call on success
  65505. * @param errorCallback defines the callback to call on error
  65506. */
  65507. open(successCallback: () => void, errorCallback: () => void): void;
  65508. /**
  65509. * Loads an image from the database
  65510. * @param url defines the url to load from
  65511. * @param image defines the target DOM image
  65512. */
  65513. loadImage(url: string, image: HTMLImageElement): void;
  65514. private _loadImageFromDBAsync;
  65515. private _saveImageIntoDBAsync;
  65516. private _checkVersionFromDB;
  65517. private _loadVersionFromDBAsync;
  65518. private _saveVersionIntoDBAsync;
  65519. /**
  65520. * Loads a file from database
  65521. * @param url defines the URL to load from
  65522. * @param sceneLoaded defines a callback to call on success
  65523. * @param progressCallBack defines a callback to call when progress changed
  65524. * @param errorCallback defines a callback to call on error
  65525. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65526. */
  65527. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65528. private _loadFileAsync;
  65529. private _saveFileAsync;
  65530. /**
  65531. * Validates if xhr data is correct
  65532. * @param xhr defines the request to validate
  65533. * @param dataType defines the expected data type
  65534. * @returns true if data is correct
  65535. */
  65536. private static _ValidateXHRData;
  65537. }
  65538. }
  65539. declare module "babylonjs/Offline/index" {
  65540. export * from "babylonjs/Offline/database";
  65541. export * from "babylonjs/Offline/IOfflineProvider";
  65542. }
  65543. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65544. /** @hidden */
  65545. export var gpuUpdateParticlesPixelShader: {
  65546. name: string;
  65547. shader: string;
  65548. };
  65549. }
  65550. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65551. /** @hidden */
  65552. export var gpuUpdateParticlesVertexShader: {
  65553. name: string;
  65554. shader: string;
  65555. };
  65556. }
  65557. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65558. /** @hidden */
  65559. export var clipPlaneFragmentDeclaration2: {
  65560. name: string;
  65561. shader: string;
  65562. };
  65563. }
  65564. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65565. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65566. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65568. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65569. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65570. /** @hidden */
  65571. export var gpuRenderParticlesPixelShader: {
  65572. name: string;
  65573. shader: string;
  65574. };
  65575. }
  65576. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65577. /** @hidden */
  65578. export var clipPlaneVertexDeclaration2: {
  65579. name: string;
  65580. shader: string;
  65581. };
  65582. }
  65583. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65584. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65585. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65586. /** @hidden */
  65587. export var gpuRenderParticlesVertexShader: {
  65588. name: string;
  65589. shader: string;
  65590. };
  65591. }
  65592. declare module "babylonjs/Particles/gpuParticleSystem" {
  65593. import { Nullable } from "babylonjs/types";
  65594. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65595. import { Observable } from "babylonjs/Misc/observable";
  65596. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65597. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65598. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65599. import { Scene, IDisposable } from "babylonjs/scene";
  65600. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65601. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65602. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65603. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65604. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65605. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65606. /**
  65607. * This represents a GPU particle system in Babylon
  65608. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65609. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65610. */
  65611. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65612. /**
  65613. * The layer mask we are rendering the particles through.
  65614. */
  65615. layerMask: number;
  65616. private _capacity;
  65617. private _activeCount;
  65618. private _currentActiveCount;
  65619. private _accumulatedCount;
  65620. private _renderEffect;
  65621. private _updateEffect;
  65622. private _buffer0;
  65623. private _buffer1;
  65624. private _spriteBuffer;
  65625. private _updateVAO;
  65626. private _renderVAO;
  65627. private _targetIndex;
  65628. private _sourceBuffer;
  65629. private _targetBuffer;
  65630. private _engine;
  65631. private _currentRenderId;
  65632. private _started;
  65633. private _stopped;
  65634. private _timeDelta;
  65635. private _randomTexture;
  65636. private _randomTexture2;
  65637. private _attributesStrideSize;
  65638. private _updateEffectOptions;
  65639. private _randomTextureSize;
  65640. private _actualFrame;
  65641. private readonly _rawTextureWidth;
  65642. /**
  65643. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65644. */
  65645. static get IsSupported(): boolean;
  65646. /**
  65647. * An event triggered when the system is disposed.
  65648. */
  65649. onDisposeObservable: Observable<GPUParticleSystem>;
  65650. /**
  65651. * Gets the maximum number of particles active at the same time.
  65652. * @returns The max number of active particles.
  65653. */
  65654. getCapacity(): number;
  65655. /**
  65656. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65657. * to override the particles.
  65658. */
  65659. forceDepthWrite: boolean;
  65660. /**
  65661. * Gets or set the number of active particles
  65662. */
  65663. get activeParticleCount(): number;
  65664. set activeParticleCount(value: number);
  65665. private _preWarmDone;
  65666. /**
  65667. * Is this system ready to be used/rendered
  65668. * @return true if the system is ready
  65669. */
  65670. isReady(): boolean;
  65671. /**
  65672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65673. * @returns True if it has been started, otherwise false.
  65674. */
  65675. isStarted(): boolean;
  65676. /**
  65677. * Starts the particle system and begins to emit
  65678. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65679. */
  65680. start(delay?: number): void;
  65681. /**
  65682. * Stops the particle system.
  65683. */
  65684. stop(): void;
  65685. /**
  65686. * Remove all active particles
  65687. */
  65688. reset(): void;
  65689. /**
  65690. * Returns the string "GPUParticleSystem"
  65691. * @returns a string containing the class name
  65692. */
  65693. getClassName(): string;
  65694. private _colorGradientsTexture;
  65695. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65696. /**
  65697. * Adds a new color gradient
  65698. * @param gradient defines the gradient to use (between 0 and 1)
  65699. * @param color1 defines the color to affect to the specified gradient
  65700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65701. * @returns the current particle system
  65702. */
  65703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65704. /**
  65705. * Remove a specific color gradient
  65706. * @param gradient defines the gradient to remove
  65707. * @returns the current particle system
  65708. */
  65709. removeColorGradient(gradient: number): GPUParticleSystem;
  65710. private _angularSpeedGradientsTexture;
  65711. private _sizeGradientsTexture;
  65712. private _velocityGradientsTexture;
  65713. private _limitVelocityGradientsTexture;
  65714. private _dragGradientsTexture;
  65715. private _addFactorGradient;
  65716. /**
  65717. * Adds a new size gradient
  65718. * @param gradient defines the gradient to use (between 0 and 1)
  65719. * @param factor defines the size factor to affect to the specified gradient
  65720. * @returns the current particle system
  65721. */
  65722. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65723. /**
  65724. * Remove a specific size gradient
  65725. * @param gradient defines the gradient to remove
  65726. * @returns the current particle system
  65727. */
  65728. removeSizeGradient(gradient: number): GPUParticleSystem;
  65729. /**
  65730. * Adds a new angular speed gradient
  65731. * @param gradient defines the gradient to use (between 0 and 1)
  65732. * @param factor defines the angular speed to affect to the specified gradient
  65733. * @returns the current particle system
  65734. */
  65735. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65736. /**
  65737. * Remove a specific angular speed gradient
  65738. * @param gradient defines the gradient to remove
  65739. * @returns the current particle system
  65740. */
  65741. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65742. /**
  65743. * Adds a new velocity gradient
  65744. * @param gradient defines the gradient to use (between 0 and 1)
  65745. * @param factor defines the velocity to affect to the specified gradient
  65746. * @returns the current particle system
  65747. */
  65748. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65749. /**
  65750. * Remove a specific velocity gradient
  65751. * @param gradient defines the gradient to remove
  65752. * @returns the current particle system
  65753. */
  65754. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65755. /**
  65756. * Adds a new limit velocity gradient
  65757. * @param gradient defines the gradient to use (between 0 and 1)
  65758. * @param factor defines the limit velocity value to affect to the specified gradient
  65759. * @returns the current particle system
  65760. */
  65761. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65762. /**
  65763. * Remove a specific limit velocity gradient
  65764. * @param gradient defines the gradient to remove
  65765. * @returns the current particle system
  65766. */
  65767. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65768. /**
  65769. * Adds a new drag gradient
  65770. * @param gradient defines the gradient to use (between 0 and 1)
  65771. * @param factor defines the drag value to affect to the specified gradient
  65772. * @returns the current particle system
  65773. */
  65774. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65775. /**
  65776. * Remove a specific drag gradient
  65777. * @param gradient defines the gradient to remove
  65778. * @returns the current particle system
  65779. */
  65780. removeDragGradient(gradient: number): GPUParticleSystem;
  65781. /**
  65782. * Not supported by GPUParticleSystem
  65783. * @param gradient defines the gradient to use (between 0 and 1)
  65784. * @param factor defines the emit rate value to affect to the specified gradient
  65785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65786. * @returns the current particle system
  65787. */
  65788. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65789. /**
  65790. * Not supported by GPUParticleSystem
  65791. * @param gradient defines the gradient to remove
  65792. * @returns the current particle system
  65793. */
  65794. removeEmitRateGradient(gradient: number): IParticleSystem;
  65795. /**
  65796. * Not supported by GPUParticleSystem
  65797. * @param gradient defines the gradient to use (between 0 and 1)
  65798. * @param factor defines the start size value to affect to the specified gradient
  65799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65800. * @returns the current particle system
  65801. */
  65802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65803. /**
  65804. * Not supported by GPUParticleSystem
  65805. * @param gradient defines the gradient to remove
  65806. * @returns the current particle system
  65807. */
  65808. removeStartSizeGradient(gradient: number): IParticleSystem;
  65809. /**
  65810. * Not supported by GPUParticleSystem
  65811. * @param gradient defines the gradient to use (between 0 and 1)
  65812. * @param min defines the color remap minimal range
  65813. * @param max defines the color remap maximal range
  65814. * @returns the current particle system
  65815. */
  65816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65817. /**
  65818. * Not supported by GPUParticleSystem
  65819. * @param gradient defines the gradient to remove
  65820. * @returns the current particle system
  65821. */
  65822. removeColorRemapGradient(): IParticleSystem;
  65823. /**
  65824. * Not supported by GPUParticleSystem
  65825. * @param gradient defines the gradient to use (between 0 and 1)
  65826. * @param min defines the alpha remap minimal range
  65827. * @param max defines the alpha remap maximal range
  65828. * @returns the current particle system
  65829. */
  65830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65831. /**
  65832. * Not supported by GPUParticleSystem
  65833. * @param gradient defines the gradient to remove
  65834. * @returns the current particle system
  65835. */
  65836. removeAlphaRemapGradient(): IParticleSystem;
  65837. /**
  65838. * Not supported by GPUParticleSystem
  65839. * @param gradient defines the gradient to use (between 0 and 1)
  65840. * @param color defines the color to affect to the specified gradient
  65841. * @returns the current particle system
  65842. */
  65843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65844. /**
  65845. * Not supported by GPUParticleSystem
  65846. * @param gradient defines the gradient to remove
  65847. * @returns the current particle system
  65848. */
  65849. removeRampGradient(): IParticleSystem;
  65850. /**
  65851. * Not supported by GPUParticleSystem
  65852. * @returns the list of ramp gradients
  65853. */
  65854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65855. /**
  65856. * Not supported by GPUParticleSystem
  65857. * Gets or sets a boolean indicating that ramp gradients must be used
  65858. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65859. */
  65860. get useRampGradients(): boolean;
  65861. set useRampGradients(value: boolean);
  65862. /**
  65863. * Not supported by GPUParticleSystem
  65864. * @param gradient defines the gradient to use (between 0 and 1)
  65865. * @param factor defines the life time factor to affect to the specified gradient
  65866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65867. * @returns the current particle system
  65868. */
  65869. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65870. /**
  65871. * Not supported by GPUParticleSystem
  65872. * @param gradient defines the gradient to remove
  65873. * @returns the current particle system
  65874. */
  65875. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65876. /**
  65877. * Instantiates a GPU particle system.
  65878. * 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.
  65879. * @param name The name of the particle system
  65880. * @param options The options used to create the system
  65881. * @param scene The scene the particle system belongs to
  65882. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65883. */
  65884. constructor(name: string, options: Partial<{
  65885. capacity: number;
  65886. randomTextureSize: number;
  65887. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65888. protected _reset(): void;
  65889. private _createUpdateVAO;
  65890. private _createRenderVAO;
  65891. private _initialize;
  65892. /** @hidden */
  65893. _recreateUpdateEffect(): void;
  65894. /** @hidden */
  65895. _recreateRenderEffect(): void;
  65896. /**
  65897. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65898. * @param preWarm defines if we are in the pre-warmimg phase
  65899. */
  65900. animate(preWarm?: boolean): void;
  65901. private _createFactorGradientTexture;
  65902. private _createSizeGradientTexture;
  65903. private _createAngularSpeedGradientTexture;
  65904. private _createVelocityGradientTexture;
  65905. private _createLimitVelocityGradientTexture;
  65906. private _createDragGradientTexture;
  65907. private _createColorGradientTexture;
  65908. /**
  65909. * Renders the particle system in its current state
  65910. * @param preWarm defines if the system should only update the particles but not render them
  65911. * @returns the current number of particles
  65912. */
  65913. render(preWarm?: boolean): number;
  65914. /**
  65915. * Rebuilds the particle system
  65916. */
  65917. rebuild(): void;
  65918. private _releaseBuffers;
  65919. private _releaseVAOs;
  65920. /**
  65921. * Disposes the particle system and free the associated resources
  65922. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65923. */
  65924. dispose(disposeTexture?: boolean): void;
  65925. /**
  65926. * Clones the particle system.
  65927. * @param name The name of the cloned object
  65928. * @param newEmitter The new emitter to use
  65929. * @returns the cloned particle system
  65930. */
  65931. clone(name: string, newEmitter: any): GPUParticleSystem;
  65932. /**
  65933. * Serializes the particle system to a JSON object.
  65934. * @returns the JSON object
  65935. */
  65936. serialize(): any;
  65937. /**
  65938. * Parses a JSON object to create a GPU particle system.
  65939. * @param parsedParticleSystem The JSON object to parse
  65940. * @param scene The scene to create the particle system in
  65941. * @param rootUrl The root url to use to load external dependencies like texture
  65942. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65943. * @returns the parsed GPU particle system
  65944. */
  65945. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65946. }
  65947. }
  65948. declare module "babylonjs/Particles/particleSystemSet" {
  65949. import { Nullable } from "babylonjs/types";
  65950. import { Color3 } from "babylonjs/Maths/math.color";
  65951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65953. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65954. import { Scene, IDisposable } from "babylonjs/scene";
  65955. /**
  65956. * Represents a set of particle systems working together to create a specific effect
  65957. */
  65958. export class ParticleSystemSet implements IDisposable {
  65959. /**
  65960. * Gets or sets base Assets URL
  65961. */
  65962. static BaseAssetsUrl: string;
  65963. private _emitterCreationOptions;
  65964. private _emitterNode;
  65965. /**
  65966. * Gets the particle system list
  65967. */
  65968. systems: IParticleSystem[];
  65969. /**
  65970. * Gets the emitter node used with this set
  65971. */
  65972. get emitterNode(): Nullable<TransformNode>;
  65973. /**
  65974. * Creates a new emitter mesh as a sphere
  65975. * @param options defines the options used to create the sphere
  65976. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65977. * @param scene defines the hosting scene
  65978. */
  65979. setEmitterAsSphere(options: {
  65980. diameter: number;
  65981. segments: number;
  65982. color: Color3;
  65983. }, renderingGroupId: number, scene: Scene): void;
  65984. /**
  65985. * Starts all particle systems of the set
  65986. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65987. */
  65988. start(emitter?: AbstractMesh): void;
  65989. /**
  65990. * Release all associated resources
  65991. */
  65992. dispose(): void;
  65993. /**
  65994. * Serialize the set into a JSON compatible object
  65995. * @returns a JSON compatible representation of the set
  65996. */
  65997. serialize(): any;
  65998. /**
  65999. * Parse a new ParticleSystemSet from a serialized source
  66000. * @param data defines a JSON compatible representation of the set
  66001. * @param scene defines the hosting scene
  66002. * @param gpu defines if we want GPU particles or CPU particles
  66003. * @returns a new ParticleSystemSet
  66004. */
  66005. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66006. }
  66007. }
  66008. declare module "babylonjs/Particles/particleHelper" {
  66009. import { Nullable } from "babylonjs/types";
  66010. import { Scene } from "babylonjs/scene";
  66011. import { Vector3 } from "babylonjs/Maths/math.vector";
  66012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66013. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66014. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66015. /**
  66016. * This class is made for on one-liner static method to help creating particle system set.
  66017. */
  66018. export class ParticleHelper {
  66019. /**
  66020. * Gets or sets base Assets URL
  66021. */
  66022. static BaseAssetsUrl: string;
  66023. /**
  66024. * Create a default particle system that you can tweak
  66025. * @param emitter defines the emitter to use
  66026. * @param capacity defines the system capacity (default is 500 particles)
  66027. * @param scene defines the hosting scene
  66028. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66029. * @returns the new Particle system
  66030. */
  66031. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66032. /**
  66033. * This is the main static method (one-liner) of this helper to create different particle systems
  66034. * @param type This string represents the type to the particle system to create
  66035. * @param scene The scene where the particle system should live
  66036. * @param gpu If the system will use gpu
  66037. * @returns the ParticleSystemSet created
  66038. */
  66039. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66040. /**
  66041. * Static function used to export a particle system to a ParticleSystemSet variable.
  66042. * Please note that the emitter shape is not exported
  66043. * @param systems defines the particle systems to export
  66044. * @returns the created particle system set
  66045. */
  66046. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66047. }
  66048. }
  66049. declare module "babylonjs/Particles/particleSystemComponent" {
  66050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66051. import { Effect } from "babylonjs/Materials/effect";
  66052. import "babylonjs/Shaders/particles.vertex";
  66053. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66054. module "babylonjs/Engines/engine" {
  66055. interface Engine {
  66056. /**
  66057. * Create an effect to use with particle systems.
  66058. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66059. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66060. * @param uniformsNames defines a list of attribute names
  66061. * @param samplers defines an array of string used to represent textures
  66062. * @param defines defines the string containing the defines to use to compile the shaders
  66063. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66064. * @param onCompiled defines a function to call when the effect creation is successful
  66065. * @param onError defines a function to call when the effect creation has failed
  66066. * @returns the new Effect
  66067. */
  66068. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66069. }
  66070. }
  66071. module "babylonjs/Meshes/mesh" {
  66072. interface Mesh {
  66073. /**
  66074. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66075. * @returns an array of IParticleSystem
  66076. */
  66077. getEmittedParticleSystems(): IParticleSystem[];
  66078. /**
  66079. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66080. * @returns an array of IParticleSystem
  66081. */
  66082. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66083. }
  66084. }
  66085. /**
  66086. * @hidden
  66087. */
  66088. export var _IDoNeedToBeInTheBuild: number;
  66089. }
  66090. declare module "babylonjs/Particles/pointsCloudSystem" {
  66091. import { Color4 } from "babylonjs/Maths/math";
  66092. import { Mesh } from "babylonjs/Meshes/mesh";
  66093. import { Scene, IDisposable } from "babylonjs/scene";
  66094. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66095. /** Defines the 4 color options */
  66096. export enum PointColor {
  66097. /** color value */
  66098. Color = 2,
  66099. /** uv value */
  66100. UV = 1,
  66101. /** random value */
  66102. Random = 0,
  66103. /** stated value */
  66104. Stated = 3
  66105. }
  66106. /**
  66107. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66108. * 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.
  66109. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66110. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66111. *
  66112. * Full documentation here : TO BE ENTERED
  66113. */
  66114. export class PointsCloudSystem implements IDisposable {
  66115. /**
  66116. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66117. * Example : var p = SPS.particles[i];
  66118. */
  66119. particles: CloudPoint[];
  66120. /**
  66121. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66122. */
  66123. nbParticles: number;
  66124. /**
  66125. * This a counter for your own usage. It's not set by any SPS functions.
  66126. */
  66127. counter: number;
  66128. /**
  66129. * The PCS name. This name is also given to the underlying mesh.
  66130. */
  66131. name: string;
  66132. /**
  66133. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66134. */
  66135. mesh: Mesh;
  66136. /**
  66137. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66138. * Please read :
  66139. */
  66140. vars: any;
  66141. /**
  66142. * @hidden
  66143. */
  66144. _size: number;
  66145. private _scene;
  66146. private _promises;
  66147. private _positions;
  66148. private _indices;
  66149. private _normals;
  66150. private _colors;
  66151. private _uvs;
  66152. private _indices32;
  66153. private _positions32;
  66154. private _colors32;
  66155. private _uvs32;
  66156. private _updatable;
  66157. private _isVisibilityBoxLocked;
  66158. private _alwaysVisible;
  66159. private _groups;
  66160. private _groupCounter;
  66161. private _computeParticleColor;
  66162. private _computeParticleTexture;
  66163. private _computeParticleRotation;
  66164. private _computeBoundingBox;
  66165. private _isReady;
  66166. /**
  66167. * Creates a PCS (Points Cloud System) object
  66168. * @param name (String) is the PCS name, this will be the underlying mesh name
  66169. * @param pointSize (number) is the size for each point
  66170. * @param scene (Scene) is the scene in which the PCS is added
  66171. * @param options defines the options of the PCS e.g.
  66172. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66173. */
  66174. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66175. updatable?: boolean;
  66176. });
  66177. /**
  66178. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66179. * If no points were added to the PCS, the returned mesh is just a single point.
  66180. * @returns a promise for the created mesh
  66181. */
  66182. buildMeshAsync(): Promise<Mesh>;
  66183. /**
  66184. * @hidden
  66185. */
  66186. private _buildMesh;
  66187. private _addParticle;
  66188. private _randomUnitVector;
  66189. private _getColorIndicesForCoord;
  66190. private _setPointsColorOrUV;
  66191. private _colorFromTexture;
  66192. private _calculateDensity;
  66193. /**
  66194. * Adds points to the PCS in random positions within a unit sphere
  66195. * @param nb (positive integer) the number of particles to be created from this model
  66196. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66197. * @returns the number of groups in the system
  66198. */
  66199. addPoints(nb: number, pointFunction?: any): number;
  66200. /**
  66201. * Adds points to the PCS from the surface of the model shape
  66202. * @param mesh is any Mesh object that will be used as a surface model for the points
  66203. * @param nb (positive integer) the number of particles to be created from this model
  66204. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66205. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66206. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66207. * @returns the number of groups in the system
  66208. */
  66209. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66210. /**
  66211. * Adds points to the PCS inside the model shape
  66212. * @param mesh is any Mesh object that will be used as a surface model for the points
  66213. * @param nb (positive integer) the number of particles to be created from this model
  66214. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66215. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66216. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66217. * @returns the number of groups in the system
  66218. */
  66219. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66220. /**
  66221. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66222. * This method calls `updateParticle()` for each particle of the SPS.
  66223. * For an animated SPS, it is usually called within the render loop.
  66224. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66225. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66226. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66227. * @returns the PCS.
  66228. */
  66229. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66230. /**
  66231. * Disposes the PCS.
  66232. */
  66233. dispose(): void;
  66234. /**
  66235. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66236. * doc :
  66237. * @returns the PCS.
  66238. */
  66239. refreshVisibleSize(): PointsCloudSystem;
  66240. /**
  66241. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66242. * @param size the size (float) of the visibility box
  66243. * note : this doesn't lock the PCS mesh bounding box.
  66244. * doc :
  66245. */
  66246. setVisibilityBox(size: number): void;
  66247. /**
  66248. * Gets whether the PCS is always visible or not
  66249. * doc :
  66250. */
  66251. get isAlwaysVisible(): boolean;
  66252. /**
  66253. * Sets the PCS as always visible or not
  66254. * doc :
  66255. */
  66256. set isAlwaysVisible(val: boolean);
  66257. /**
  66258. * Tells to `setParticles()` to compute the particle rotations or not
  66259. * Default value : false. The PCS is faster when it's set to false
  66260. * Note : particle rotations are only applied to parent particles
  66261. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66262. */
  66263. set computeParticleRotation(val: boolean);
  66264. /**
  66265. * Tells to `setParticles()` to compute the particle colors or not.
  66266. * Default value : true. The PCS is faster when it's set to false.
  66267. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66268. */
  66269. set computeParticleColor(val: boolean);
  66270. set computeParticleTexture(val: boolean);
  66271. /**
  66272. * Gets if `setParticles()` computes the particle colors or not.
  66273. * Default value : false. The PCS is faster when it's set to false.
  66274. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66275. */
  66276. get computeParticleColor(): boolean;
  66277. /**
  66278. * Gets if `setParticles()` computes the particle textures or not.
  66279. * Default value : false. The PCS is faster when it's set to false.
  66280. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66281. */
  66282. get computeParticleTexture(): boolean;
  66283. /**
  66284. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66285. */
  66286. set computeBoundingBox(val: boolean);
  66287. /**
  66288. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66289. */
  66290. get computeBoundingBox(): boolean;
  66291. /**
  66292. * This function does nothing. It may be overwritten to set all the particle first values.
  66293. * The PCS doesn't call this function, you may have to call it by your own.
  66294. * doc :
  66295. */
  66296. initParticles(): void;
  66297. /**
  66298. * This function does nothing. It may be overwritten to recycle a particle
  66299. * The PCS doesn't call this function, you can to call it
  66300. * doc :
  66301. * @param particle The particle to recycle
  66302. * @returns the recycled particle
  66303. */
  66304. recycleParticle(particle: CloudPoint): CloudPoint;
  66305. /**
  66306. * Updates a particle : this function should be overwritten by the user.
  66307. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66308. * doc :
  66309. * @example : just set a particle position or velocity and recycle conditions
  66310. * @param particle The particle to update
  66311. * @returns the updated particle
  66312. */
  66313. updateParticle(particle: CloudPoint): CloudPoint;
  66314. /**
  66315. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66316. * This does nothing and may be overwritten by the user.
  66317. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66318. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66319. * @param update the boolean update value actually passed to setParticles()
  66320. */
  66321. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66322. /**
  66323. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66324. * This will be passed three parameters.
  66325. * This does nothing and may be overwritten by the user.
  66326. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66327. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66328. * @param update the boolean update value actually passed to setParticles()
  66329. */
  66330. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66331. }
  66332. }
  66333. declare module "babylonjs/Particles/cloudPoint" {
  66334. import { Nullable } from "babylonjs/types";
  66335. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66336. import { Mesh } from "babylonjs/Meshes/mesh";
  66337. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66338. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66339. /**
  66340. * Represents one particle of a points cloud system.
  66341. */
  66342. export class CloudPoint {
  66343. /**
  66344. * particle global index
  66345. */
  66346. idx: number;
  66347. /**
  66348. * The color of the particle
  66349. */
  66350. color: Nullable<Color4>;
  66351. /**
  66352. * The world space position of the particle.
  66353. */
  66354. position: Vector3;
  66355. /**
  66356. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66357. */
  66358. rotation: Vector3;
  66359. /**
  66360. * The world space rotation quaternion of the particle.
  66361. */
  66362. rotationQuaternion: Nullable<Quaternion>;
  66363. /**
  66364. * The uv of the particle.
  66365. */
  66366. uv: Nullable<Vector2>;
  66367. /**
  66368. * The current speed of the particle.
  66369. */
  66370. velocity: Vector3;
  66371. /**
  66372. * The pivot point in the particle local space.
  66373. */
  66374. pivot: Vector3;
  66375. /**
  66376. * Must the particle be translated from its pivot point in its local space ?
  66377. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66378. * Default : false
  66379. */
  66380. translateFromPivot: boolean;
  66381. /**
  66382. * Index of this particle in the global "positions" array (Internal use)
  66383. * @hidden
  66384. */
  66385. _pos: number;
  66386. /**
  66387. * @hidden Index of this particle in the global "indices" array (Internal use)
  66388. */
  66389. _ind: number;
  66390. /**
  66391. * Group this particle belongs to
  66392. */
  66393. _group: PointsGroup;
  66394. /**
  66395. * Group id of this particle
  66396. */
  66397. groupId: number;
  66398. /**
  66399. * Index of the particle in its group id (Internal use)
  66400. */
  66401. idxInGroup: number;
  66402. /**
  66403. * @hidden Particle BoundingInfo object (Internal use)
  66404. */
  66405. _boundingInfo: BoundingInfo;
  66406. /**
  66407. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66408. */
  66409. _pcs: PointsCloudSystem;
  66410. /**
  66411. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66412. */
  66413. _stillInvisible: boolean;
  66414. /**
  66415. * @hidden Last computed particle rotation matrix
  66416. */
  66417. _rotationMatrix: number[];
  66418. /**
  66419. * Parent particle Id, if any.
  66420. * Default null.
  66421. */
  66422. parentId: Nullable<number>;
  66423. /**
  66424. * @hidden Internal global position in the PCS.
  66425. */
  66426. _globalPosition: Vector3;
  66427. /**
  66428. * Creates a Point Cloud object.
  66429. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66430. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66431. * @param group (PointsGroup) is the group the particle belongs to
  66432. * @param groupId (integer) is the group identifier in the PCS.
  66433. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66434. * @param pcs defines the PCS it is associated to
  66435. */
  66436. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66437. /**
  66438. * get point size
  66439. */
  66440. get size(): Vector3;
  66441. /**
  66442. * Set point size
  66443. */
  66444. set size(scale: Vector3);
  66445. /**
  66446. * Legacy support, changed quaternion to rotationQuaternion
  66447. */
  66448. get quaternion(): Nullable<Quaternion>;
  66449. /**
  66450. * Legacy support, changed quaternion to rotationQuaternion
  66451. */
  66452. set quaternion(q: Nullable<Quaternion>);
  66453. /**
  66454. * Returns a boolean. True if the particle intersects a mesh, else false
  66455. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66456. * @param target is the object (point or mesh) what the intersection is computed against
  66457. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66458. * @returns true if it intersects
  66459. */
  66460. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66461. /**
  66462. * get the rotation matrix of the particle
  66463. * @hidden
  66464. */
  66465. getRotationMatrix(m: Matrix): void;
  66466. }
  66467. /**
  66468. * Represents a group of points in a points cloud system
  66469. * * PCS internal tool, don't use it manually.
  66470. */
  66471. export class PointsGroup {
  66472. /**
  66473. * The group id
  66474. * @hidden
  66475. */
  66476. groupID: number;
  66477. /**
  66478. * image data for group (internal use)
  66479. * @hidden
  66480. */
  66481. _groupImageData: Nullable<ArrayBufferView>;
  66482. /**
  66483. * Image Width (internal use)
  66484. * @hidden
  66485. */
  66486. _groupImgWidth: number;
  66487. /**
  66488. * Image Height (internal use)
  66489. * @hidden
  66490. */
  66491. _groupImgHeight: number;
  66492. /**
  66493. * Custom position function (internal use)
  66494. * @hidden
  66495. */
  66496. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66497. /**
  66498. * density per facet for surface points
  66499. * @hidden
  66500. */
  66501. _groupDensity: number[];
  66502. /**
  66503. * Only when points are colored by texture carries pointer to texture list array
  66504. * @hidden
  66505. */
  66506. _textureNb: number;
  66507. /**
  66508. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66509. * PCS internal tool, don't use it manually.
  66510. * @hidden
  66511. */
  66512. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66513. }
  66514. }
  66515. declare module "babylonjs/Particles/index" {
  66516. export * from "babylonjs/Particles/baseParticleSystem";
  66517. export * from "babylonjs/Particles/EmitterTypes/index";
  66518. export * from "babylonjs/Particles/gpuParticleSystem";
  66519. export * from "babylonjs/Particles/IParticleSystem";
  66520. export * from "babylonjs/Particles/particle";
  66521. export * from "babylonjs/Particles/particleHelper";
  66522. export * from "babylonjs/Particles/particleSystem";
  66523. export * from "babylonjs/Particles/particleSystemComponent";
  66524. export * from "babylonjs/Particles/particleSystemSet";
  66525. export * from "babylonjs/Particles/solidParticle";
  66526. export * from "babylonjs/Particles/solidParticleSystem";
  66527. export * from "babylonjs/Particles/cloudPoint";
  66528. export * from "babylonjs/Particles/pointsCloudSystem";
  66529. export * from "babylonjs/Particles/subEmitter";
  66530. }
  66531. declare module "babylonjs/Physics/physicsEngineComponent" {
  66532. import { Nullable } from "babylonjs/types";
  66533. import { Observable, Observer } from "babylonjs/Misc/observable";
  66534. import { Vector3 } from "babylonjs/Maths/math.vector";
  66535. import { Mesh } from "babylonjs/Meshes/mesh";
  66536. import { ISceneComponent } from "babylonjs/sceneComponent";
  66537. import { Scene } from "babylonjs/scene";
  66538. import { Node } from "babylonjs/node";
  66539. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66540. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66541. module "babylonjs/scene" {
  66542. interface Scene {
  66543. /** @hidden (Backing field) */
  66544. _physicsEngine: Nullable<IPhysicsEngine>;
  66545. /** @hidden */
  66546. _physicsTimeAccumulator: number;
  66547. /**
  66548. * Gets the current physics engine
  66549. * @returns a IPhysicsEngine or null if none attached
  66550. */
  66551. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66552. /**
  66553. * Enables physics to the current scene
  66554. * @param gravity defines the scene's gravity for the physics engine
  66555. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66556. * @return a boolean indicating if the physics engine was initialized
  66557. */
  66558. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66559. /**
  66560. * Disables and disposes the physics engine associated with the scene
  66561. */
  66562. disablePhysicsEngine(): void;
  66563. /**
  66564. * Gets a boolean indicating if there is an active physics engine
  66565. * @returns a boolean indicating if there is an active physics engine
  66566. */
  66567. isPhysicsEnabled(): boolean;
  66568. /**
  66569. * Deletes a physics compound impostor
  66570. * @param compound defines the compound to delete
  66571. */
  66572. deleteCompoundImpostor(compound: any): void;
  66573. /**
  66574. * An event triggered when physic simulation is about to be run
  66575. */
  66576. onBeforePhysicsObservable: Observable<Scene>;
  66577. /**
  66578. * An event triggered when physic simulation has been done
  66579. */
  66580. onAfterPhysicsObservable: Observable<Scene>;
  66581. }
  66582. }
  66583. module "babylonjs/Meshes/abstractMesh" {
  66584. interface AbstractMesh {
  66585. /** @hidden */
  66586. _physicsImpostor: Nullable<PhysicsImpostor>;
  66587. /**
  66588. * Gets or sets impostor used for physic simulation
  66589. * @see http://doc.babylonjs.com/features/physics_engine
  66590. */
  66591. physicsImpostor: Nullable<PhysicsImpostor>;
  66592. /**
  66593. * Gets the current physics impostor
  66594. * @see http://doc.babylonjs.com/features/physics_engine
  66595. * @returns a physics impostor or null
  66596. */
  66597. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66598. /** Apply a physic impulse to the mesh
  66599. * @param force defines the force to apply
  66600. * @param contactPoint defines where to apply the force
  66601. * @returns the current mesh
  66602. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66603. */
  66604. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66605. /**
  66606. * Creates a physic joint between two meshes
  66607. * @param otherMesh defines the other mesh to use
  66608. * @param pivot1 defines the pivot to use on this mesh
  66609. * @param pivot2 defines the pivot to use on the other mesh
  66610. * @param options defines additional options (can be plugin dependent)
  66611. * @returns the current mesh
  66612. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66613. */
  66614. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66615. /** @hidden */
  66616. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66617. }
  66618. }
  66619. /**
  66620. * Defines the physics engine scene component responsible to manage a physics engine
  66621. */
  66622. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66623. /**
  66624. * The component name helpful to identify the component in the list of scene components.
  66625. */
  66626. readonly name: string;
  66627. /**
  66628. * The scene the component belongs to.
  66629. */
  66630. scene: Scene;
  66631. /**
  66632. * Creates a new instance of the component for the given scene
  66633. * @param scene Defines the scene to register the component in
  66634. */
  66635. constructor(scene: Scene);
  66636. /**
  66637. * Registers the component in a given scene
  66638. */
  66639. register(): void;
  66640. /**
  66641. * Rebuilds the elements related to this component in case of
  66642. * context lost for instance.
  66643. */
  66644. rebuild(): void;
  66645. /**
  66646. * Disposes the component and the associated ressources
  66647. */
  66648. dispose(): void;
  66649. }
  66650. }
  66651. declare module "babylonjs/Physics/physicsHelper" {
  66652. import { Nullable } from "babylonjs/types";
  66653. import { Vector3 } from "babylonjs/Maths/math.vector";
  66654. import { Mesh } from "babylonjs/Meshes/mesh";
  66655. import { Scene } from "babylonjs/scene";
  66656. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66657. /**
  66658. * A helper for physics simulations
  66659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66660. */
  66661. export class PhysicsHelper {
  66662. private _scene;
  66663. private _physicsEngine;
  66664. /**
  66665. * Initializes the Physics helper
  66666. * @param scene Babylon.js scene
  66667. */
  66668. constructor(scene: Scene);
  66669. /**
  66670. * Applies a radial explosion impulse
  66671. * @param origin the origin of the explosion
  66672. * @param radiusOrEventOptions the radius or the options of radial explosion
  66673. * @param strength the explosion strength
  66674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66675. * @returns A physics radial explosion event, or null
  66676. */
  66677. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66678. /**
  66679. * Applies a radial explosion force
  66680. * @param origin the origin of the explosion
  66681. * @param radiusOrEventOptions the radius or the options of radial explosion
  66682. * @param strength the explosion strength
  66683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66684. * @returns A physics radial explosion event, or null
  66685. */
  66686. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66687. /**
  66688. * Creates a gravitational field
  66689. * @param origin the origin of the explosion
  66690. * @param radiusOrEventOptions the radius or the options of radial explosion
  66691. * @param strength the explosion strength
  66692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66693. * @returns A physics gravitational field event, or null
  66694. */
  66695. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66696. /**
  66697. * Creates a physics updraft event
  66698. * @param origin the origin of the updraft
  66699. * @param radiusOrEventOptions the radius or the options of the updraft
  66700. * @param strength the strength of the updraft
  66701. * @param height the height of the updraft
  66702. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66703. * @returns A physics updraft event, or null
  66704. */
  66705. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66706. /**
  66707. * Creates a physics vortex event
  66708. * @param origin the of the vortex
  66709. * @param radiusOrEventOptions the radius or the options of the vortex
  66710. * @param strength the strength of the vortex
  66711. * @param height the height of the vortex
  66712. * @returns a Physics vortex event, or null
  66713. * A physics vortex event or null
  66714. */
  66715. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66716. }
  66717. /**
  66718. * Represents a physics radial explosion event
  66719. */
  66720. class PhysicsRadialExplosionEvent {
  66721. private _scene;
  66722. private _options;
  66723. private _sphere;
  66724. private _dataFetched;
  66725. /**
  66726. * Initializes a radial explosioin event
  66727. * @param _scene BabylonJS scene
  66728. * @param _options The options for the vortex event
  66729. */
  66730. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66731. /**
  66732. * Returns the data related to the radial explosion event (sphere).
  66733. * @returns The radial explosion event data
  66734. */
  66735. getData(): PhysicsRadialExplosionEventData;
  66736. /**
  66737. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66738. * @param impostor A physics imposter
  66739. * @param origin the origin of the explosion
  66740. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66741. */
  66742. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66743. /**
  66744. * Triggers affecterd impostors callbacks
  66745. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66746. */
  66747. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66748. /**
  66749. * Disposes the sphere.
  66750. * @param force Specifies if the sphere should be disposed by force
  66751. */
  66752. dispose(force?: boolean): void;
  66753. /*** Helpers ***/
  66754. private _prepareSphere;
  66755. private _intersectsWithSphere;
  66756. }
  66757. /**
  66758. * Represents a gravitational field event
  66759. */
  66760. class PhysicsGravitationalFieldEvent {
  66761. private _physicsHelper;
  66762. private _scene;
  66763. private _origin;
  66764. private _options;
  66765. private _tickCallback;
  66766. private _sphere;
  66767. private _dataFetched;
  66768. /**
  66769. * Initializes the physics gravitational field event
  66770. * @param _physicsHelper A physics helper
  66771. * @param _scene BabylonJS scene
  66772. * @param _origin The origin position of the gravitational field event
  66773. * @param _options The options for the vortex event
  66774. */
  66775. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66776. /**
  66777. * Returns the data related to the gravitational field event (sphere).
  66778. * @returns A gravitational field event
  66779. */
  66780. getData(): PhysicsGravitationalFieldEventData;
  66781. /**
  66782. * Enables the gravitational field.
  66783. */
  66784. enable(): void;
  66785. /**
  66786. * Disables the gravitational field.
  66787. */
  66788. disable(): void;
  66789. /**
  66790. * Disposes the sphere.
  66791. * @param force The force to dispose from the gravitational field event
  66792. */
  66793. dispose(force?: boolean): void;
  66794. private _tick;
  66795. }
  66796. /**
  66797. * Represents a physics updraft event
  66798. */
  66799. class PhysicsUpdraftEvent {
  66800. private _scene;
  66801. private _origin;
  66802. private _options;
  66803. private _physicsEngine;
  66804. private _originTop;
  66805. private _originDirection;
  66806. private _tickCallback;
  66807. private _cylinder;
  66808. private _cylinderPosition;
  66809. private _dataFetched;
  66810. /**
  66811. * Initializes the physics updraft event
  66812. * @param _scene BabylonJS scene
  66813. * @param _origin The origin position of the updraft
  66814. * @param _options The options for the updraft event
  66815. */
  66816. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66817. /**
  66818. * Returns the data related to the updraft event (cylinder).
  66819. * @returns A physics updraft event
  66820. */
  66821. getData(): PhysicsUpdraftEventData;
  66822. /**
  66823. * Enables the updraft.
  66824. */
  66825. enable(): void;
  66826. /**
  66827. * Disables the updraft.
  66828. */
  66829. disable(): void;
  66830. /**
  66831. * Disposes the cylinder.
  66832. * @param force Specifies if the updraft should be disposed by force
  66833. */
  66834. dispose(force?: boolean): void;
  66835. private getImpostorHitData;
  66836. private _tick;
  66837. /*** Helpers ***/
  66838. private _prepareCylinder;
  66839. private _intersectsWithCylinder;
  66840. }
  66841. /**
  66842. * Represents a physics vortex event
  66843. */
  66844. class PhysicsVortexEvent {
  66845. private _scene;
  66846. private _origin;
  66847. private _options;
  66848. private _physicsEngine;
  66849. private _originTop;
  66850. private _tickCallback;
  66851. private _cylinder;
  66852. private _cylinderPosition;
  66853. private _dataFetched;
  66854. /**
  66855. * Initializes the physics vortex event
  66856. * @param _scene The BabylonJS scene
  66857. * @param _origin The origin position of the vortex
  66858. * @param _options The options for the vortex event
  66859. */
  66860. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66861. /**
  66862. * Returns the data related to the vortex event (cylinder).
  66863. * @returns The physics vortex event data
  66864. */
  66865. getData(): PhysicsVortexEventData;
  66866. /**
  66867. * Enables the vortex.
  66868. */
  66869. enable(): void;
  66870. /**
  66871. * Disables the cortex.
  66872. */
  66873. disable(): void;
  66874. /**
  66875. * Disposes the sphere.
  66876. * @param force
  66877. */
  66878. dispose(force?: boolean): void;
  66879. private getImpostorHitData;
  66880. private _tick;
  66881. /*** Helpers ***/
  66882. private _prepareCylinder;
  66883. private _intersectsWithCylinder;
  66884. }
  66885. /**
  66886. * Options fot the radial explosion event
  66887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66888. */
  66889. export class PhysicsRadialExplosionEventOptions {
  66890. /**
  66891. * The radius of the sphere for the radial explosion.
  66892. */
  66893. radius: number;
  66894. /**
  66895. * The strenth of the explosion.
  66896. */
  66897. strength: number;
  66898. /**
  66899. * The strenght of the force in correspondence to the distance of the affected object
  66900. */
  66901. falloff: PhysicsRadialImpulseFalloff;
  66902. /**
  66903. * Sphere options for the radial explosion.
  66904. */
  66905. sphere: {
  66906. segments: number;
  66907. diameter: number;
  66908. };
  66909. /**
  66910. * Sphere options for the radial explosion.
  66911. */
  66912. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66913. }
  66914. /**
  66915. * Options fot the updraft event
  66916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66917. */
  66918. export class PhysicsUpdraftEventOptions {
  66919. /**
  66920. * The radius of the cylinder for the vortex
  66921. */
  66922. radius: number;
  66923. /**
  66924. * The strenth of the updraft.
  66925. */
  66926. strength: number;
  66927. /**
  66928. * The height of the cylinder for the updraft.
  66929. */
  66930. height: number;
  66931. /**
  66932. * The mode for the the updraft.
  66933. */
  66934. updraftMode: PhysicsUpdraftMode;
  66935. }
  66936. /**
  66937. * Options fot the vortex event
  66938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66939. */
  66940. export class PhysicsVortexEventOptions {
  66941. /**
  66942. * The radius of the cylinder for the vortex
  66943. */
  66944. radius: number;
  66945. /**
  66946. * The strenth of the vortex.
  66947. */
  66948. strength: number;
  66949. /**
  66950. * The height of the cylinder for the vortex.
  66951. */
  66952. height: number;
  66953. /**
  66954. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66955. */
  66956. centripetalForceThreshold: number;
  66957. /**
  66958. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66959. */
  66960. centripetalForceMultiplier: number;
  66961. /**
  66962. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66963. */
  66964. centrifugalForceMultiplier: number;
  66965. /**
  66966. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66967. */
  66968. updraftForceMultiplier: number;
  66969. }
  66970. /**
  66971. * The strenght of the force in correspondence to the distance of the affected object
  66972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66973. */
  66974. export enum PhysicsRadialImpulseFalloff {
  66975. /** Defines that impulse is constant in strength across it's whole radius */
  66976. Constant = 0,
  66977. /** Defines that impulse gets weaker if it's further from the origin */
  66978. Linear = 1
  66979. }
  66980. /**
  66981. * The strength of the force in correspondence to the distance of the affected object
  66982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66983. */
  66984. export enum PhysicsUpdraftMode {
  66985. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66986. Center = 0,
  66987. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66988. Perpendicular = 1
  66989. }
  66990. /**
  66991. * Interface for a physics hit data
  66992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66993. */
  66994. export interface PhysicsHitData {
  66995. /**
  66996. * The force applied at the contact point
  66997. */
  66998. force: Vector3;
  66999. /**
  67000. * The contact point
  67001. */
  67002. contactPoint: Vector3;
  67003. /**
  67004. * The distance from the origin to the contact point
  67005. */
  67006. distanceFromOrigin: number;
  67007. }
  67008. /**
  67009. * Interface for radial explosion event data
  67010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67011. */
  67012. export interface PhysicsRadialExplosionEventData {
  67013. /**
  67014. * A sphere used for the radial explosion event
  67015. */
  67016. sphere: Mesh;
  67017. }
  67018. /**
  67019. * Interface for gravitational field event data
  67020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67021. */
  67022. export interface PhysicsGravitationalFieldEventData {
  67023. /**
  67024. * A sphere mesh used for the gravitational field event
  67025. */
  67026. sphere: Mesh;
  67027. }
  67028. /**
  67029. * Interface for updraft event data
  67030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67031. */
  67032. export interface PhysicsUpdraftEventData {
  67033. /**
  67034. * A cylinder used for the updraft event
  67035. */
  67036. cylinder: Mesh;
  67037. }
  67038. /**
  67039. * Interface for vortex event data
  67040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67041. */
  67042. export interface PhysicsVortexEventData {
  67043. /**
  67044. * A cylinder used for the vortex event
  67045. */
  67046. cylinder: Mesh;
  67047. }
  67048. /**
  67049. * Interface for an affected physics impostor
  67050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67051. */
  67052. export interface PhysicsAffectedImpostorWithData {
  67053. /**
  67054. * The impostor affected by the effect
  67055. */
  67056. impostor: PhysicsImpostor;
  67057. /**
  67058. * The data about the hit/horce from the explosion
  67059. */
  67060. hitData: PhysicsHitData;
  67061. }
  67062. }
  67063. declare module "babylonjs/Physics/Plugins/index" {
  67064. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67065. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67066. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67067. }
  67068. declare module "babylonjs/Physics/index" {
  67069. export * from "babylonjs/Physics/IPhysicsEngine";
  67070. export * from "babylonjs/Physics/physicsEngine";
  67071. export * from "babylonjs/Physics/physicsEngineComponent";
  67072. export * from "babylonjs/Physics/physicsHelper";
  67073. export * from "babylonjs/Physics/physicsImpostor";
  67074. export * from "babylonjs/Physics/physicsJoint";
  67075. export * from "babylonjs/Physics/Plugins/index";
  67076. }
  67077. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67078. /** @hidden */
  67079. export var blackAndWhitePixelShader: {
  67080. name: string;
  67081. shader: string;
  67082. };
  67083. }
  67084. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67085. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67086. import { Camera } from "babylonjs/Cameras/camera";
  67087. import { Engine } from "babylonjs/Engines/engine";
  67088. import "babylonjs/Shaders/blackAndWhite.fragment";
  67089. /**
  67090. * Post process used to render in black and white
  67091. */
  67092. export class BlackAndWhitePostProcess extends PostProcess {
  67093. /**
  67094. * Linear about to convert he result to black and white (default: 1)
  67095. */
  67096. degree: number;
  67097. /**
  67098. * Creates a black and white post process
  67099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67100. * @param name The name of the effect.
  67101. * @param options The required width/height ratio to downsize to before computing the render pass.
  67102. * @param camera The camera to apply the render pass to.
  67103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67104. * @param engine The engine which the post process will be applied. (default: current engine)
  67105. * @param reusable If the post process can be reused on the same frame. (default: false)
  67106. */
  67107. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67108. }
  67109. }
  67110. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67111. import { Nullable } from "babylonjs/types";
  67112. import { Camera } from "babylonjs/Cameras/camera";
  67113. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67114. import { Engine } from "babylonjs/Engines/engine";
  67115. /**
  67116. * This represents a set of one or more post processes in Babylon.
  67117. * A post process can be used to apply a shader to a texture after it is rendered.
  67118. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67119. */
  67120. export class PostProcessRenderEffect {
  67121. private _postProcesses;
  67122. private _getPostProcesses;
  67123. private _singleInstance;
  67124. private _cameras;
  67125. private _indicesForCamera;
  67126. /**
  67127. * Name of the effect
  67128. * @hidden
  67129. */
  67130. _name: string;
  67131. /**
  67132. * Instantiates a post process render effect.
  67133. * A post process can be used to apply a shader to a texture after it is rendered.
  67134. * @param engine The engine the effect is tied to
  67135. * @param name The name of the effect
  67136. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67137. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67138. */
  67139. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67140. /**
  67141. * Checks if all the post processes in the effect are supported.
  67142. */
  67143. get isSupported(): boolean;
  67144. /**
  67145. * Updates the current state of the effect
  67146. * @hidden
  67147. */
  67148. _update(): void;
  67149. /**
  67150. * Attaches the effect on cameras
  67151. * @param cameras The camera to attach to.
  67152. * @hidden
  67153. */
  67154. _attachCameras(cameras: Camera): void;
  67155. /**
  67156. * Attaches the effect on cameras
  67157. * @param cameras The camera to attach to.
  67158. * @hidden
  67159. */
  67160. _attachCameras(cameras: Camera[]): void;
  67161. /**
  67162. * Detaches the effect on cameras
  67163. * @param cameras The camera to detatch from.
  67164. * @hidden
  67165. */
  67166. _detachCameras(cameras: Camera): void;
  67167. /**
  67168. * Detatches the effect on cameras
  67169. * @param cameras The camera to detatch from.
  67170. * @hidden
  67171. */
  67172. _detachCameras(cameras: Camera[]): void;
  67173. /**
  67174. * Enables the effect on given cameras
  67175. * @param cameras The camera to enable.
  67176. * @hidden
  67177. */
  67178. _enable(cameras: Camera): void;
  67179. /**
  67180. * Enables the effect on given cameras
  67181. * @param cameras The camera to enable.
  67182. * @hidden
  67183. */
  67184. _enable(cameras: Nullable<Camera[]>): void;
  67185. /**
  67186. * Disables the effect on the given cameras
  67187. * @param cameras The camera to disable.
  67188. * @hidden
  67189. */
  67190. _disable(cameras: Camera): void;
  67191. /**
  67192. * Disables the effect on the given cameras
  67193. * @param cameras The camera to disable.
  67194. * @hidden
  67195. */
  67196. _disable(cameras: Nullable<Camera[]>): void;
  67197. /**
  67198. * Gets a list of the post processes contained in the effect.
  67199. * @param camera The camera to get the post processes on.
  67200. * @returns The list of the post processes in the effect.
  67201. */
  67202. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67203. }
  67204. }
  67205. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67206. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67207. /** @hidden */
  67208. export var extractHighlightsPixelShader: {
  67209. name: string;
  67210. shader: string;
  67211. };
  67212. }
  67213. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67214. import { Nullable } from "babylonjs/types";
  67215. import { Camera } from "babylonjs/Cameras/camera";
  67216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67217. import { Engine } from "babylonjs/Engines/engine";
  67218. import "babylonjs/Shaders/extractHighlights.fragment";
  67219. /**
  67220. * 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.
  67221. */
  67222. export class ExtractHighlightsPostProcess extends PostProcess {
  67223. /**
  67224. * The luminance threshold, pixels below this value will be set to black.
  67225. */
  67226. threshold: number;
  67227. /** @hidden */
  67228. _exposure: number;
  67229. /**
  67230. * Post process which has the input texture to be used when performing highlight extraction
  67231. * @hidden
  67232. */
  67233. _inputPostProcess: Nullable<PostProcess>;
  67234. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67235. }
  67236. }
  67237. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67238. /** @hidden */
  67239. export var bloomMergePixelShader: {
  67240. name: string;
  67241. shader: string;
  67242. };
  67243. }
  67244. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67245. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67246. import { Nullable } from "babylonjs/types";
  67247. import { Engine } from "babylonjs/Engines/engine";
  67248. import { Camera } from "babylonjs/Cameras/camera";
  67249. import "babylonjs/Shaders/bloomMerge.fragment";
  67250. /**
  67251. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67252. */
  67253. export class BloomMergePostProcess extends PostProcess {
  67254. /** Weight of the bloom to be added to the original input. */
  67255. weight: number;
  67256. /**
  67257. * Creates a new instance of @see BloomMergePostProcess
  67258. * @param name The name of the effect.
  67259. * @param originalFromInput Post process which's input will be used for the merge.
  67260. * @param blurred Blurred highlights post process which's output will be used.
  67261. * @param weight Weight of the bloom to be added to the original input.
  67262. * @param options The required width/height ratio to downsize to before computing the render pass.
  67263. * @param camera The camera to apply the render pass to.
  67264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67265. * @param engine The engine which the post process will be applied. (default: current engine)
  67266. * @param reusable If the post process can be reused on the same frame. (default: false)
  67267. * @param textureType Type of textures used when performing the post process. (default: 0)
  67268. * @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)
  67269. */
  67270. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67271. /** Weight of the bloom to be added to the original input. */
  67272. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67273. }
  67274. }
  67275. declare module "babylonjs/PostProcesses/bloomEffect" {
  67276. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67278. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67279. import { Camera } from "babylonjs/Cameras/camera";
  67280. import { Scene } from "babylonjs/scene";
  67281. /**
  67282. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67283. */
  67284. export class BloomEffect extends PostProcessRenderEffect {
  67285. private bloomScale;
  67286. /**
  67287. * @hidden Internal
  67288. */
  67289. _effects: Array<PostProcess>;
  67290. /**
  67291. * @hidden Internal
  67292. */
  67293. _downscale: ExtractHighlightsPostProcess;
  67294. private _blurX;
  67295. private _blurY;
  67296. private _merge;
  67297. /**
  67298. * The luminance threshold to find bright areas of the image to bloom.
  67299. */
  67300. get threshold(): number;
  67301. set threshold(value: number);
  67302. /**
  67303. * The strength of the bloom.
  67304. */
  67305. get weight(): number;
  67306. set weight(value: number);
  67307. /**
  67308. * Specifies the size of the bloom blur kernel, relative to the final output size
  67309. */
  67310. get kernel(): number;
  67311. set kernel(value: number);
  67312. /**
  67313. * Creates a new instance of @see BloomEffect
  67314. * @param scene The scene the effect belongs to.
  67315. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67316. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67317. * @param bloomWeight The the strength of bloom.
  67318. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67319. * @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)
  67320. */
  67321. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67322. /**
  67323. * Disposes each of the internal effects for a given camera.
  67324. * @param camera The camera to dispose the effect on.
  67325. */
  67326. disposeEffects(camera: Camera): void;
  67327. /**
  67328. * @hidden Internal
  67329. */
  67330. _updateEffects(): void;
  67331. /**
  67332. * Internal
  67333. * @returns if all the contained post processes are ready.
  67334. * @hidden
  67335. */
  67336. _isReady(): boolean;
  67337. }
  67338. }
  67339. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67340. /** @hidden */
  67341. export var chromaticAberrationPixelShader: {
  67342. name: string;
  67343. shader: string;
  67344. };
  67345. }
  67346. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67347. import { Vector2 } from "babylonjs/Maths/math.vector";
  67348. import { Nullable } from "babylonjs/types";
  67349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67350. import { Camera } from "babylonjs/Cameras/camera";
  67351. import { Engine } from "babylonjs/Engines/engine";
  67352. import "babylonjs/Shaders/chromaticAberration.fragment";
  67353. /**
  67354. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67355. */
  67356. export class ChromaticAberrationPostProcess extends PostProcess {
  67357. /**
  67358. * The amount of seperation of rgb channels (default: 30)
  67359. */
  67360. aberrationAmount: number;
  67361. /**
  67362. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67363. */
  67364. radialIntensity: number;
  67365. /**
  67366. * 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))
  67367. */
  67368. direction: Vector2;
  67369. /**
  67370. * 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))
  67371. */
  67372. centerPosition: Vector2;
  67373. /**
  67374. * Creates a new instance ChromaticAberrationPostProcess
  67375. * @param name The name of the effect.
  67376. * @param screenWidth The width of the screen to apply the effect on.
  67377. * @param screenHeight The height of the screen to apply the effect on.
  67378. * @param options The required width/height ratio to downsize to before computing the render pass.
  67379. * @param camera The camera to apply the render pass to.
  67380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67381. * @param engine The engine which the post process will be applied. (default: current engine)
  67382. * @param reusable If the post process can be reused on the same frame. (default: false)
  67383. * @param textureType Type of textures used when performing the post process. (default: 0)
  67384. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  67385. */
  67386. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67387. }
  67388. }
  67389. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67390. /** @hidden */
  67391. export var circleOfConfusionPixelShader: {
  67392. name: string;
  67393. shader: string;
  67394. };
  67395. }
  67396. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67397. import { Nullable } from "babylonjs/types";
  67398. import { Engine } from "babylonjs/Engines/engine";
  67399. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67401. import { Camera } from "babylonjs/Cameras/camera";
  67402. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67403. /**
  67404. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67405. */
  67406. export class CircleOfConfusionPostProcess extends PostProcess {
  67407. /**
  67408. * 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.
  67409. */
  67410. lensSize: number;
  67411. /**
  67412. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67413. */
  67414. fStop: number;
  67415. /**
  67416. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67417. */
  67418. focusDistance: number;
  67419. /**
  67420. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67421. */
  67422. focalLength: number;
  67423. private _depthTexture;
  67424. /**
  67425. * Creates a new instance CircleOfConfusionPostProcess
  67426. * @param name The name of the effect.
  67427. * @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.
  67428. * @param options The required width/height ratio to downsize to before computing the render pass.
  67429. * @param camera The camera to apply the render pass to.
  67430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67431. * @param engine The engine which the post process will be applied. (default: current engine)
  67432. * @param reusable If the post process can be reused on the same frame. (default: false)
  67433. * @param textureType Type of textures used when performing the post process. (default: 0)
  67434. * @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)
  67435. */
  67436. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67437. /**
  67438. * 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.
  67439. */
  67440. set depthTexture(value: RenderTargetTexture);
  67441. }
  67442. }
  67443. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67444. /** @hidden */
  67445. export var colorCorrectionPixelShader: {
  67446. name: string;
  67447. shader: string;
  67448. };
  67449. }
  67450. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67451. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67452. import { Engine } from "babylonjs/Engines/engine";
  67453. import { Camera } from "babylonjs/Cameras/camera";
  67454. import "babylonjs/Shaders/colorCorrection.fragment";
  67455. /**
  67456. *
  67457. * This post-process allows the modification of rendered colors by using
  67458. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67459. *
  67460. * The object needs to be provided an url to a texture containing the color
  67461. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67462. * Use an image editing software to tweak the LUT to match your needs.
  67463. *
  67464. * For an example of a color LUT, see here:
  67465. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67466. * For explanations on color grading, see here:
  67467. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67468. *
  67469. */
  67470. export class ColorCorrectionPostProcess extends PostProcess {
  67471. private _colorTableTexture;
  67472. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67473. }
  67474. }
  67475. declare module "babylonjs/Shaders/convolution.fragment" {
  67476. /** @hidden */
  67477. export var convolutionPixelShader: {
  67478. name: string;
  67479. shader: string;
  67480. };
  67481. }
  67482. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67483. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67484. import { Nullable } from "babylonjs/types";
  67485. import { Camera } from "babylonjs/Cameras/camera";
  67486. import { Engine } from "babylonjs/Engines/engine";
  67487. import "babylonjs/Shaders/convolution.fragment";
  67488. /**
  67489. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67490. * input texture to perform effects such as edge detection or sharpening
  67491. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67492. */
  67493. export class ConvolutionPostProcess extends PostProcess {
  67494. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67495. kernel: number[];
  67496. /**
  67497. * Creates a new instance ConvolutionPostProcess
  67498. * @param name The name of the effect.
  67499. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67500. * @param options The required width/height ratio to downsize to before computing the render pass.
  67501. * @param camera The camera to apply the render pass to.
  67502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67503. * @param engine The engine which the post process will be applied. (default: current engine)
  67504. * @param reusable If the post process can be reused on the same frame. (default: false)
  67505. * @param textureType Type of textures used when performing the post process. (default: 0)
  67506. */
  67507. constructor(name: string,
  67508. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67509. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67510. /**
  67511. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67512. */
  67513. static EdgeDetect0Kernel: number[];
  67514. /**
  67515. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67516. */
  67517. static EdgeDetect1Kernel: number[];
  67518. /**
  67519. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67520. */
  67521. static EdgeDetect2Kernel: number[];
  67522. /**
  67523. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67524. */
  67525. static SharpenKernel: number[];
  67526. /**
  67527. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67528. */
  67529. static EmbossKernel: number[];
  67530. /**
  67531. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67532. */
  67533. static GaussianKernel: number[];
  67534. }
  67535. }
  67536. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67537. import { Nullable } from "babylonjs/types";
  67538. import { Vector2 } from "babylonjs/Maths/math.vector";
  67539. import { Camera } from "babylonjs/Cameras/camera";
  67540. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67541. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67542. import { Engine } from "babylonjs/Engines/engine";
  67543. import { Scene } from "babylonjs/scene";
  67544. /**
  67545. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67546. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67547. * based on samples that have a large difference in distance than the center pixel.
  67548. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67549. */
  67550. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67551. direction: Vector2;
  67552. /**
  67553. * Creates a new instance CircleOfConfusionPostProcess
  67554. * @param name The name of the effect.
  67555. * @param scene The scene the effect belongs to.
  67556. * @param direction The direction the blur should be applied.
  67557. * @param kernel The size of the kernel used to blur.
  67558. * @param options The required width/height ratio to downsize to before computing the render pass.
  67559. * @param camera The camera to apply the render pass to.
  67560. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67561. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67563. * @param engine The engine which the post process will be applied. (default: current engine)
  67564. * @param reusable If the post process can be reused on the same frame. (default: false)
  67565. * @param textureType Type of textures used when performing the post process. (default: 0)
  67566. * @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)
  67567. */
  67568. 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);
  67569. }
  67570. }
  67571. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67572. /** @hidden */
  67573. export var depthOfFieldMergePixelShader: {
  67574. name: string;
  67575. shader: string;
  67576. };
  67577. }
  67578. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67579. import { Nullable } from "babylonjs/types";
  67580. import { Camera } from "babylonjs/Cameras/camera";
  67581. import { Effect } from "babylonjs/Materials/effect";
  67582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67583. import { Engine } from "babylonjs/Engines/engine";
  67584. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67585. /**
  67586. * Options to be set when merging outputs from the default pipeline.
  67587. */
  67588. export class DepthOfFieldMergePostProcessOptions {
  67589. /**
  67590. * The original image to merge on top of
  67591. */
  67592. originalFromInput: PostProcess;
  67593. /**
  67594. * Parameters to perform the merge of the depth of field effect
  67595. */
  67596. depthOfField?: {
  67597. circleOfConfusion: PostProcess;
  67598. blurSteps: Array<PostProcess>;
  67599. };
  67600. /**
  67601. * Parameters to perform the merge of bloom effect
  67602. */
  67603. bloom?: {
  67604. blurred: PostProcess;
  67605. weight: number;
  67606. };
  67607. }
  67608. /**
  67609. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67610. */
  67611. export class DepthOfFieldMergePostProcess extends PostProcess {
  67612. private blurSteps;
  67613. /**
  67614. * Creates a new instance of DepthOfFieldMergePostProcess
  67615. * @param name The name of the effect.
  67616. * @param originalFromInput Post process which's input will be used for the merge.
  67617. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67618. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67619. * @param options The required width/height ratio to downsize to before computing the render pass.
  67620. * @param camera The camera to apply the render pass to.
  67621. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67622. * @param engine The engine which the post process will be applied. (default: current engine)
  67623. * @param reusable If the post process can be reused on the same frame. (default: false)
  67624. * @param textureType Type of textures used when performing the post process. (default: 0)
  67625. * @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)
  67626. */
  67627. 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);
  67628. /**
  67629. * Updates the effect with the current post process compile time values and recompiles the shader.
  67630. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67631. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67632. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67633. * @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
  67634. * @param onCompiled Called when the shader has been compiled.
  67635. * @param onError Called if there is an error when compiling a shader.
  67636. */
  67637. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67638. }
  67639. }
  67640. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67641. import { Nullable } from "babylonjs/types";
  67642. import { Camera } from "babylonjs/Cameras/camera";
  67643. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67644. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67645. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67646. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67647. import { Scene } from "babylonjs/scene";
  67648. /**
  67649. * Specifies the level of max blur that should be applied when using the depth of field effect
  67650. */
  67651. export enum DepthOfFieldEffectBlurLevel {
  67652. /**
  67653. * Subtle blur
  67654. */
  67655. Low = 0,
  67656. /**
  67657. * Medium blur
  67658. */
  67659. Medium = 1,
  67660. /**
  67661. * Large blur
  67662. */
  67663. High = 2
  67664. }
  67665. /**
  67666. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67667. */
  67668. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67669. private _circleOfConfusion;
  67670. /**
  67671. * @hidden Internal, blurs from high to low
  67672. */
  67673. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67674. private _depthOfFieldBlurY;
  67675. private _dofMerge;
  67676. /**
  67677. * @hidden Internal post processes in depth of field effect
  67678. */
  67679. _effects: Array<PostProcess>;
  67680. /**
  67681. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67682. */
  67683. set focalLength(value: number);
  67684. get focalLength(): number;
  67685. /**
  67686. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67687. */
  67688. set fStop(value: number);
  67689. get fStop(): number;
  67690. /**
  67691. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67692. */
  67693. set focusDistance(value: number);
  67694. get focusDistance(): number;
  67695. /**
  67696. * 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.
  67697. */
  67698. set lensSize(value: number);
  67699. get lensSize(): number;
  67700. /**
  67701. * Creates a new instance DepthOfFieldEffect
  67702. * @param scene The scene the effect belongs to.
  67703. * @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.
  67704. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67705. * @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)
  67706. */
  67707. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67708. /**
  67709. * Get the current class name of the current effet
  67710. * @returns "DepthOfFieldEffect"
  67711. */
  67712. getClassName(): string;
  67713. /**
  67714. * 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.
  67715. */
  67716. set depthTexture(value: RenderTargetTexture);
  67717. /**
  67718. * Disposes each of the internal effects for a given camera.
  67719. * @param camera The camera to dispose the effect on.
  67720. */
  67721. disposeEffects(camera: Camera): void;
  67722. /**
  67723. * @hidden Internal
  67724. */
  67725. _updateEffects(): void;
  67726. /**
  67727. * Internal
  67728. * @returns if all the contained post processes are ready.
  67729. * @hidden
  67730. */
  67731. _isReady(): boolean;
  67732. }
  67733. }
  67734. declare module "babylonjs/Shaders/displayPass.fragment" {
  67735. /** @hidden */
  67736. export var displayPassPixelShader: {
  67737. name: string;
  67738. shader: string;
  67739. };
  67740. }
  67741. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67742. import { Nullable } from "babylonjs/types";
  67743. import { Camera } from "babylonjs/Cameras/camera";
  67744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67745. import { Engine } from "babylonjs/Engines/engine";
  67746. import "babylonjs/Shaders/displayPass.fragment";
  67747. /**
  67748. * DisplayPassPostProcess which produces an output the same as it's input
  67749. */
  67750. export class DisplayPassPostProcess extends PostProcess {
  67751. /**
  67752. * Creates the DisplayPassPostProcess
  67753. * @param name The name of the effect.
  67754. * @param options The required width/height ratio to downsize to before computing the render pass.
  67755. * @param camera The camera to apply the render pass to.
  67756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67757. * @param engine The engine which the post process will be applied. (default: current engine)
  67758. * @param reusable If the post process can be reused on the same frame. (default: false)
  67759. */
  67760. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67761. }
  67762. }
  67763. declare module "babylonjs/Shaders/filter.fragment" {
  67764. /** @hidden */
  67765. export var filterPixelShader: {
  67766. name: string;
  67767. shader: string;
  67768. };
  67769. }
  67770. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67771. import { Nullable } from "babylonjs/types";
  67772. import { Matrix } from "babylonjs/Maths/math.vector";
  67773. import { Camera } from "babylonjs/Cameras/camera";
  67774. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67775. import { Engine } from "babylonjs/Engines/engine";
  67776. import "babylonjs/Shaders/filter.fragment";
  67777. /**
  67778. * Applies a kernel filter to the image
  67779. */
  67780. export class FilterPostProcess extends PostProcess {
  67781. /** The matrix to be applied to the image */
  67782. kernelMatrix: Matrix;
  67783. /**
  67784. *
  67785. * @param name The name of the effect.
  67786. * @param kernelMatrix The matrix to be applied to the image
  67787. * @param options The required width/height ratio to downsize to before computing the render pass.
  67788. * @param camera The camera to apply the render pass to.
  67789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67790. * @param engine The engine which the post process will be applied. (default: current engine)
  67791. * @param reusable If the post process can be reused on the same frame. (default: false)
  67792. */
  67793. constructor(name: string,
  67794. /** The matrix to be applied to the image */
  67795. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67796. }
  67797. }
  67798. declare module "babylonjs/Shaders/fxaa.fragment" {
  67799. /** @hidden */
  67800. export var fxaaPixelShader: {
  67801. name: string;
  67802. shader: string;
  67803. };
  67804. }
  67805. declare module "babylonjs/Shaders/fxaa.vertex" {
  67806. /** @hidden */
  67807. export var fxaaVertexShader: {
  67808. name: string;
  67809. shader: string;
  67810. };
  67811. }
  67812. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67813. import { Nullable } from "babylonjs/types";
  67814. import { Camera } from "babylonjs/Cameras/camera";
  67815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67816. import { Engine } from "babylonjs/Engines/engine";
  67817. import "babylonjs/Shaders/fxaa.fragment";
  67818. import "babylonjs/Shaders/fxaa.vertex";
  67819. /**
  67820. * Fxaa post process
  67821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67822. */
  67823. export class FxaaPostProcess extends PostProcess {
  67824. /** @hidden */
  67825. texelWidth: number;
  67826. /** @hidden */
  67827. texelHeight: number;
  67828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67829. private _getDefines;
  67830. }
  67831. }
  67832. declare module "babylonjs/Shaders/grain.fragment" {
  67833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67834. /** @hidden */
  67835. export var grainPixelShader: {
  67836. name: string;
  67837. shader: string;
  67838. };
  67839. }
  67840. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67841. import { Nullable } from "babylonjs/types";
  67842. import { Camera } from "babylonjs/Cameras/camera";
  67843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67844. import { Engine } from "babylonjs/Engines/engine";
  67845. import "babylonjs/Shaders/grain.fragment";
  67846. /**
  67847. * The GrainPostProcess adds noise to the image at mid luminance levels
  67848. */
  67849. export class GrainPostProcess extends PostProcess {
  67850. /**
  67851. * The intensity of the grain added (default: 30)
  67852. */
  67853. intensity: number;
  67854. /**
  67855. * If the grain should be randomized on every frame
  67856. */
  67857. animated: boolean;
  67858. /**
  67859. * Creates a new instance of @see GrainPostProcess
  67860. * @param name The name of the effect.
  67861. * @param options The required width/height ratio to downsize to before computing the render pass.
  67862. * @param camera The camera to apply the render pass to.
  67863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67864. * @param engine The engine which the post process will be applied. (default: current engine)
  67865. * @param reusable If the post process can be reused on the same frame. (default: false)
  67866. * @param textureType Type of textures used when performing the post process. (default: 0)
  67867. * @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)
  67868. */
  67869. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67870. }
  67871. }
  67872. declare module "babylonjs/Shaders/highlights.fragment" {
  67873. /** @hidden */
  67874. export var highlightsPixelShader: {
  67875. name: string;
  67876. shader: string;
  67877. };
  67878. }
  67879. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67880. import { Nullable } from "babylonjs/types";
  67881. import { Camera } from "babylonjs/Cameras/camera";
  67882. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67883. import { Engine } from "babylonjs/Engines/engine";
  67884. import "babylonjs/Shaders/highlights.fragment";
  67885. /**
  67886. * Extracts highlights from the image
  67887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67888. */
  67889. export class HighlightsPostProcess extends PostProcess {
  67890. /**
  67891. * Extracts highlights from the image
  67892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67893. * @param name The name of the effect.
  67894. * @param options The required width/height ratio to downsize to before computing the render pass.
  67895. * @param camera The camera to apply the render pass to.
  67896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67897. * @param engine The engine which the post process will be applied. (default: current engine)
  67898. * @param reusable If the post process can be reused on the same frame. (default: false)
  67899. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67900. */
  67901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67902. }
  67903. }
  67904. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67905. /** @hidden */
  67906. export var mrtFragmentDeclaration: {
  67907. name: string;
  67908. shader: string;
  67909. };
  67910. }
  67911. declare module "babylonjs/Shaders/geometry.fragment" {
  67912. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67913. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67914. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67915. /** @hidden */
  67916. export var geometryPixelShader: {
  67917. name: string;
  67918. shader: string;
  67919. };
  67920. }
  67921. declare module "babylonjs/Shaders/geometry.vertex" {
  67922. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67925. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67927. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67928. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67929. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67930. /** @hidden */
  67931. export var geometryVertexShader: {
  67932. name: string;
  67933. shader: string;
  67934. };
  67935. }
  67936. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67937. import { Matrix } from "babylonjs/Maths/math.vector";
  67938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67939. import { Mesh } from "babylonjs/Meshes/mesh";
  67940. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67941. import { Effect } from "babylonjs/Materials/effect";
  67942. import { Scene } from "babylonjs/scene";
  67943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67944. import "babylonjs/Shaders/geometry.fragment";
  67945. import "babylonjs/Shaders/geometry.vertex";
  67946. /** @hidden */
  67947. interface ISavedTransformationMatrix {
  67948. world: Matrix;
  67949. viewProjection: Matrix;
  67950. }
  67951. /**
  67952. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67953. */
  67954. export class GeometryBufferRenderer {
  67955. /**
  67956. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67957. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67958. */
  67959. static readonly POSITION_TEXTURE_TYPE: number;
  67960. /**
  67961. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67962. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67963. */
  67964. static readonly VELOCITY_TEXTURE_TYPE: number;
  67965. /**
  67966. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67967. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67968. */
  67969. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67970. /**
  67971. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67972. * in order to compute objects velocities when enableVelocity is set to "true"
  67973. * @hidden
  67974. */
  67975. _previousTransformationMatrices: {
  67976. [index: number]: ISavedTransformationMatrix;
  67977. };
  67978. /**
  67979. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67980. * in order to compute objects velocities when enableVelocity is set to "true"
  67981. * @hidden
  67982. */
  67983. _previousBonesTransformationMatrices: {
  67984. [index: number]: Float32Array;
  67985. };
  67986. /**
  67987. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67988. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67989. */
  67990. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67991. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67992. renderTransparentMeshes: boolean;
  67993. private _scene;
  67994. private _multiRenderTarget;
  67995. private _ratio;
  67996. private _enablePosition;
  67997. private _enableVelocity;
  67998. private _enableReflectivity;
  67999. private _positionIndex;
  68000. private _velocityIndex;
  68001. private _reflectivityIndex;
  68002. protected _effect: Effect;
  68003. protected _cachedDefines: string;
  68004. /**
  68005. * Set the render list (meshes to be rendered) used in the G buffer.
  68006. */
  68007. set renderList(meshes: Mesh[]);
  68008. /**
  68009. * Gets wether or not G buffer are supported by the running hardware.
  68010. * This requires draw buffer supports
  68011. */
  68012. get isSupported(): boolean;
  68013. /**
  68014. * Returns the index of the given texture type in the G-Buffer textures array
  68015. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68016. * @returns the index of the given texture type in the G-Buffer textures array
  68017. */
  68018. getTextureIndex(textureType: number): number;
  68019. /**
  68020. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68021. */
  68022. get enablePosition(): boolean;
  68023. /**
  68024. * Sets whether or not objects positions are enabled for the G buffer.
  68025. */
  68026. set enablePosition(enable: boolean);
  68027. /**
  68028. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68029. */
  68030. get enableVelocity(): boolean;
  68031. /**
  68032. * Sets wether or not objects velocities are enabled for the G buffer.
  68033. */
  68034. set enableVelocity(enable: boolean);
  68035. /**
  68036. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68037. */
  68038. get enableReflectivity(): boolean;
  68039. /**
  68040. * Sets wether or not objects roughness are enabled for the G buffer.
  68041. */
  68042. set enableReflectivity(enable: boolean);
  68043. /**
  68044. * Gets the scene associated with the buffer.
  68045. */
  68046. get scene(): Scene;
  68047. /**
  68048. * Gets the ratio used by the buffer during its creation.
  68049. * How big is the buffer related to the main canvas.
  68050. */
  68051. get ratio(): number;
  68052. /** @hidden */
  68053. static _SceneComponentInitialization: (scene: Scene) => void;
  68054. /**
  68055. * Creates a new G Buffer for the scene
  68056. * @param scene The scene the buffer belongs to
  68057. * @param ratio How big is the buffer related to the main canvas.
  68058. */
  68059. constructor(scene: Scene, ratio?: number);
  68060. /**
  68061. * Checks wether everything is ready to render a submesh to the G buffer.
  68062. * @param subMesh the submesh to check readiness for
  68063. * @param useInstances is the mesh drawn using instance or not
  68064. * @returns true if ready otherwise false
  68065. */
  68066. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68067. /**
  68068. * Gets the current underlying G Buffer.
  68069. * @returns the buffer
  68070. */
  68071. getGBuffer(): MultiRenderTarget;
  68072. /**
  68073. * Gets the number of samples used to render the buffer (anti aliasing).
  68074. */
  68075. get samples(): number;
  68076. /**
  68077. * Sets the number of samples used to render the buffer (anti aliasing).
  68078. */
  68079. set samples(value: number);
  68080. /**
  68081. * Disposes the renderer and frees up associated resources.
  68082. */
  68083. dispose(): void;
  68084. protected _createRenderTargets(): void;
  68085. private _copyBonesTransformationMatrices;
  68086. }
  68087. }
  68088. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68089. import { Nullable } from "babylonjs/types";
  68090. import { Scene } from "babylonjs/scene";
  68091. import { ISceneComponent } from "babylonjs/sceneComponent";
  68092. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68093. module "babylonjs/scene" {
  68094. interface Scene {
  68095. /** @hidden (Backing field) */
  68096. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68097. /**
  68098. * Gets or Sets the current geometry buffer associated to the scene.
  68099. */
  68100. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68101. /**
  68102. * Enables a GeometryBufferRender and associates it with the scene
  68103. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68104. * @returns the GeometryBufferRenderer
  68105. */
  68106. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68107. /**
  68108. * Disables the GeometryBufferRender associated with the scene
  68109. */
  68110. disableGeometryBufferRenderer(): void;
  68111. }
  68112. }
  68113. /**
  68114. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68115. * in several rendering techniques.
  68116. */
  68117. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68118. /**
  68119. * The component name helpful to identify the component in the list of scene components.
  68120. */
  68121. readonly name: string;
  68122. /**
  68123. * The scene the component belongs to.
  68124. */
  68125. scene: Scene;
  68126. /**
  68127. * Creates a new instance of the component for the given scene
  68128. * @param scene Defines the scene to register the component in
  68129. */
  68130. constructor(scene: Scene);
  68131. /**
  68132. * Registers the component in a given scene
  68133. */
  68134. register(): void;
  68135. /**
  68136. * Rebuilds the elements related to this component in case of
  68137. * context lost for instance.
  68138. */
  68139. rebuild(): void;
  68140. /**
  68141. * Disposes the component and the associated ressources
  68142. */
  68143. dispose(): void;
  68144. private _gatherRenderTargets;
  68145. }
  68146. }
  68147. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68148. /** @hidden */
  68149. export var motionBlurPixelShader: {
  68150. name: string;
  68151. shader: string;
  68152. };
  68153. }
  68154. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68155. import { Nullable } from "babylonjs/types";
  68156. import { Camera } from "babylonjs/Cameras/camera";
  68157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68158. import { Scene } from "babylonjs/scene";
  68159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68160. import "babylonjs/Animations/animatable";
  68161. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68162. import "babylonjs/Shaders/motionBlur.fragment";
  68163. import { Engine } from "babylonjs/Engines/engine";
  68164. /**
  68165. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68166. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68167. * As an example, all you have to do is to create the post-process:
  68168. * var mb = new BABYLON.MotionBlurPostProcess(
  68169. * 'mb', // The name of the effect.
  68170. * scene, // The scene containing the objects to blur according to their velocity.
  68171. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68172. * camera // The camera to apply the render pass to.
  68173. * );
  68174. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68175. */
  68176. export class MotionBlurPostProcess extends PostProcess {
  68177. /**
  68178. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68179. */
  68180. motionStrength: number;
  68181. /**
  68182. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68183. */
  68184. get motionBlurSamples(): number;
  68185. /**
  68186. * Sets the number of iterations to be used for motion blur quality
  68187. */
  68188. set motionBlurSamples(samples: number);
  68189. private _motionBlurSamples;
  68190. private _geometryBufferRenderer;
  68191. /**
  68192. * Creates a new instance MotionBlurPostProcess
  68193. * @param name The name of the effect.
  68194. * @param scene The scene containing the objects to blur according to their velocity.
  68195. * @param options The required width/height ratio to downsize to before computing the render pass.
  68196. * @param camera The camera to apply the render pass to.
  68197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68198. * @param engine The engine which the post process will be applied. (default: current engine)
  68199. * @param reusable If the post process can be reused on the same frame. (default: false)
  68200. * @param textureType Type of textures used when performing the post process. (default: 0)
  68201. * @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)
  68202. */
  68203. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68204. /**
  68205. * Excludes the given skinned mesh from computing bones velocities.
  68206. * 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.
  68207. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68208. */
  68209. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68210. /**
  68211. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68212. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68213. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68214. */
  68215. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68216. /**
  68217. * Disposes the post process.
  68218. * @param camera The camera to dispose the post process on.
  68219. */
  68220. dispose(camera?: Camera): void;
  68221. }
  68222. }
  68223. declare module "babylonjs/Shaders/refraction.fragment" {
  68224. /** @hidden */
  68225. export var refractionPixelShader: {
  68226. name: string;
  68227. shader: string;
  68228. };
  68229. }
  68230. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68231. import { Color3 } from "babylonjs/Maths/math.color";
  68232. import { Camera } from "babylonjs/Cameras/camera";
  68233. import { Texture } from "babylonjs/Materials/Textures/texture";
  68234. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68235. import { Engine } from "babylonjs/Engines/engine";
  68236. import "babylonjs/Shaders/refraction.fragment";
  68237. /**
  68238. * Post process which applies a refractin texture
  68239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68240. */
  68241. export class RefractionPostProcess extends PostProcess {
  68242. /** the base color of the refraction (used to taint the rendering) */
  68243. color: Color3;
  68244. /** simulated refraction depth */
  68245. depth: number;
  68246. /** the coefficient of the base color (0 to remove base color tainting) */
  68247. colorLevel: number;
  68248. private _refTexture;
  68249. private _ownRefractionTexture;
  68250. /**
  68251. * Gets or sets the refraction texture
  68252. * Please note that you are responsible for disposing the texture if you set it manually
  68253. */
  68254. get refractionTexture(): Texture;
  68255. set refractionTexture(value: Texture);
  68256. /**
  68257. * Initializes the RefractionPostProcess
  68258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68259. * @param name The name of the effect.
  68260. * @param refractionTextureUrl Url of the refraction texture to use
  68261. * @param color the base color of the refraction (used to taint the rendering)
  68262. * @param depth simulated refraction depth
  68263. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68264. * @param camera The camera to apply the render pass to.
  68265. * @param options The required width/height ratio to downsize to before computing the render pass.
  68266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68267. * @param engine The engine which the post process will be applied. (default: current engine)
  68268. * @param reusable If the post process can be reused on the same frame. (default: false)
  68269. */
  68270. constructor(name: string, refractionTextureUrl: string,
  68271. /** the base color of the refraction (used to taint the rendering) */
  68272. color: Color3,
  68273. /** simulated refraction depth */
  68274. depth: number,
  68275. /** the coefficient of the base color (0 to remove base color tainting) */
  68276. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68277. /**
  68278. * Disposes of the post process
  68279. * @param camera Camera to dispose post process on
  68280. */
  68281. dispose(camera: Camera): void;
  68282. }
  68283. }
  68284. declare module "babylonjs/Shaders/sharpen.fragment" {
  68285. /** @hidden */
  68286. export var sharpenPixelShader: {
  68287. name: string;
  68288. shader: string;
  68289. };
  68290. }
  68291. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68292. import { Nullable } from "babylonjs/types";
  68293. import { Camera } from "babylonjs/Cameras/camera";
  68294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68295. import "babylonjs/Shaders/sharpen.fragment";
  68296. import { Engine } from "babylonjs/Engines/engine";
  68297. /**
  68298. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68299. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68300. */
  68301. export class SharpenPostProcess extends PostProcess {
  68302. /**
  68303. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68304. */
  68305. colorAmount: number;
  68306. /**
  68307. * How much sharpness should be applied (default: 0.3)
  68308. */
  68309. edgeAmount: number;
  68310. /**
  68311. * Creates a new instance ConvolutionPostProcess
  68312. * @param name The name of the effect.
  68313. * @param options The required width/height ratio to downsize to before computing the render pass.
  68314. * @param camera The camera to apply the render pass to.
  68315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68316. * @param engine The engine which the post process will be applied. (default: current engine)
  68317. * @param reusable If the post process can be reused on the same frame. (default: false)
  68318. * @param textureType Type of textures used when performing the post process. (default: 0)
  68319. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  68320. */
  68321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68322. }
  68323. }
  68324. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68325. import { Nullable } from "babylonjs/types";
  68326. import { Camera } from "babylonjs/Cameras/camera";
  68327. import { Engine } from "babylonjs/Engines/engine";
  68328. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68329. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68330. /**
  68331. * PostProcessRenderPipeline
  68332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68333. */
  68334. export class PostProcessRenderPipeline {
  68335. private engine;
  68336. private _renderEffects;
  68337. private _renderEffectsForIsolatedPass;
  68338. /**
  68339. * List of inspectable custom properties (used by the Inspector)
  68340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68341. */
  68342. inspectableCustomProperties: IInspectable[];
  68343. /**
  68344. * @hidden
  68345. */
  68346. protected _cameras: Camera[];
  68347. /** @hidden */
  68348. _name: string;
  68349. /**
  68350. * Gets pipeline name
  68351. */
  68352. get name(): string;
  68353. /** Gets the list of attached cameras */
  68354. get cameras(): Camera[];
  68355. /**
  68356. * Initializes a PostProcessRenderPipeline
  68357. * @param engine engine to add the pipeline to
  68358. * @param name name of the pipeline
  68359. */
  68360. constructor(engine: Engine, name: string);
  68361. /**
  68362. * Gets the class name
  68363. * @returns "PostProcessRenderPipeline"
  68364. */
  68365. getClassName(): string;
  68366. /**
  68367. * If all the render effects in the pipeline are supported
  68368. */
  68369. get isSupported(): boolean;
  68370. /**
  68371. * Adds an effect to the pipeline
  68372. * @param renderEffect the effect to add
  68373. */
  68374. addEffect(renderEffect: PostProcessRenderEffect): void;
  68375. /** @hidden */
  68376. _rebuild(): void;
  68377. /** @hidden */
  68378. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68379. /** @hidden */
  68380. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68381. /** @hidden */
  68382. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68383. /** @hidden */
  68384. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68385. /** @hidden */
  68386. _attachCameras(cameras: Camera, unique: boolean): void;
  68387. /** @hidden */
  68388. _attachCameras(cameras: Camera[], unique: boolean): void;
  68389. /** @hidden */
  68390. _detachCameras(cameras: Camera): void;
  68391. /** @hidden */
  68392. _detachCameras(cameras: Nullable<Camera[]>): void;
  68393. /** @hidden */
  68394. _update(): void;
  68395. /** @hidden */
  68396. _reset(): void;
  68397. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68398. /**
  68399. * Disposes of the pipeline
  68400. */
  68401. dispose(): void;
  68402. }
  68403. }
  68404. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68405. import { Camera } from "babylonjs/Cameras/camera";
  68406. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68407. /**
  68408. * PostProcessRenderPipelineManager class
  68409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68410. */
  68411. export class PostProcessRenderPipelineManager {
  68412. private _renderPipelines;
  68413. /**
  68414. * Initializes a PostProcessRenderPipelineManager
  68415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68416. */
  68417. constructor();
  68418. /**
  68419. * Gets the list of supported render pipelines
  68420. */
  68421. get supportedPipelines(): PostProcessRenderPipeline[];
  68422. /**
  68423. * Adds a pipeline to the manager
  68424. * @param renderPipeline The pipeline to add
  68425. */
  68426. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68427. /**
  68428. * Attaches a camera to the pipeline
  68429. * @param renderPipelineName The name of the pipeline to attach to
  68430. * @param cameras the camera to attach
  68431. * @param unique if the camera can be attached multiple times to the pipeline
  68432. */
  68433. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68434. /**
  68435. * Detaches a camera from the pipeline
  68436. * @param renderPipelineName The name of the pipeline to detach from
  68437. * @param cameras the camera to detach
  68438. */
  68439. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68440. /**
  68441. * Enables an effect by name on a pipeline
  68442. * @param renderPipelineName the name of the pipeline to enable the effect in
  68443. * @param renderEffectName the name of the effect to enable
  68444. * @param cameras the cameras that the effect should be enabled on
  68445. */
  68446. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68447. /**
  68448. * Disables an effect by name on a pipeline
  68449. * @param renderPipelineName the name of the pipeline to disable the effect in
  68450. * @param renderEffectName the name of the effect to disable
  68451. * @param cameras the cameras that the effect should be disabled on
  68452. */
  68453. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68454. /**
  68455. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68456. */
  68457. update(): void;
  68458. /** @hidden */
  68459. _rebuild(): void;
  68460. /**
  68461. * Disposes of the manager and pipelines
  68462. */
  68463. dispose(): void;
  68464. }
  68465. }
  68466. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68467. import { ISceneComponent } from "babylonjs/sceneComponent";
  68468. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68469. import { Scene } from "babylonjs/scene";
  68470. module "babylonjs/scene" {
  68471. interface Scene {
  68472. /** @hidden (Backing field) */
  68473. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68474. /**
  68475. * Gets the postprocess render pipeline manager
  68476. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68477. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68478. */
  68479. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68480. }
  68481. }
  68482. /**
  68483. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68484. */
  68485. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68486. /**
  68487. * The component name helpfull to identify the component in the list of scene components.
  68488. */
  68489. readonly name: string;
  68490. /**
  68491. * The scene the component belongs to.
  68492. */
  68493. scene: Scene;
  68494. /**
  68495. * Creates a new instance of the component for the given scene
  68496. * @param scene Defines the scene to register the component in
  68497. */
  68498. constructor(scene: Scene);
  68499. /**
  68500. * Registers the component in a given scene
  68501. */
  68502. register(): void;
  68503. /**
  68504. * Rebuilds the elements related to this component in case of
  68505. * context lost for instance.
  68506. */
  68507. rebuild(): void;
  68508. /**
  68509. * Disposes the component and the associated ressources
  68510. */
  68511. dispose(): void;
  68512. private _gatherRenderTargets;
  68513. }
  68514. }
  68515. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68516. import { Nullable } from "babylonjs/types";
  68517. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68518. import { Camera } from "babylonjs/Cameras/camera";
  68519. import { IDisposable } from "babylonjs/scene";
  68520. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68521. import { Scene } from "babylonjs/scene";
  68522. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68523. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68524. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68525. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68526. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68527. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68528. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68529. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68530. import { Animation } from "babylonjs/Animations/animation";
  68531. /**
  68532. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68533. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68534. */
  68535. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68536. private _scene;
  68537. private _camerasToBeAttached;
  68538. /**
  68539. * ID of the sharpen post process,
  68540. */
  68541. private readonly SharpenPostProcessId;
  68542. /**
  68543. * @ignore
  68544. * ID of the image processing post process;
  68545. */
  68546. readonly ImageProcessingPostProcessId: string;
  68547. /**
  68548. * @ignore
  68549. * ID of the Fast Approximate Anti-Aliasing post process;
  68550. */
  68551. readonly FxaaPostProcessId: string;
  68552. /**
  68553. * ID of the chromatic aberration post process,
  68554. */
  68555. private readonly ChromaticAberrationPostProcessId;
  68556. /**
  68557. * ID of the grain post process
  68558. */
  68559. private readonly GrainPostProcessId;
  68560. /**
  68561. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68562. */
  68563. sharpen: SharpenPostProcess;
  68564. private _sharpenEffect;
  68565. private bloom;
  68566. /**
  68567. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68568. */
  68569. depthOfField: DepthOfFieldEffect;
  68570. /**
  68571. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68572. */
  68573. fxaa: FxaaPostProcess;
  68574. /**
  68575. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68576. */
  68577. imageProcessing: ImageProcessingPostProcess;
  68578. /**
  68579. * Chromatic aberration post process which will shift rgb colors in the image
  68580. */
  68581. chromaticAberration: ChromaticAberrationPostProcess;
  68582. private _chromaticAberrationEffect;
  68583. /**
  68584. * Grain post process which add noise to the image
  68585. */
  68586. grain: GrainPostProcess;
  68587. private _grainEffect;
  68588. /**
  68589. * Glow post process which adds a glow to emissive areas of the image
  68590. */
  68591. private _glowLayer;
  68592. /**
  68593. * Animations which can be used to tweak settings over a period of time
  68594. */
  68595. animations: Animation[];
  68596. private _imageProcessingConfigurationObserver;
  68597. private _sharpenEnabled;
  68598. private _bloomEnabled;
  68599. private _depthOfFieldEnabled;
  68600. private _depthOfFieldBlurLevel;
  68601. private _fxaaEnabled;
  68602. private _imageProcessingEnabled;
  68603. private _defaultPipelineTextureType;
  68604. private _bloomScale;
  68605. private _chromaticAberrationEnabled;
  68606. private _grainEnabled;
  68607. private _buildAllowed;
  68608. /**
  68609. * Gets active scene
  68610. */
  68611. get scene(): Scene;
  68612. /**
  68613. * Enable or disable the sharpen process from the pipeline
  68614. */
  68615. set sharpenEnabled(enabled: boolean);
  68616. get sharpenEnabled(): boolean;
  68617. private _resizeObserver;
  68618. private _hardwareScaleLevel;
  68619. private _bloomKernel;
  68620. /**
  68621. * Specifies the size of the bloom blur kernel, relative to the final output size
  68622. */
  68623. get bloomKernel(): number;
  68624. set bloomKernel(value: number);
  68625. /**
  68626. * Specifies the weight of the bloom in the final rendering
  68627. */
  68628. private _bloomWeight;
  68629. /**
  68630. * Specifies the luma threshold for the area that will be blurred by the bloom
  68631. */
  68632. private _bloomThreshold;
  68633. private _hdr;
  68634. /**
  68635. * The strength of the bloom.
  68636. */
  68637. set bloomWeight(value: number);
  68638. get bloomWeight(): number;
  68639. /**
  68640. * The strength of the bloom.
  68641. */
  68642. set bloomThreshold(value: number);
  68643. get bloomThreshold(): number;
  68644. /**
  68645. * The scale of the bloom, lower value will provide better performance.
  68646. */
  68647. set bloomScale(value: number);
  68648. get bloomScale(): number;
  68649. /**
  68650. * Enable or disable the bloom from the pipeline
  68651. */
  68652. set bloomEnabled(enabled: boolean);
  68653. get bloomEnabled(): boolean;
  68654. private _rebuildBloom;
  68655. /**
  68656. * If the depth of field is enabled.
  68657. */
  68658. get depthOfFieldEnabled(): boolean;
  68659. set depthOfFieldEnabled(enabled: boolean);
  68660. /**
  68661. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68662. */
  68663. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68664. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68665. /**
  68666. * If the anti aliasing is enabled.
  68667. */
  68668. set fxaaEnabled(enabled: boolean);
  68669. get fxaaEnabled(): boolean;
  68670. private _samples;
  68671. /**
  68672. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68673. */
  68674. set samples(sampleCount: number);
  68675. get samples(): number;
  68676. /**
  68677. * If image processing is enabled.
  68678. */
  68679. set imageProcessingEnabled(enabled: boolean);
  68680. get imageProcessingEnabled(): boolean;
  68681. /**
  68682. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68683. */
  68684. set glowLayerEnabled(enabled: boolean);
  68685. get glowLayerEnabled(): boolean;
  68686. /**
  68687. * Gets the glow layer (or null if not defined)
  68688. */
  68689. get glowLayer(): Nullable<GlowLayer>;
  68690. /**
  68691. * Enable or disable the chromaticAberration process from the pipeline
  68692. */
  68693. set chromaticAberrationEnabled(enabled: boolean);
  68694. get chromaticAberrationEnabled(): boolean;
  68695. /**
  68696. * Enable or disable the grain process from the pipeline
  68697. */
  68698. set grainEnabled(enabled: boolean);
  68699. get grainEnabled(): boolean;
  68700. /**
  68701. * @constructor
  68702. * @param name - The rendering pipeline name (default: "")
  68703. * @param hdr - If high dynamic range textures should be used (default: true)
  68704. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68705. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68706. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68707. */
  68708. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68709. /**
  68710. * Get the class name
  68711. * @returns "DefaultRenderingPipeline"
  68712. */
  68713. getClassName(): string;
  68714. /**
  68715. * Force the compilation of the entire pipeline.
  68716. */
  68717. prepare(): void;
  68718. private _hasCleared;
  68719. private _prevPostProcess;
  68720. private _prevPrevPostProcess;
  68721. private _setAutoClearAndTextureSharing;
  68722. private _depthOfFieldSceneObserver;
  68723. private _buildPipeline;
  68724. private _disposePostProcesses;
  68725. /**
  68726. * Adds a camera to the pipeline
  68727. * @param camera the camera to be added
  68728. */
  68729. addCamera(camera: Camera): void;
  68730. /**
  68731. * Removes a camera from the pipeline
  68732. * @param camera the camera to remove
  68733. */
  68734. removeCamera(camera: Camera): void;
  68735. /**
  68736. * Dispose of the pipeline and stop all post processes
  68737. */
  68738. dispose(): void;
  68739. /**
  68740. * Serialize the rendering pipeline (Used when exporting)
  68741. * @returns the serialized object
  68742. */
  68743. serialize(): any;
  68744. /**
  68745. * Parse the serialized pipeline
  68746. * @param source Source pipeline.
  68747. * @param scene The scene to load the pipeline to.
  68748. * @param rootUrl The URL of the serialized pipeline.
  68749. * @returns An instantiated pipeline from the serialized object.
  68750. */
  68751. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68752. }
  68753. }
  68754. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68755. /** @hidden */
  68756. export var lensHighlightsPixelShader: {
  68757. name: string;
  68758. shader: string;
  68759. };
  68760. }
  68761. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68762. /** @hidden */
  68763. export var depthOfFieldPixelShader: {
  68764. name: string;
  68765. shader: string;
  68766. };
  68767. }
  68768. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68769. import { Camera } from "babylonjs/Cameras/camera";
  68770. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68771. import { Scene } from "babylonjs/scene";
  68772. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68773. import "babylonjs/Shaders/chromaticAberration.fragment";
  68774. import "babylonjs/Shaders/lensHighlights.fragment";
  68775. import "babylonjs/Shaders/depthOfField.fragment";
  68776. /**
  68777. * BABYLON.JS Chromatic Aberration GLSL Shader
  68778. * Author: Olivier Guyot
  68779. * Separates very slightly R, G and B colors on the edges of the screen
  68780. * Inspired by Francois Tarlier & Martins Upitis
  68781. */
  68782. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68783. /**
  68784. * @ignore
  68785. * The chromatic aberration PostProcess id in the pipeline
  68786. */
  68787. LensChromaticAberrationEffect: string;
  68788. /**
  68789. * @ignore
  68790. * The highlights enhancing PostProcess id in the pipeline
  68791. */
  68792. HighlightsEnhancingEffect: string;
  68793. /**
  68794. * @ignore
  68795. * The depth-of-field PostProcess id in the pipeline
  68796. */
  68797. LensDepthOfFieldEffect: string;
  68798. private _scene;
  68799. private _depthTexture;
  68800. private _grainTexture;
  68801. private _chromaticAberrationPostProcess;
  68802. private _highlightsPostProcess;
  68803. private _depthOfFieldPostProcess;
  68804. private _edgeBlur;
  68805. private _grainAmount;
  68806. private _chromaticAberration;
  68807. private _distortion;
  68808. private _highlightsGain;
  68809. private _highlightsThreshold;
  68810. private _dofDistance;
  68811. private _dofAperture;
  68812. private _dofDarken;
  68813. private _dofPentagon;
  68814. private _blurNoise;
  68815. /**
  68816. * @constructor
  68817. *
  68818. * Effect parameters are as follow:
  68819. * {
  68820. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68821. * edge_blur: number; // from 0 to x (1 for realism)
  68822. * distortion: number; // from 0 to x (1 for realism)
  68823. * grain_amount: number; // from 0 to 1
  68824. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68825. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68826. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68827. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68828. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68829. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68830. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68831. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68832. * }
  68833. * Note: if an effect parameter is unset, effect is disabled
  68834. *
  68835. * @param name The rendering pipeline name
  68836. * @param parameters - An object containing all parameters (see above)
  68837. * @param scene The scene linked to this pipeline
  68838. * @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)
  68839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68840. */
  68841. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68842. /**
  68843. * Get the class name
  68844. * @returns "LensRenderingPipeline"
  68845. */
  68846. getClassName(): string;
  68847. /**
  68848. * Gets associated scene
  68849. */
  68850. get scene(): Scene;
  68851. /**
  68852. * Gets or sets the edge blur
  68853. */
  68854. get edgeBlur(): number;
  68855. set edgeBlur(value: number);
  68856. /**
  68857. * Gets or sets the grain amount
  68858. */
  68859. get grainAmount(): number;
  68860. set grainAmount(value: number);
  68861. /**
  68862. * Gets or sets the chromatic aberration amount
  68863. */
  68864. get chromaticAberration(): number;
  68865. set chromaticAberration(value: number);
  68866. /**
  68867. * Gets or sets the depth of field aperture
  68868. */
  68869. get dofAperture(): number;
  68870. set dofAperture(value: number);
  68871. /**
  68872. * Gets or sets the edge distortion
  68873. */
  68874. get edgeDistortion(): number;
  68875. set edgeDistortion(value: number);
  68876. /**
  68877. * Gets or sets the depth of field distortion
  68878. */
  68879. get dofDistortion(): number;
  68880. set dofDistortion(value: number);
  68881. /**
  68882. * Gets or sets the darken out of focus amount
  68883. */
  68884. get darkenOutOfFocus(): number;
  68885. set darkenOutOfFocus(value: number);
  68886. /**
  68887. * Gets or sets a boolean indicating if blur noise is enabled
  68888. */
  68889. get blurNoise(): boolean;
  68890. set blurNoise(value: boolean);
  68891. /**
  68892. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68893. */
  68894. get pentagonBokeh(): boolean;
  68895. set pentagonBokeh(value: boolean);
  68896. /**
  68897. * Gets or sets the highlight grain amount
  68898. */
  68899. get highlightsGain(): number;
  68900. set highlightsGain(value: number);
  68901. /**
  68902. * Gets or sets the highlight threshold
  68903. */
  68904. get highlightsThreshold(): number;
  68905. set highlightsThreshold(value: number);
  68906. /**
  68907. * Sets the amount of blur at the edges
  68908. * @param amount blur amount
  68909. */
  68910. setEdgeBlur(amount: number): void;
  68911. /**
  68912. * Sets edge blur to 0
  68913. */
  68914. disableEdgeBlur(): void;
  68915. /**
  68916. * Sets the amout of grain
  68917. * @param amount Amount of grain
  68918. */
  68919. setGrainAmount(amount: number): void;
  68920. /**
  68921. * Set grain amount to 0
  68922. */
  68923. disableGrain(): void;
  68924. /**
  68925. * Sets the chromatic aberration amount
  68926. * @param amount amount of chromatic aberration
  68927. */
  68928. setChromaticAberration(amount: number): void;
  68929. /**
  68930. * Sets chromatic aberration amount to 0
  68931. */
  68932. disableChromaticAberration(): void;
  68933. /**
  68934. * Sets the EdgeDistortion amount
  68935. * @param amount amount of EdgeDistortion
  68936. */
  68937. setEdgeDistortion(amount: number): void;
  68938. /**
  68939. * Sets edge distortion to 0
  68940. */
  68941. disableEdgeDistortion(): void;
  68942. /**
  68943. * Sets the FocusDistance amount
  68944. * @param amount amount of FocusDistance
  68945. */
  68946. setFocusDistance(amount: number): void;
  68947. /**
  68948. * Disables depth of field
  68949. */
  68950. disableDepthOfField(): void;
  68951. /**
  68952. * Sets the Aperture amount
  68953. * @param amount amount of Aperture
  68954. */
  68955. setAperture(amount: number): void;
  68956. /**
  68957. * Sets the DarkenOutOfFocus amount
  68958. * @param amount amount of DarkenOutOfFocus
  68959. */
  68960. setDarkenOutOfFocus(amount: number): void;
  68961. private _pentagonBokehIsEnabled;
  68962. /**
  68963. * Creates a pentagon bokeh effect
  68964. */
  68965. enablePentagonBokeh(): void;
  68966. /**
  68967. * Disables the pentagon bokeh effect
  68968. */
  68969. disablePentagonBokeh(): void;
  68970. /**
  68971. * Enables noise blur
  68972. */
  68973. enableNoiseBlur(): void;
  68974. /**
  68975. * Disables noise blur
  68976. */
  68977. disableNoiseBlur(): void;
  68978. /**
  68979. * Sets the HighlightsGain amount
  68980. * @param amount amount of HighlightsGain
  68981. */
  68982. setHighlightsGain(amount: number): void;
  68983. /**
  68984. * Sets the HighlightsThreshold amount
  68985. * @param amount amount of HighlightsThreshold
  68986. */
  68987. setHighlightsThreshold(amount: number): void;
  68988. /**
  68989. * Disables highlights
  68990. */
  68991. disableHighlights(): void;
  68992. /**
  68993. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68994. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68995. */
  68996. dispose(disableDepthRender?: boolean): void;
  68997. private _createChromaticAberrationPostProcess;
  68998. private _createHighlightsPostProcess;
  68999. private _createDepthOfFieldPostProcess;
  69000. private _createGrainTexture;
  69001. }
  69002. }
  69003. declare module "babylonjs/Shaders/ssao2.fragment" {
  69004. /** @hidden */
  69005. export var ssao2PixelShader: {
  69006. name: string;
  69007. shader: string;
  69008. };
  69009. }
  69010. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69011. /** @hidden */
  69012. export var ssaoCombinePixelShader: {
  69013. name: string;
  69014. shader: string;
  69015. };
  69016. }
  69017. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69018. import { Camera } from "babylonjs/Cameras/camera";
  69019. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69020. import { Scene } from "babylonjs/scene";
  69021. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69022. import "babylonjs/Shaders/ssao2.fragment";
  69023. import "babylonjs/Shaders/ssaoCombine.fragment";
  69024. /**
  69025. * Render pipeline to produce ssao effect
  69026. */
  69027. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69028. /**
  69029. * @ignore
  69030. * The PassPostProcess id in the pipeline that contains the original scene color
  69031. */
  69032. SSAOOriginalSceneColorEffect: string;
  69033. /**
  69034. * @ignore
  69035. * The SSAO PostProcess id in the pipeline
  69036. */
  69037. SSAORenderEffect: string;
  69038. /**
  69039. * @ignore
  69040. * The horizontal blur PostProcess id in the pipeline
  69041. */
  69042. SSAOBlurHRenderEffect: string;
  69043. /**
  69044. * @ignore
  69045. * The vertical blur PostProcess id in the pipeline
  69046. */
  69047. SSAOBlurVRenderEffect: string;
  69048. /**
  69049. * @ignore
  69050. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69051. */
  69052. SSAOCombineRenderEffect: string;
  69053. /**
  69054. * The output strength of the SSAO post-process. Default value is 1.0.
  69055. */
  69056. totalStrength: number;
  69057. /**
  69058. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69059. */
  69060. maxZ: number;
  69061. /**
  69062. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69063. */
  69064. minZAspect: number;
  69065. private _samples;
  69066. /**
  69067. * Number of samples used for the SSAO calculations. Default value is 8
  69068. */
  69069. set samples(n: number);
  69070. get samples(): number;
  69071. private _textureSamples;
  69072. /**
  69073. * Number of samples to use for antialiasing
  69074. */
  69075. set textureSamples(n: number);
  69076. get textureSamples(): number;
  69077. /**
  69078. * Ratio object used for SSAO ratio and blur ratio
  69079. */
  69080. private _ratio;
  69081. /**
  69082. * Dynamically generated sphere sampler.
  69083. */
  69084. private _sampleSphere;
  69085. /**
  69086. * Blur filter offsets
  69087. */
  69088. private _samplerOffsets;
  69089. private _expensiveBlur;
  69090. /**
  69091. * If bilateral blur should be used
  69092. */
  69093. set expensiveBlur(b: boolean);
  69094. get expensiveBlur(): boolean;
  69095. /**
  69096. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69097. */
  69098. radius: number;
  69099. /**
  69100. * The base color of the SSAO post-process
  69101. * The final result is "base + ssao" between [0, 1]
  69102. */
  69103. base: number;
  69104. /**
  69105. * Support test.
  69106. */
  69107. static get IsSupported(): boolean;
  69108. private _scene;
  69109. private _depthTexture;
  69110. private _normalTexture;
  69111. private _randomTexture;
  69112. private _originalColorPostProcess;
  69113. private _ssaoPostProcess;
  69114. private _blurHPostProcess;
  69115. private _blurVPostProcess;
  69116. private _ssaoCombinePostProcess;
  69117. /**
  69118. * Gets active scene
  69119. */
  69120. get scene(): Scene;
  69121. /**
  69122. * @constructor
  69123. * @param name The rendering pipeline name
  69124. * @param scene The scene linked to this pipeline
  69125. * @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 }
  69126. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69127. */
  69128. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69129. /**
  69130. * Get the class name
  69131. * @returns "SSAO2RenderingPipeline"
  69132. */
  69133. getClassName(): string;
  69134. /**
  69135. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69136. */
  69137. dispose(disableGeometryBufferRenderer?: boolean): void;
  69138. private _createBlurPostProcess;
  69139. /** @hidden */
  69140. _rebuild(): void;
  69141. private _bits;
  69142. private _radicalInverse_VdC;
  69143. private _hammersley;
  69144. private _hemisphereSample_uniform;
  69145. private _generateHemisphere;
  69146. private _createSSAOPostProcess;
  69147. private _createSSAOCombinePostProcess;
  69148. private _createRandomTexture;
  69149. /**
  69150. * Serialize the rendering pipeline (Used when exporting)
  69151. * @returns the serialized object
  69152. */
  69153. serialize(): any;
  69154. /**
  69155. * Parse the serialized pipeline
  69156. * @param source Source pipeline.
  69157. * @param scene The scene to load the pipeline to.
  69158. * @param rootUrl The URL of the serialized pipeline.
  69159. * @returns An instantiated pipeline from the serialized object.
  69160. */
  69161. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69162. }
  69163. }
  69164. declare module "babylonjs/Shaders/ssao.fragment" {
  69165. /** @hidden */
  69166. export var ssaoPixelShader: {
  69167. name: string;
  69168. shader: string;
  69169. };
  69170. }
  69171. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69172. import { Camera } from "babylonjs/Cameras/camera";
  69173. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69174. import { Scene } from "babylonjs/scene";
  69175. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69176. import "babylonjs/Shaders/ssao.fragment";
  69177. import "babylonjs/Shaders/ssaoCombine.fragment";
  69178. /**
  69179. * Render pipeline to produce ssao effect
  69180. */
  69181. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69182. /**
  69183. * @ignore
  69184. * The PassPostProcess id in the pipeline that contains the original scene color
  69185. */
  69186. SSAOOriginalSceneColorEffect: string;
  69187. /**
  69188. * @ignore
  69189. * The SSAO PostProcess id in the pipeline
  69190. */
  69191. SSAORenderEffect: string;
  69192. /**
  69193. * @ignore
  69194. * The horizontal blur PostProcess id in the pipeline
  69195. */
  69196. SSAOBlurHRenderEffect: string;
  69197. /**
  69198. * @ignore
  69199. * The vertical blur PostProcess id in the pipeline
  69200. */
  69201. SSAOBlurVRenderEffect: string;
  69202. /**
  69203. * @ignore
  69204. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69205. */
  69206. SSAOCombineRenderEffect: string;
  69207. /**
  69208. * The output strength of the SSAO post-process. Default value is 1.0.
  69209. */
  69210. totalStrength: number;
  69211. /**
  69212. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69213. */
  69214. radius: number;
  69215. /**
  69216. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69217. * Must not be equal to fallOff and superior to fallOff.
  69218. * Default value is 0.0075
  69219. */
  69220. area: number;
  69221. /**
  69222. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69223. * Must not be equal to area and inferior to area.
  69224. * Default value is 0.000001
  69225. */
  69226. fallOff: number;
  69227. /**
  69228. * The base color of the SSAO post-process
  69229. * The final result is "base + ssao" between [0, 1]
  69230. */
  69231. base: number;
  69232. private _scene;
  69233. private _depthTexture;
  69234. private _randomTexture;
  69235. private _originalColorPostProcess;
  69236. private _ssaoPostProcess;
  69237. private _blurHPostProcess;
  69238. private _blurVPostProcess;
  69239. private _ssaoCombinePostProcess;
  69240. private _firstUpdate;
  69241. /**
  69242. * Gets active scene
  69243. */
  69244. get scene(): Scene;
  69245. /**
  69246. * @constructor
  69247. * @param name - The rendering pipeline name
  69248. * @param scene - The scene linked to this pipeline
  69249. * @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 }
  69250. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69251. */
  69252. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69253. /**
  69254. * Get the class name
  69255. * @returns "SSAORenderingPipeline"
  69256. */
  69257. getClassName(): string;
  69258. /**
  69259. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69260. */
  69261. dispose(disableDepthRender?: boolean): void;
  69262. private _createBlurPostProcess;
  69263. /** @hidden */
  69264. _rebuild(): void;
  69265. private _createSSAOPostProcess;
  69266. private _createSSAOCombinePostProcess;
  69267. private _createRandomTexture;
  69268. }
  69269. }
  69270. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69271. /** @hidden */
  69272. export var screenSpaceReflectionPixelShader: {
  69273. name: string;
  69274. shader: string;
  69275. };
  69276. }
  69277. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69278. import { Nullable } from "babylonjs/types";
  69279. import { Camera } from "babylonjs/Cameras/camera";
  69280. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69281. import { Scene } from "babylonjs/scene";
  69282. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69283. import { Engine } from "babylonjs/Engines/engine";
  69284. /**
  69285. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69286. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69287. */
  69288. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69289. /**
  69290. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69291. */
  69292. threshold: number;
  69293. /**
  69294. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69295. */
  69296. strength: number;
  69297. /**
  69298. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69299. */
  69300. reflectionSpecularFalloffExponent: number;
  69301. /**
  69302. * 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]
  69303. */
  69304. step: number;
  69305. /**
  69306. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69307. */
  69308. roughnessFactor: number;
  69309. private _geometryBufferRenderer;
  69310. private _enableSmoothReflections;
  69311. private _reflectionSamples;
  69312. private _smoothSteps;
  69313. /**
  69314. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69315. * @param name The name of the effect.
  69316. * @param scene The scene containing the objects to calculate reflections.
  69317. * @param options The required width/height ratio to downsize to before computing the render pass.
  69318. * @param camera The camera to apply the render pass to.
  69319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69320. * @param engine The engine which the post process will be applied. (default: current engine)
  69321. * @param reusable If the post process can be reused on the same frame. (default: false)
  69322. * @param textureType Type of textures used when performing the post process. (default: 0)
  69323. * @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)
  69324. */
  69325. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69326. /**
  69327. * Gets wether or not smoothing reflections is enabled.
  69328. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69329. */
  69330. get enableSmoothReflections(): boolean;
  69331. /**
  69332. * Sets wether or not smoothing reflections is enabled.
  69333. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69334. */
  69335. set enableSmoothReflections(enabled: boolean);
  69336. /**
  69337. * Gets the number of samples taken while computing reflections. More samples count is high,
  69338. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69339. */
  69340. get reflectionSamples(): number;
  69341. /**
  69342. * Sets the number of samples taken while computing reflections. More samples count is high,
  69343. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69344. */
  69345. set reflectionSamples(samples: number);
  69346. /**
  69347. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69348. * more the post-process will require GPU power and can generate a drop in FPS.
  69349. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69350. */
  69351. get smoothSteps(): number;
  69352. set smoothSteps(steps: number);
  69353. private _updateEffectDefines;
  69354. }
  69355. }
  69356. declare module "babylonjs/Shaders/standard.fragment" {
  69357. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69358. /** @hidden */
  69359. export var standardPixelShader: {
  69360. name: string;
  69361. shader: string;
  69362. };
  69363. }
  69364. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69365. import { Nullable } from "babylonjs/types";
  69366. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69367. import { Camera } from "babylonjs/Cameras/camera";
  69368. import { Texture } from "babylonjs/Materials/Textures/texture";
  69369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69370. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69371. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69372. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69373. import { IDisposable } from "babylonjs/scene";
  69374. import { SpotLight } from "babylonjs/Lights/spotLight";
  69375. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69376. import { Scene } from "babylonjs/scene";
  69377. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69378. import { Animation } from "babylonjs/Animations/animation";
  69379. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69380. import "babylonjs/Shaders/standard.fragment";
  69381. /**
  69382. * Standard rendering pipeline
  69383. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69384. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69385. */
  69386. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69387. /**
  69388. * Public members
  69389. */
  69390. /**
  69391. * Post-process which contains the original scene color before the pipeline applies all the effects
  69392. */
  69393. originalPostProcess: Nullable<PostProcess>;
  69394. /**
  69395. * Post-process used to down scale an image x4
  69396. */
  69397. downSampleX4PostProcess: Nullable<PostProcess>;
  69398. /**
  69399. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69400. */
  69401. brightPassPostProcess: Nullable<PostProcess>;
  69402. /**
  69403. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69404. */
  69405. blurHPostProcesses: PostProcess[];
  69406. /**
  69407. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69408. */
  69409. blurVPostProcesses: PostProcess[];
  69410. /**
  69411. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69412. */
  69413. textureAdderPostProcess: Nullable<PostProcess>;
  69414. /**
  69415. * Post-process used to create volumetric lighting effect
  69416. */
  69417. volumetricLightPostProcess: Nullable<PostProcess>;
  69418. /**
  69419. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69420. */
  69421. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69422. /**
  69423. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69424. */
  69425. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69426. /**
  69427. * Post-process used to merge the volumetric light effect and the real scene color
  69428. */
  69429. volumetricLightMergePostProces: Nullable<PostProcess>;
  69430. /**
  69431. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69432. */
  69433. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69434. /**
  69435. * Base post-process used to calculate the average luminance of the final image for HDR
  69436. */
  69437. luminancePostProcess: Nullable<PostProcess>;
  69438. /**
  69439. * Post-processes used to create down sample post-processes in order to get
  69440. * the average luminance of the final image for HDR
  69441. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69442. */
  69443. luminanceDownSamplePostProcesses: PostProcess[];
  69444. /**
  69445. * Post-process used to create a HDR effect (light adaptation)
  69446. */
  69447. hdrPostProcess: Nullable<PostProcess>;
  69448. /**
  69449. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69450. */
  69451. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69452. /**
  69453. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69454. */
  69455. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69456. /**
  69457. * Post-process used to merge the final HDR post-process and the real scene color
  69458. */
  69459. hdrFinalPostProcess: Nullable<PostProcess>;
  69460. /**
  69461. * Post-process used to create a lens flare effect
  69462. */
  69463. lensFlarePostProcess: Nullable<PostProcess>;
  69464. /**
  69465. * Post-process that merges the result of the lens flare post-process and the real scene color
  69466. */
  69467. lensFlareComposePostProcess: Nullable<PostProcess>;
  69468. /**
  69469. * Post-process used to create a motion blur effect
  69470. */
  69471. motionBlurPostProcess: Nullable<PostProcess>;
  69472. /**
  69473. * Post-process used to create a depth of field effect
  69474. */
  69475. depthOfFieldPostProcess: Nullable<PostProcess>;
  69476. /**
  69477. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69478. */
  69479. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69480. /**
  69481. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69482. */
  69483. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69484. /**
  69485. * Represents the brightness threshold in order to configure the illuminated surfaces
  69486. */
  69487. brightThreshold: number;
  69488. /**
  69489. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69490. */
  69491. blurWidth: number;
  69492. /**
  69493. * Sets if the blur for highlighted surfaces must be only horizontal
  69494. */
  69495. horizontalBlur: boolean;
  69496. /**
  69497. * Gets the overall exposure used by the pipeline
  69498. */
  69499. get exposure(): number;
  69500. /**
  69501. * Sets the overall exposure used by the pipeline
  69502. */
  69503. set exposure(value: number);
  69504. /**
  69505. * Texture used typically to simulate "dirty" on camera lens
  69506. */
  69507. lensTexture: Nullable<Texture>;
  69508. /**
  69509. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69510. */
  69511. volumetricLightCoefficient: number;
  69512. /**
  69513. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69514. */
  69515. volumetricLightPower: number;
  69516. /**
  69517. * Used the set the blur intensity to smooth the volumetric lights
  69518. */
  69519. volumetricLightBlurScale: number;
  69520. /**
  69521. * Light (spot or directional) used to generate the volumetric lights rays
  69522. * The source light must have a shadow generate so the pipeline can get its
  69523. * depth map
  69524. */
  69525. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69526. /**
  69527. * For eye adaptation, represents the minimum luminance the eye can see
  69528. */
  69529. hdrMinimumLuminance: number;
  69530. /**
  69531. * For eye adaptation, represents the decrease luminance speed
  69532. */
  69533. hdrDecreaseRate: number;
  69534. /**
  69535. * For eye adaptation, represents the increase luminance speed
  69536. */
  69537. hdrIncreaseRate: number;
  69538. /**
  69539. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69540. */
  69541. get hdrAutoExposure(): boolean;
  69542. /**
  69543. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69544. */
  69545. set hdrAutoExposure(value: boolean);
  69546. /**
  69547. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69548. */
  69549. lensColorTexture: Nullable<Texture>;
  69550. /**
  69551. * The overall strengh for the lens flare effect
  69552. */
  69553. lensFlareStrength: number;
  69554. /**
  69555. * Dispersion coefficient for lens flare ghosts
  69556. */
  69557. lensFlareGhostDispersal: number;
  69558. /**
  69559. * Main lens flare halo width
  69560. */
  69561. lensFlareHaloWidth: number;
  69562. /**
  69563. * Based on the lens distortion effect, defines how much the lens flare result
  69564. * is distorted
  69565. */
  69566. lensFlareDistortionStrength: number;
  69567. /**
  69568. * Configures the blur intensity used for for lens flare (halo)
  69569. */
  69570. lensFlareBlurWidth: number;
  69571. /**
  69572. * Lens star texture must be used to simulate rays on the flares and is available
  69573. * in the documentation
  69574. */
  69575. lensStarTexture: Nullable<Texture>;
  69576. /**
  69577. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69578. * flare effect by taking account of the dirt texture
  69579. */
  69580. lensFlareDirtTexture: Nullable<Texture>;
  69581. /**
  69582. * Represents the focal length for the depth of field effect
  69583. */
  69584. depthOfFieldDistance: number;
  69585. /**
  69586. * Represents the blur intensity for the blurred part of the depth of field effect
  69587. */
  69588. depthOfFieldBlurWidth: number;
  69589. /**
  69590. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69591. */
  69592. get motionStrength(): number;
  69593. /**
  69594. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69595. */
  69596. set motionStrength(strength: number);
  69597. /**
  69598. * Gets wether or not the motion blur post-process is object based or screen based.
  69599. */
  69600. get objectBasedMotionBlur(): boolean;
  69601. /**
  69602. * Sets wether or not the motion blur post-process should be object based or screen based
  69603. */
  69604. set objectBasedMotionBlur(value: boolean);
  69605. /**
  69606. * List of animations for the pipeline (IAnimatable implementation)
  69607. */
  69608. animations: Animation[];
  69609. /**
  69610. * Private members
  69611. */
  69612. private _scene;
  69613. private _currentDepthOfFieldSource;
  69614. private _basePostProcess;
  69615. private _fixedExposure;
  69616. private _currentExposure;
  69617. private _hdrAutoExposure;
  69618. private _hdrCurrentLuminance;
  69619. private _motionStrength;
  69620. private _isObjectBasedMotionBlur;
  69621. private _floatTextureType;
  69622. private _camerasToBeAttached;
  69623. private _ratio;
  69624. private _bloomEnabled;
  69625. private _depthOfFieldEnabled;
  69626. private _vlsEnabled;
  69627. private _lensFlareEnabled;
  69628. private _hdrEnabled;
  69629. private _motionBlurEnabled;
  69630. private _fxaaEnabled;
  69631. private _screenSpaceReflectionsEnabled;
  69632. private _motionBlurSamples;
  69633. private _volumetricLightStepsCount;
  69634. private _samples;
  69635. /**
  69636. * @ignore
  69637. * Specifies if the bloom pipeline is enabled
  69638. */
  69639. get BloomEnabled(): boolean;
  69640. set BloomEnabled(enabled: boolean);
  69641. /**
  69642. * @ignore
  69643. * Specifies if the depth of field pipeline is enabed
  69644. */
  69645. get DepthOfFieldEnabled(): boolean;
  69646. set DepthOfFieldEnabled(enabled: boolean);
  69647. /**
  69648. * @ignore
  69649. * Specifies if the lens flare pipeline is enabed
  69650. */
  69651. get LensFlareEnabled(): boolean;
  69652. set LensFlareEnabled(enabled: boolean);
  69653. /**
  69654. * @ignore
  69655. * Specifies if the HDR pipeline is enabled
  69656. */
  69657. get HDREnabled(): boolean;
  69658. set HDREnabled(enabled: boolean);
  69659. /**
  69660. * @ignore
  69661. * Specifies if the volumetric lights scattering effect is enabled
  69662. */
  69663. get VLSEnabled(): boolean;
  69664. set VLSEnabled(enabled: boolean);
  69665. /**
  69666. * @ignore
  69667. * Specifies if the motion blur effect is enabled
  69668. */
  69669. get MotionBlurEnabled(): boolean;
  69670. set MotionBlurEnabled(enabled: boolean);
  69671. /**
  69672. * Specifies if anti-aliasing is enabled
  69673. */
  69674. get fxaaEnabled(): boolean;
  69675. set fxaaEnabled(enabled: boolean);
  69676. /**
  69677. * Specifies if screen space reflections are enabled.
  69678. */
  69679. get screenSpaceReflectionsEnabled(): boolean;
  69680. set screenSpaceReflectionsEnabled(enabled: boolean);
  69681. /**
  69682. * Specifies the number of steps used to calculate the volumetric lights
  69683. * Typically in interval [50, 200]
  69684. */
  69685. get volumetricLightStepsCount(): number;
  69686. set volumetricLightStepsCount(count: number);
  69687. /**
  69688. * Specifies the number of samples used for the motion blur effect
  69689. * Typically in interval [16, 64]
  69690. */
  69691. get motionBlurSamples(): number;
  69692. set motionBlurSamples(samples: number);
  69693. /**
  69694. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69695. */
  69696. get samples(): number;
  69697. set samples(sampleCount: number);
  69698. /**
  69699. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69700. * @constructor
  69701. * @param name The rendering pipeline name
  69702. * @param scene The scene linked to this pipeline
  69703. * @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)
  69704. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69705. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69706. */
  69707. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69708. private _buildPipeline;
  69709. private _createDownSampleX4PostProcess;
  69710. private _createBrightPassPostProcess;
  69711. private _createBlurPostProcesses;
  69712. private _createTextureAdderPostProcess;
  69713. private _createVolumetricLightPostProcess;
  69714. private _createLuminancePostProcesses;
  69715. private _createHdrPostProcess;
  69716. private _createLensFlarePostProcess;
  69717. private _createDepthOfFieldPostProcess;
  69718. private _createMotionBlurPostProcess;
  69719. private _getDepthTexture;
  69720. private _disposePostProcesses;
  69721. /**
  69722. * Dispose of the pipeline and stop all post processes
  69723. */
  69724. dispose(): void;
  69725. /**
  69726. * Serialize the rendering pipeline (Used when exporting)
  69727. * @returns the serialized object
  69728. */
  69729. serialize(): any;
  69730. /**
  69731. * Parse the serialized pipeline
  69732. * @param source Source pipeline.
  69733. * @param scene The scene to load the pipeline to.
  69734. * @param rootUrl The URL of the serialized pipeline.
  69735. * @returns An instantiated pipeline from the serialized object.
  69736. */
  69737. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69738. /**
  69739. * Luminance steps
  69740. */
  69741. static LuminanceSteps: number;
  69742. }
  69743. }
  69744. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69745. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69746. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69747. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69748. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69749. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69750. }
  69751. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69752. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69753. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69754. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69755. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69756. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69757. }
  69758. declare module "babylonjs/Shaders/tonemap.fragment" {
  69759. /** @hidden */
  69760. export var tonemapPixelShader: {
  69761. name: string;
  69762. shader: string;
  69763. };
  69764. }
  69765. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69766. import { Camera } from "babylonjs/Cameras/camera";
  69767. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69768. import "babylonjs/Shaders/tonemap.fragment";
  69769. import { Engine } from "babylonjs/Engines/engine";
  69770. /** Defines operator used for tonemapping */
  69771. export enum TonemappingOperator {
  69772. /** Hable */
  69773. Hable = 0,
  69774. /** Reinhard */
  69775. Reinhard = 1,
  69776. /** HejiDawson */
  69777. HejiDawson = 2,
  69778. /** Photographic */
  69779. Photographic = 3
  69780. }
  69781. /**
  69782. * Defines a post process to apply tone mapping
  69783. */
  69784. export class TonemapPostProcess extends PostProcess {
  69785. private _operator;
  69786. /** Defines the required exposure adjustement */
  69787. exposureAdjustment: number;
  69788. /**
  69789. * Creates a new TonemapPostProcess
  69790. * @param name defines the name of the postprocess
  69791. * @param _operator defines the operator to use
  69792. * @param exposureAdjustment defines the required exposure adjustement
  69793. * @param camera defines the camera to use (can be null)
  69794. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69795. * @param engine defines the hosting engine (can be ignore if camera is set)
  69796. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69797. */
  69798. constructor(name: string, _operator: TonemappingOperator,
  69799. /** Defines the required exposure adjustement */
  69800. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69801. }
  69802. }
  69803. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69804. /** @hidden */
  69805. export var volumetricLightScatteringPixelShader: {
  69806. name: string;
  69807. shader: string;
  69808. };
  69809. }
  69810. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69811. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69813. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69814. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69815. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69816. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69817. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69818. /** @hidden */
  69819. export var volumetricLightScatteringPassVertexShader: {
  69820. name: string;
  69821. shader: string;
  69822. };
  69823. }
  69824. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69825. /** @hidden */
  69826. export var volumetricLightScatteringPassPixelShader: {
  69827. name: string;
  69828. shader: string;
  69829. };
  69830. }
  69831. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69832. import { Vector3 } from "babylonjs/Maths/math.vector";
  69833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69834. import { Mesh } from "babylonjs/Meshes/mesh";
  69835. import { Camera } from "babylonjs/Cameras/camera";
  69836. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69837. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69838. import { Scene } from "babylonjs/scene";
  69839. import "babylonjs/Meshes/Builders/planeBuilder";
  69840. import "babylonjs/Shaders/depth.vertex";
  69841. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69842. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69843. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69844. import { Engine } from "babylonjs/Engines/engine";
  69845. /**
  69846. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69847. */
  69848. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69849. private _volumetricLightScatteringPass;
  69850. private _volumetricLightScatteringRTT;
  69851. private _viewPort;
  69852. private _screenCoordinates;
  69853. private _cachedDefines;
  69854. /**
  69855. * If not undefined, the mesh position is computed from the attached node position
  69856. */
  69857. attachedNode: {
  69858. position: Vector3;
  69859. };
  69860. /**
  69861. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69862. */
  69863. customMeshPosition: Vector3;
  69864. /**
  69865. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69866. */
  69867. useCustomMeshPosition: boolean;
  69868. /**
  69869. * If the post-process should inverse the light scattering direction
  69870. */
  69871. invert: boolean;
  69872. /**
  69873. * The internal mesh used by the post-process
  69874. */
  69875. mesh: Mesh;
  69876. /**
  69877. * @hidden
  69878. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69879. */
  69880. get useDiffuseColor(): boolean;
  69881. set useDiffuseColor(useDiffuseColor: boolean);
  69882. /**
  69883. * Array containing the excluded meshes not rendered in the internal pass
  69884. */
  69885. excludedMeshes: AbstractMesh[];
  69886. /**
  69887. * Controls the overall intensity of the post-process
  69888. */
  69889. exposure: number;
  69890. /**
  69891. * Dissipates each sample's contribution in range [0, 1]
  69892. */
  69893. decay: number;
  69894. /**
  69895. * Controls the overall intensity of each sample
  69896. */
  69897. weight: number;
  69898. /**
  69899. * Controls the density of each sample
  69900. */
  69901. density: number;
  69902. /**
  69903. * @constructor
  69904. * @param name The post-process name
  69905. * @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)
  69906. * @param camera The camera that the post-process will be attached to
  69907. * @param mesh The mesh used to create the light scattering
  69908. * @param samples The post-process quality, default 100
  69909. * @param samplingModeThe post-process filtering mode
  69910. * @param engine The babylon engine
  69911. * @param reusable If the post-process is reusable
  69912. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69913. */
  69914. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69915. /**
  69916. * Returns the string "VolumetricLightScatteringPostProcess"
  69917. * @returns "VolumetricLightScatteringPostProcess"
  69918. */
  69919. getClassName(): string;
  69920. private _isReady;
  69921. /**
  69922. * Sets the new light position for light scattering effect
  69923. * @param position The new custom light position
  69924. */
  69925. setCustomMeshPosition(position: Vector3): void;
  69926. /**
  69927. * Returns the light position for light scattering effect
  69928. * @return Vector3 The custom light position
  69929. */
  69930. getCustomMeshPosition(): Vector3;
  69931. /**
  69932. * Disposes the internal assets and detaches the post-process from the camera
  69933. */
  69934. dispose(camera: Camera): void;
  69935. /**
  69936. * Returns the render target texture used by the post-process
  69937. * @return the render target texture used by the post-process
  69938. */
  69939. getPass(): RenderTargetTexture;
  69940. private _meshExcluded;
  69941. private _createPass;
  69942. private _updateMeshScreenCoordinates;
  69943. /**
  69944. * Creates a default mesh for the Volumeric Light Scattering post-process
  69945. * @param name The mesh name
  69946. * @param scene The scene where to create the mesh
  69947. * @return the default mesh
  69948. */
  69949. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69950. }
  69951. }
  69952. declare module "babylonjs/PostProcesses/index" {
  69953. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69954. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69955. export * from "babylonjs/PostProcesses/bloomEffect";
  69956. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69957. export * from "babylonjs/PostProcesses/blurPostProcess";
  69958. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69959. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69960. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69961. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69962. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69963. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69964. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69965. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69966. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69967. export * from "babylonjs/PostProcesses/filterPostProcess";
  69968. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69969. export * from "babylonjs/PostProcesses/grainPostProcess";
  69970. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69971. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69972. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69973. export * from "babylonjs/PostProcesses/passPostProcess";
  69974. export * from "babylonjs/PostProcesses/postProcess";
  69975. export * from "babylonjs/PostProcesses/postProcessManager";
  69976. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69977. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69978. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69979. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69980. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69981. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69982. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69983. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69984. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69985. }
  69986. declare module "babylonjs/Probes/index" {
  69987. export * from "babylonjs/Probes/reflectionProbe";
  69988. }
  69989. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69990. import { Scene } from "babylonjs/scene";
  69991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69992. import { SmartArray } from "babylonjs/Misc/smartArray";
  69993. import { ISceneComponent } from "babylonjs/sceneComponent";
  69994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69995. import "babylonjs/Meshes/Builders/boxBuilder";
  69996. import "babylonjs/Shaders/color.fragment";
  69997. import "babylonjs/Shaders/color.vertex";
  69998. import { Color3 } from "babylonjs/Maths/math.color";
  69999. module "babylonjs/scene" {
  70000. interface Scene {
  70001. /** @hidden (Backing field) */
  70002. _boundingBoxRenderer: BoundingBoxRenderer;
  70003. /** @hidden (Backing field) */
  70004. _forceShowBoundingBoxes: boolean;
  70005. /**
  70006. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70007. */
  70008. forceShowBoundingBoxes: boolean;
  70009. /**
  70010. * Gets the bounding box renderer associated with the scene
  70011. * @returns a BoundingBoxRenderer
  70012. */
  70013. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70014. }
  70015. }
  70016. module "babylonjs/Meshes/abstractMesh" {
  70017. interface AbstractMesh {
  70018. /** @hidden (Backing field) */
  70019. _showBoundingBox: boolean;
  70020. /**
  70021. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70022. */
  70023. showBoundingBox: boolean;
  70024. }
  70025. }
  70026. /**
  70027. * Component responsible of rendering the bounding box of the meshes in a scene.
  70028. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70029. */
  70030. export class BoundingBoxRenderer implements ISceneComponent {
  70031. /**
  70032. * The component name helpfull to identify the component in the list of scene components.
  70033. */
  70034. readonly name: string;
  70035. /**
  70036. * The scene the component belongs to.
  70037. */
  70038. scene: Scene;
  70039. /**
  70040. * Color of the bounding box lines placed in front of an object
  70041. */
  70042. frontColor: Color3;
  70043. /**
  70044. * Color of the bounding box lines placed behind an object
  70045. */
  70046. backColor: Color3;
  70047. /**
  70048. * Defines if the renderer should show the back lines or not
  70049. */
  70050. showBackLines: boolean;
  70051. /**
  70052. * @hidden
  70053. */
  70054. renderList: SmartArray<BoundingBox>;
  70055. private _colorShader;
  70056. private _vertexBuffers;
  70057. private _indexBuffer;
  70058. private _fillIndexBuffer;
  70059. private _fillIndexData;
  70060. /**
  70061. * Instantiates a new bounding box renderer in a scene.
  70062. * @param scene the scene the renderer renders in
  70063. */
  70064. constructor(scene: Scene);
  70065. /**
  70066. * Registers the component in a given scene
  70067. */
  70068. register(): void;
  70069. private _evaluateSubMesh;
  70070. private _activeMesh;
  70071. private _prepareRessources;
  70072. private _createIndexBuffer;
  70073. /**
  70074. * Rebuilds the elements related to this component in case of
  70075. * context lost for instance.
  70076. */
  70077. rebuild(): void;
  70078. /**
  70079. * @hidden
  70080. */
  70081. reset(): void;
  70082. /**
  70083. * Render the bounding boxes of a specific rendering group
  70084. * @param renderingGroupId defines the rendering group to render
  70085. */
  70086. render(renderingGroupId: number): void;
  70087. /**
  70088. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70089. * @param mesh Define the mesh to render the occlusion bounding box for
  70090. */
  70091. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70092. /**
  70093. * Dispose and release the resources attached to this renderer.
  70094. */
  70095. dispose(): void;
  70096. }
  70097. }
  70098. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70099. import { Nullable } from "babylonjs/types";
  70100. import { Scene } from "babylonjs/scene";
  70101. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70102. import { Camera } from "babylonjs/Cameras/camera";
  70103. import { ISceneComponent } from "babylonjs/sceneComponent";
  70104. module "babylonjs/scene" {
  70105. interface Scene {
  70106. /** @hidden (Backing field) */
  70107. _depthRenderer: {
  70108. [id: string]: DepthRenderer;
  70109. };
  70110. /**
  70111. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70112. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70113. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70114. * @returns the created depth renderer
  70115. */
  70116. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70117. /**
  70118. * Disables a depth renderer for a given camera
  70119. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70120. */
  70121. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70122. }
  70123. }
  70124. /**
  70125. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70126. * in several rendering techniques.
  70127. */
  70128. export class DepthRendererSceneComponent implements ISceneComponent {
  70129. /**
  70130. * The component name helpfull to identify the component in the list of scene components.
  70131. */
  70132. readonly name: string;
  70133. /**
  70134. * The scene the component belongs to.
  70135. */
  70136. scene: Scene;
  70137. /**
  70138. * Creates a new instance of the component for the given scene
  70139. * @param scene Defines the scene to register the component in
  70140. */
  70141. constructor(scene: Scene);
  70142. /**
  70143. * Registers the component in a given scene
  70144. */
  70145. register(): void;
  70146. /**
  70147. * Rebuilds the elements related to this component in case of
  70148. * context lost for instance.
  70149. */
  70150. rebuild(): void;
  70151. /**
  70152. * Disposes the component and the associated ressources
  70153. */
  70154. dispose(): void;
  70155. private _gatherRenderTargets;
  70156. private _gatherActiveCameraRenderTargets;
  70157. }
  70158. }
  70159. declare module "babylonjs/Shaders/outline.fragment" {
  70160. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70161. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70162. /** @hidden */
  70163. export var outlinePixelShader: {
  70164. name: string;
  70165. shader: string;
  70166. };
  70167. }
  70168. declare module "babylonjs/Shaders/outline.vertex" {
  70169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70172. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70173. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70174. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70175. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70176. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70177. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70178. /** @hidden */
  70179. export var outlineVertexShader: {
  70180. name: string;
  70181. shader: string;
  70182. };
  70183. }
  70184. declare module "babylonjs/Rendering/outlineRenderer" {
  70185. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70186. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70187. import { Scene } from "babylonjs/scene";
  70188. import { ISceneComponent } from "babylonjs/sceneComponent";
  70189. import "babylonjs/Shaders/outline.fragment";
  70190. import "babylonjs/Shaders/outline.vertex";
  70191. module "babylonjs/scene" {
  70192. interface Scene {
  70193. /** @hidden */
  70194. _outlineRenderer: OutlineRenderer;
  70195. /**
  70196. * Gets the outline renderer associated with the scene
  70197. * @returns a OutlineRenderer
  70198. */
  70199. getOutlineRenderer(): OutlineRenderer;
  70200. }
  70201. }
  70202. module "babylonjs/Meshes/abstractMesh" {
  70203. interface AbstractMesh {
  70204. /** @hidden (Backing field) */
  70205. _renderOutline: boolean;
  70206. /**
  70207. * Gets or sets a boolean indicating if the outline must be rendered as well
  70208. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70209. */
  70210. renderOutline: boolean;
  70211. /** @hidden (Backing field) */
  70212. _renderOverlay: boolean;
  70213. /**
  70214. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70215. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70216. */
  70217. renderOverlay: boolean;
  70218. }
  70219. }
  70220. /**
  70221. * This class is responsible to draw bothe outline/overlay of meshes.
  70222. * It should not be used directly but through the available method on mesh.
  70223. */
  70224. export class OutlineRenderer implements ISceneComponent {
  70225. /**
  70226. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70227. */
  70228. private static _StencilReference;
  70229. /**
  70230. * The name of the component. Each component must have a unique name.
  70231. */
  70232. name: string;
  70233. /**
  70234. * The scene the component belongs to.
  70235. */
  70236. scene: Scene;
  70237. /**
  70238. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70239. */
  70240. zOffset: number;
  70241. private _engine;
  70242. private _effect;
  70243. private _cachedDefines;
  70244. private _savedDepthWrite;
  70245. /**
  70246. * Instantiates a new outline renderer. (There could be only one per scene).
  70247. * @param scene Defines the scene it belongs to
  70248. */
  70249. constructor(scene: Scene);
  70250. /**
  70251. * Register the component to one instance of a scene.
  70252. */
  70253. register(): void;
  70254. /**
  70255. * Rebuilds the elements related to this component in case of
  70256. * context lost for instance.
  70257. */
  70258. rebuild(): void;
  70259. /**
  70260. * Disposes the component and the associated ressources.
  70261. */
  70262. dispose(): void;
  70263. /**
  70264. * Renders the outline in the canvas.
  70265. * @param subMesh Defines the sumesh to render
  70266. * @param batch Defines the batch of meshes in case of instances
  70267. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70268. */
  70269. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70270. /**
  70271. * Returns whether or not the outline renderer is ready for a given submesh.
  70272. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70273. * @param subMesh Defines the submesh to check readyness for
  70274. * @param useInstances Defines wheter wee are trying to render instances or not
  70275. * @returns true if ready otherwise false
  70276. */
  70277. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70278. private _beforeRenderingMesh;
  70279. private _afterRenderingMesh;
  70280. }
  70281. }
  70282. declare module "babylonjs/Rendering/index" {
  70283. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70284. export * from "babylonjs/Rendering/depthRenderer";
  70285. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70286. export * from "babylonjs/Rendering/edgesRenderer";
  70287. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70288. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70289. export * from "babylonjs/Rendering/outlineRenderer";
  70290. export * from "babylonjs/Rendering/renderingGroup";
  70291. export * from "babylonjs/Rendering/renderingManager";
  70292. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70293. }
  70294. declare module "babylonjs/Sprites/ISprites" {
  70295. /**
  70296. * Defines the basic options interface of a Sprite Frame Source Size.
  70297. */
  70298. export interface ISpriteJSONSpriteSourceSize {
  70299. /**
  70300. * number of the original width of the Frame
  70301. */
  70302. w: number;
  70303. /**
  70304. * number of the original height of the Frame
  70305. */
  70306. h: number;
  70307. }
  70308. /**
  70309. * Defines the basic options interface of a Sprite Frame Data.
  70310. */
  70311. export interface ISpriteJSONSpriteFrameData {
  70312. /**
  70313. * number of the x offset of the Frame
  70314. */
  70315. x: number;
  70316. /**
  70317. * number of the y offset of the Frame
  70318. */
  70319. y: number;
  70320. /**
  70321. * number of the width of the Frame
  70322. */
  70323. w: number;
  70324. /**
  70325. * number of the height of the Frame
  70326. */
  70327. h: number;
  70328. }
  70329. /**
  70330. * Defines the basic options interface of a JSON Sprite.
  70331. */
  70332. export interface ISpriteJSONSprite {
  70333. /**
  70334. * string name of the Frame
  70335. */
  70336. filename: string;
  70337. /**
  70338. * ISpriteJSONSpriteFrame basic object of the frame data
  70339. */
  70340. frame: ISpriteJSONSpriteFrameData;
  70341. /**
  70342. * boolean to flag is the frame was rotated.
  70343. */
  70344. rotated: boolean;
  70345. /**
  70346. * boolean to flag is the frame was trimmed.
  70347. */
  70348. trimmed: boolean;
  70349. /**
  70350. * ISpriteJSONSpriteFrame basic object of the source data
  70351. */
  70352. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70353. /**
  70354. * ISpriteJSONSpriteFrame basic object of the source data
  70355. */
  70356. sourceSize: ISpriteJSONSpriteSourceSize;
  70357. }
  70358. /**
  70359. * Defines the basic options interface of a JSON atlas.
  70360. */
  70361. export interface ISpriteJSONAtlas {
  70362. /**
  70363. * Array of objects that contain the frame data.
  70364. */
  70365. frames: Array<ISpriteJSONSprite>;
  70366. /**
  70367. * object basic object containing the sprite meta data.
  70368. */
  70369. meta?: object;
  70370. }
  70371. }
  70372. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70373. /** @hidden */
  70374. export var spriteMapPixelShader: {
  70375. name: string;
  70376. shader: string;
  70377. };
  70378. }
  70379. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70380. /** @hidden */
  70381. export var spriteMapVertexShader: {
  70382. name: string;
  70383. shader: string;
  70384. };
  70385. }
  70386. declare module "babylonjs/Sprites/spriteMap" {
  70387. import { IDisposable, Scene } from "babylonjs/scene";
  70388. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70389. import { Texture } from "babylonjs/Materials/Textures/texture";
  70390. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70391. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70392. import "babylonjs/Meshes/Builders/planeBuilder";
  70393. import "babylonjs/Shaders/spriteMap.fragment";
  70394. import "babylonjs/Shaders/spriteMap.vertex";
  70395. /**
  70396. * Defines the basic options interface of a SpriteMap
  70397. */
  70398. export interface ISpriteMapOptions {
  70399. /**
  70400. * Vector2 of the number of cells in the grid.
  70401. */
  70402. stageSize?: Vector2;
  70403. /**
  70404. * Vector2 of the size of the output plane in World Units.
  70405. */
  70406. outputSize?: Vector2;
  70407. /**
  70408. * Vector3 of the position of the output plane in World Units.
  70409. */
  70410. outputPosition?: Vector3;
  70411. /**
  70412. * Vector3 of the rotation of the output plane.
  70413. */
  70414. outputRotation?: Vector3;
  70415. /**
  70416. * number of layers that the system will reserve in resources.
  70417. */
  70418. layerCount?: number;
  70419. /**
  70420. * number of max animation frames a single cell will reserve in resources.
  70421. */
  70422. maxAnimationFrames?: number;
  70423. /**
  70424. * number cell index of the base tile when the system compiles.
  70425. */
  70426. baseTile?: number;
  70427. /**
  70428. * boolean flip the sprite after its been repositioned by the framing data.
  70429. */
  70430. flipU?: boolean;
  70431. /**
  70432. * Vector3 scalar of the global RGB values of the SpriteMap.
  70433. */
  70434. colorMultiply?: Vector3;
  70435. }
  70436. /**
  70437. * Defines the IDisposable interface in order to be cleanable from resources.
  70438. */
  70439. export interface ISpriteMap extends IDisposable {
  70440. /**
  70441. * String name of the SpriteMap.
  70442. */
  70443. name: string;
  70444. /**
  70445. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70446. */
  70447. atlasJSON: ISpriteJSONAtlas;
  70448. /**
  70449. * Texture of the SpriteMap.
  70450. */
  70451. spriteSheet: Texture;
  70452. /**
  70453. * The parameters to initialize the SpriteMap with.
  70454. */
  70455. options: ISpriteMapOptions;
  70456. }
  70457. /**
  70458. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70459. */
  70460. export class SpriteMap implements ISpriteMap {
  70461. /** The Name of the spriteMap */
  70462. name: string;
  70463. /** The JSON file with the frame and meta data */
  70464. atlasJSON: ISpriteJSONAtlas;
  70465. /** The systems Sprite Sheet Texture */
  70466. spriteSheet: Texture;
  70467. /** Arguments passed with the Constructor */
  70468. options: ISpriteMapOptions;
  70469. /** Public Sprite Storage array, parsed from atlasJSON */
  70470. sprites: Array<ISpriteJSONSprite>;
  70471. /** Returns the Number of Sprites in the System */
  70472. get spriteCount(): number;
  70473. /** Returns the Position of Output Plane*/
  70474. get position(): Vector3;
  70475. /** Returns the Position of Output Plane*/
  70476. set position(v: Vector3);
  70477. /** Returns the Rotation of Output Plane*/
  70478. get rotation(): Vector3;
  70479. /** Returns the Rotation of Output Plane*/
  70480. set rotation(v: Vector3);
  70481. /** Sets the AnimationMap*/
  70482. get animationMap(): RawTexture;
  70483. /** Sets the AnimationMap*/
  70484. set animationMap(v: RawTexture);
  70485. /** Scene that the SpriteMap was created in */
  70486. private _scene;
  70487. /** Texture Buffer of Float32 that holds tile frame data*/
  70488. private _frameMap;
  70489. /** Texture Buffers of Float32 that holds tileMap data*/
  70490. private _tileMaps;
  70491. /** Texture Buffer of Float32 that holds Animation Data*/
  70492. private _animationMap;
  70493. /** Custom ShaderMaterial Central to the System*/
  70494. private _material;
  70495. /** Custom ShaderMaterial Central to the System*/
  70496. private _output;
  70497. /** Systems Time Ticker*/
  70498. private _time;
  70499. /**
  70500. * Creates a new SpriteMap
  70501. * @param name defines the SpriteMaps Name
  70502. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70503. * @param spriteSheet is the Texture that the Sprites are on.
  70504. * @param options a basic deployment configuration
  70505. * @param scene The Scene that the map is deployed on
  70506. */
  70507. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70508. /**
  70509. * Returns tileID location
  70510. * @returns Vector2 the cell position ID
  70511. */
  70512. getTileID(): Vector2;
  70513. /**
  70514. * Gets the UV location of the mouse over the SpriteMap.
  70515. * @returns Vector2 the UV position of the mouse interaction
  70516. */
  70517. getMousePosition(): Vector2;
  70518. /**
  70519. * Creates the "frame" texture Buffer
  70520. * -------------------------------------
  70521. * Structure of frames
  70522. * "filename": "Falling-Water-2.png",
  70523. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70524. * "rotated": true,
  70525. * "trimmed": true,
  70526. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70527. * "sourceSize": {"w":32,"h":32}
  70528. * @returns RawTexture of the frameMap
  70529. */
  70530. private _createFrameBuffer;
  70531. /**
  70532. * Creates the tileMap texture Buffer
  70533. * @param buffer normally and array of numbers, or a false to generate from scratch
  70534. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70535. * @returns RawTexture of the tileMap
  70536. */
  70537. private _createTileBuffer;
  70538. /**
  70539. * Modifies the data of the tileMaps
  70540. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70541. * @param pos is the iVector2 Coordinates of the Tile
  70542. * @param tile The SpriteIndex of the new Tile
  70543. */
  70544. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70545. /**
  70546. * Creates the animationMap texture Buffer
  70547. * @param buffer normally and array of numbers, or a false to generate from scratch
  70548. * @returns RawTexture of the animationMap
  70549. */
  70550. private _createTileAnimationBuffer;
  70551. /**
  70552. * Modifies the data of the animationMap
  70553. * @param cellID is the Index of the Sprite
  70554. * @param _frame is the target Animation frame
  70555. * @param toCell is the Target Index of the next frame of the animation
  70556. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70557. * @param speed is a global scalar of the time variable on the map.
  70558. */
  70559. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70560. /**
  70561. * Exports the .tilemaps file
  70562. */
  70563. saveTileMaps(): void;
  70564. /**
  70565. * Imports the .tilemaps file
  70566. * @param url of the .tilemaps file
  70567. */
  70568. loadTileMaps(url: string): void;
  70569. /**
  70570. * Release associated resources
  70571. */
  70572. dispose(): void;
  70573. }
  70574. }
  70575. declare module "babylonjs/Sprites/spritePackedManager" {
  70576. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70577. import { Scene } from "babylonjs/scene";
  70578. /**
  70579. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70580. * @see http://doc.babylonjs.com/babylon101/sprites
  70581. */
  70582. export class SpritePackedManager extends SpriteManager {
  70583. /** defines the packed manager's name */
  70584. name: string;
  70585. /**
  70586. * Creates a new sprite manager from a packed sprite sheet
  70587. * @param name defines the manager's name
  70588. * @param imgUrl defines the sprite sheet url
  70589. * @param capacity defines the maximum allowed number of sprites
  70590. * @param scene defines the hosting scene
  70591. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70592. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70593. * @param samplingMode defines the smapling mode to use with spritesheet
  70594. * @param fromPacked set to true; do not alter
  70595. */
  70596. constructor(
  70597. /** defines the packed manager's name */
  70598. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70599. }
  70600. }
  70601. declare module "babylonjs/Sprites/index" {
  70602. export * from "babylonjs/Sprites/sprite";
  70603. export * from "babylonjs/Sprites/ISprites";
  70604. export * from "babylonjs/Sprites/spriteManager";
  70605. export * from "babylonjs/Sprites/spriteMap";
  70606. export * from "babylonjs/Sprites/spritePackedManager";
  70607. export * from "babylonjs/Sprites/spriteSceneComponent";
  70608. }
  70609. declare module "babylonjs/States/index" {
  70610. export * from "babylonjs/States/alphaCullingState";
  70611. export * from "babylonjs/States/depthCullingState";
  70612. export * from "babylonjs/States/stencilState";
  70613. }
  70614. declare module "babylonjs/Misc/assetsManager" {
  70615. import { Scene } from "babylonjs/scene";
  70616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70617. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70618. import { Skeleton } from "babylonjs/Bones/skeleton";
  70619. import { Observable } from "babylonjs/Misc/observable";
  70620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70621. import { Texture } from "babylonjs/Materials/Textures/texture";
  70622. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70623. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70624. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70625. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70626. /**
  70627. * Defines the list of states available for a task inside a AssetsManager
  70628. */
  70629. export enum AssetTaskState {
  70630. /**
  70631. * Initialization
  70632. */
  70633. INIT = 0,
  70634. /**
  70635. * Running
  70636. */
  70637. RUNNING = 1,
  70638. /**
  70639. * Done
  70640. */
  70641. DONE = 2,
  70642. /**
  70643. * Error
  70644. */
  70645. ERROR = 3
  70646. }
  70647. /**
  70648. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70649. */
  70650. export abstract class AbstractAssetTask {
  70651. /**
  70652. * Task name
  70653. */ name: string;
  70654. /**
  70655. * Callback called when the task is successful
  70656. */
  70657. onSuccess: (task: any) => void;
  70658. /**
  70659. * Callback called when the task is not successful
  70660. */
  70661. onError: (task: any, message?: string, exception?: any) => void;
  70662. /**
  70663. * Creates a new AssetsManager
  70664. * @param name defines the name of the task
  70665. */
  70666. constructor(
  70667. /**
  70668. * Task name
  70669. */ name: string);
  70670. private _isCompleted;
  70671. private _taskState;
  70672. private _errorObject;
  70673. /**
  70674. * Get if the task is completed
  70675. */
  70676. get isCompleted(): boolean;
  70677. /**
  70678. * Gets the current state of the task
  70679. */
  70680. get taskState(): AssetTaskState;
  70681. /**
  70682. * Gets the current error object (if task is in error)
  70683. */
  70684. get errorObject(): {
  70685. message?: string;
  70686. exception?: any;
  70687. };
  70688. /**
  70689. * Internal only
  70690. * @hidden
  70691. */
  70692. _setErrorObject(message?: string, exception?: any): void;
  70693. /**
  70694. * Execute the current task
  70695. * @param scene defines the scene where you want your assets to be loaded
  70696. * @param onSuccess is a callback called when the task is successfully executed
  70697. * @param onError is a callback called if an error occurs
  70698. */
  70699. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70700. /**
  70701. * Execute the current task
  70702. * @param scene defines the scene where you want your assets to be loaded
  70703. * @param onSuccess is a callback called when the task is successfully executed
  70704. * @param onError is a callback called if an error occurs
  70705. */
  70706. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70707. /**
  70708. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70709. * This can be used with failed tasks that have the reason for failure fixed.
  70710. */
  70711. reset(): void;
  70712. private onErrorCallback;
  70713. private onDoneCallback;
  70714. }
  70715. /**
  70716. * Define the interface used by progress events raised during assets loading
  70717. */
  70718. export interface IAssetsProgressEvent {
  70719. /**
  70720. * Defines the number of remaining tasks to process
  70721. */
  70722. remainingCount: number;
  70723. /**
  70724. * Defines the total number of tasks
  70725. */
  70726. totalCount: number;
  70727. /**
  70728. * Defines the task that was just processed
  70729. */
  70730. task: AbstractAssetTask;
  70731. }
  70732. /**
  70733. * Class used to share progress information about assets loading
  70734. */
  70735. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70736. /**
  70737. * Defines the number of remaining tasks to process
  70738. */
  70739. remainingCount: number;
  70740. /**
  70741. * Defines the total number of tasks
  70742. */
  70743. totalCount: number;
  70744. /**
  70745. * Defines the task that was just processed
  70746. */
  70747. task: AbstractAssetTask;
  70748. /**
  70749. * Creates a AssetsProgressEvent
  70750. * @param remainingCount defines the number of remaining tasks to process
  70751. * @param totalCount defines the total number of tasks
  70752. * @param task defines the task that was just processed
  70753. */
  70754. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70755. }
  70756. /**
  70757. * Define a task used by AssetsManager to load meshes
  70758. */
  70759. export class MeshAssetTask extends AbstractAssetTask {
  70760. /**
  70761. * Defines the name of the task
  70762. */
  70763. name: string;
  70764. /**
  70765. * Defines the list of mesh's names you want to load
  70766. */
  70767. meshesNames: any;
  70768. /**
  70769. * Defines the root url to use as a base to load your meshes and associated resources
  70770. */
  70771. rootUrl: string;
  70772. /**
  70773. * Defines the filename of the scene to load from
  70774. */
  70775. sceneFilename: string;
  70776. /**
  70777. * Gets the list of loaded meshes
  70778. */
  70779. loadedMeshes: Array<AbstractMesh>;
  70780. /**
  70781. * Gets the list of loaded particle systems
  70782. */
  70783. loadedParticleSystems: Array<IParticleSystem>;
  70784. /**
  70785. * Gets the list of loaded skeletons
  70786. */
  70787. loadedSkeletons: Array<Skeleton>;
  70788. /**
  70789. * Gets the list of loaded animation groups
  70790. */
  70791. loadedAnimationGroups: Array<AnimationGroup>;
  70792. /**
  70793. * Callback called when the task is successful
  70794. */
  70795. onSuccess: (task: MeshAssetTask) => void;
  70796. /**
  70797. * Callback called when the task is successful
  70798. */
  70799. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70800. /**
  70801. * Creates a new MeshAssetTask
  70802. * @param name defines the name of the task
  70803. * @param meshesNames defines the list of mesh's names you want to load
  70804. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70805. * @param sceneFilename defines the filename of the scene to load from
  70806. */
  70807. constructor(
  70808. /**
  70809. * Defines the name of the task
  70810. */
  70811. name: string,
  70812. /**
  70813. * Defines the list of mesh's names you want to load
  70814. */
  70815. meshesNames: any,
  70816. /**
  70817. * Defines the root url to use as a base to load your meshes and associated resources
  70818. */
  70819. rootUrl: string,
  70820. /**
  70821. * Defines the filename of the scene to load from
  70822. */
  70823. sceneFilename: string);
  70824. /**
  70825. * Execute the current task
  70826. * @param scene defines the scene where you want your assets to be loaded
  70827. * @param onSuccess is a callback called when the task is successfully executed
  70828. * @param onError is a callback called if an error occurs
  70829. */
  70830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70831. }
  70832. /**
  70833. * Define a task used by AssetsManager to load text content
  70834. */
  70835. export class TextFileAssetTask extends AbstractAssetTask {
  70836. /**
  70837. * Defines the name of the task
  70838. */
  70839. name: string;
  70840. /**
  70841. * Defines the location of the file to load
  70842. */
  70843. url: string;
  70844. /**
  70845. * Gets the loaded text string
  70846. */
  70847. text: string;
  70848. /**
  70849. * Callback called when the task is successful
  70850. */
  70851. onSuccess: (task: TextFileAssetTask) => void;
  70852. /**
  70853. * Callback called when the task is successful
  70854. */
  70855. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70856. /**
  70857. * Creates a new TextFileAssetTask object
  70858. * @param name defines the name of the task
  70859. * @param url defines the location of the file to load
  70860. */
  70861. constructor(
  70862. /**
  70863. * Defines the name of the task
  70864. */
  70865. name: string,
  70866. /**
  70867. * Defines the location of the file to load
  70868. */
  70869. url: string);
  70870. /**
  70871. * Execute the current task
  70872. * @param scene defines the scene where you want your assets to be loaded
  70873. * @param onSuccess is a callback called when the task is successfully executed
  70874. * @param onError is a callback called if an error occurs
  70875. */
  70876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70877. }
  70878. /**
  70879. * Define a task used by AssetsManager to load binary data
  70880. */
  70881. export class BinaryFileAssetTask extends AbstractAssetTask {
  70882. /**
  70883. * Defines the name of the task
  70884. */
  70885. name: string;
  70886. /**
  70887. * Defines the location of the file to load
  70888. */
  70889. url: string;
  70890. /**
  70891. * Gets the lodaded data (as an array buffer)
  70892. */
  70893. data: ArrayBuffer;
  70894. /**
  70895. * Callback called when the task is successful
  70896. */
  70897. onSuccess: (task: BinaryFileAssetTask) => void;
  70898. /**
  70899. * Callback called when the task is successful
  70900. */
  70901. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70902. /**
  70903. * Creates a new BinaryFileAssetTask object
  70904. * @param name defines the name of the new task
  70905. * @param url defines the location of the file to load
  70906. */
  70907. constructor(
  70908. /**
  70909. * Defines the name of the task
  70910. */
  70911. name: string,
  70912. /**
  70913. * Defines the location of the file to load
  70914. */
  70915. url: string);
  70916. /**
  70917. * Execute the current task
  70918. * @param scene defines the scene where you want your assets to be loaded
  70919. * @param onSuccess is a callback called when the task is successfully executed
  70920. * @param onError is a callback called if an error occurs
  70921. */
  70922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70923. }
  70924. /**
  70925. * Define a task used by AssetsManager to load images
  70926. */
  70927. export class ImageAssetTask extends AbstractAssetTask {
  70928. /**
  70929. * Defines the name of the task
  70930. */
  70931. name: string;
  70932. /**
  70933. * Defines the location of the image to load
  70934. */
  70935. url: string;
  70936. /**
  70937. * Gets the loaded images
  70938. */
  70939. image: HTMLImageElement;
  70940. /**
  70941. * Callback called when the task is successful
  70942. */
  70943. onSuccess: (task: ImageAssetTask) => void;
  70944. /**
  70945. * Callback called when the task is successful
  70946. */
  70947. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70948. /**
  70949. * Creates a new ImageAssetTask
  70950. * @param name defines the name of the task
  70951. * @param url defines the location of the image to load
  70952. */
  70953. constructor(
  70954. /**
  70955. * Defines the name of the task
  70956. */
  70957. name: string,
  70958. /**
  70959. * Defines the location of the image to load
  70960. */
  70961. url: string);
  70962. /**
  70963. * Execute the current task
  70964. * @param scene defines the scene where you want your assets to be loaded
  70965. * @param onSuccess is a callback called when the task is successfully executed
  70966. * @param onError is a callback called if an error occurs
  70967. */
  70968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70969. }
  70970. /**
  70971. * Defines the interface used by texture loading tasks
  70972. */
  70973. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70974. /**
  70975. * Gets the loaded texture
  70976. */
  70977. texture: TEX;
  70978. }
  70979. /**
  70980. * Define a task used by AssetsManager to load 2D textures
  70981. */
  70982. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70983. /**
  70984. * Defines the name of the task
  70985. */
  70986. name: string;
  70987. /**
  70988. * Defines the location of the file to load
  70989. */
  70990. url: string;
  70991. /**
  70992. * Defines if mipmap should not be generated (default is false)
  70993. */
  70994. noMipmap?: boolean | undefined;
  70995. /**
  70996. * Defines if texture must be inverted on Y axis (default is false)
  70997. */
  70998. invertY?: boolean | undefined;
  70999. /**
  71000. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71001. */
  71002. samplingMode: number;
  71003. /**
  71004. * Gets the loaded texture
  71005. */
  71006. texture: Texture;
  71007. /**
  71008. * Callback called when the task is successful
  71009. */
  71010. onSuccess: (task: TextureAssetTask) => void;
  71011. /**
  71012. * Callback called when the task is successful
  71013. */
  71014. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71015. /**
  71016. * Creates a new TextureAssetTask object
  71017. * @param name defines the name of the task
  71018. * @param url defines the location of the file to load
  71019. * @param noMipmap defines if mipmap should not be generated (default is false)
  71020. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71021. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71022. */
  71023. constructor(
  71024. /**
  71025. * Defines the name of the task
  71026. */
  71027. name: string,
  71028. /**
  71029. * Defines the location of the file to load
  71030. */
  71031. url: string,
  71032. /**
  71033. * Defines if mipmap should not be generated (default is false)
  71034. */
  71035. noMipmap?: boolean | undefined,
  71036. /**
  71037. * Defines if texture must be inverted on Y axis (default is false)
  71038. */
  71039. invertY?: boolean | undefined,
  71040. /**
  71041. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71042. */
  71043. samplingMode?: number);
  71044. /**
  71045. * Execute the current task
  71046. * @param scene defines the scene where you want your assets to be loaded
  71047. * @param onSuccess is a callback called when the task is successfully executed
  71048. * @param onError is a callback called if an error occurs
  71049. */
  71050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71051. }
  71052. /**
  71053. * Define a task used by AssetsManager to load cube textures
  71054. */
  71055. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71056. /**
  71057. * Defines the name of the task
  71058. */
  71059. name: string;
  71060. /**
  71061. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71062. */
  71063. url: string;
  71064. /**
  71065. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71066. */
  71067. extensions?: string[] | undefined;
  71068. /**
  71069. * Defines if mipmaps should not be generated (default is false)
  71070. */
  71071. noMipmap?: boolean | undefined;
  71072. /**
  71073. * Defines the explicit list of files (undefined by default)
  71074. */
  71075. files?: string[] | undefined;
  71076. /**
  71077. * Gets the loaded texture
  71078. */
  71079. texture: CubeTexture;
  71080. /**
  71081. * Callback called when the task is successful
  71082. */
  71083. onSuccess: (task: CubeTextureAssetTask) => void;
  71084. /**
  71085. * Callback called when the task is successful
  71086. */
  71087. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71088. /**
  71089. * Creates a new CubeTextureAssetTask
  71090. * @param name defines the name of the task
  71091. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71092. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71093. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71094. * @param files defines the explicit list of files (undefined by default)
  71095. */
  71096. constructor(
  71097. /**
  71098. * Defines the name of the task
  71099. */
  71100. name: string,
  71101. /**
  71102. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71103. */
  71104. url: string,
  71105. /**
  71106. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71107. */
  71108. extensions?: string[] | undefined,
  71109. /**
  71110. * Defines if mipmaps should not be generated (default is false)
  71111. */
  71112. noMipmap?: boolean | undefined,
  71113. /**
  71114. * Defines the explicit list of files (undefined by default)
  71115. */
  71116. files?: string[] | undefined);
  71117. /**
  71118. * Execute the current task
  71119. * @param scene defines the scene where you want your assets to be loaded
  71120. * @param onSuccess is a callback called when the task is successfully executed
  71121. * @param onError is a callback called if an error occurs
  71122. */
  71123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71124. }
  71125. /**
  71126. * Define a task used by AssetsManager to load HDR cube textures
  71127. */
  71128. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71129. /**
  71130. * Defines the name of the task
  71131. */
  71132. name: string;
  71133. /**
  71134. * Defines the location of the file to load
  71135. */
  71136. url: string;
  71137. /**
  71138. * Defines the desired size (the more it increases the longer the generation will be)
  71139. */
  71140. size: number;
  71141. /**
  71142. * Defines if mipmaps should not be generated (default is false)
  71143. */
  71144. noMipmap: boolean;
  71145. /**
  71146. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71147. */
  71148. generateHarmonics: boolean;
  71149. /**
  71150. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  71151. */
  71152. gammaSpace: boolean;
  71153. /**
  71154. * Internal Use Only
  71155. */
  71156. reserved: boolean;
  71157. /**
  71158. * Gets the loaded texture
  71159. */
  71160. texture: HDRCubeTexture;
  71161. /**
  71162. * Callback called when the task is successful
  71163. */
  71164. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71165. /**
  71166. * Callback called when the task is successful
  71167. */
  71168. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71169. /**
  71170. * Creates a new HDRCubeTextureAssetTask object
  71171. * @param name defines the name of the task
  71172. * @param url defines the location of the file to load
  71173. * @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.
  71174. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71175. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71176. * @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)
  71177. * @param reserved Internal use only
  71178. */
  71179. constructor(
  71180. /**
  71181. * Defines the name of the task
  71182. */
  71183. name: string,
  71184. /**
  71185. * Defines the location of the file to load
  71186. */
  71187. url: string,
  71188. /**
  71189. * Defines the desired size (the more it increases the longer the generation will be)
  71190. */
  71191. size: number,
  71192. /**
  71193. * Defines if mipmaps should not be generated (default is false)
  71194. */
  71195. noMipmap?: boolean,
  71196. /**
  71197. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71198. */
  71199. generateHarmonics?: boolean,
  71200. /**
  71201. * 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)
  71202. */
  71203. gammaSpace?: boolean,
  71204. /**
  71205. * Internal Use Only
  71206. */
  71207. reserved?: boolean);
  71208. /**
  71209. * Execute the current task
  71210. * @param scene defines the scene where you want your assets to be loaded
  71211. * @param onSuccess is a callback called when the task is successfully executed
  71212. * @param onError is a callback called if an error occurs
  71213. */
  71214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71215. }
  71216. /**
  71217. * Define a task used by AssetsManager to load Equirectangular cube textures
  71218. */
  71219. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71220. /**
  71221. * Defines the name of the task
  71222. */
  71223. name: string;
  71224. /**
  71225. * Defines the location of the file to load
  71226. */
  71227. url: string;
  71228. /**
  71229. * Defines the desired size (the more it increases the longer the generation will be)
  71230. */
  71231. size: number;
  71232. /**
  71233. * Defines if mipmaps should not be generated (default is false)
  71234. */
  71235. noMipmap: boolean;
  71236. /**
  71237. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71238. * but the standard material would require them in Gamma space) (default is true)
  71239. */
  71240. gammaSpace: boolean;
  71241. /**
  71242. * Gets the loaded texture
  71243. */
  71244. texture: EquiRectangularCubeTexture;
  71245. /**
  71246. * Callback called when the task is successful
  71247. */
  71248. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71249. /**
  71250. * Callback called when the task is successful
  71251. */
  71252. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71253. /**
  71254. * Creates a new EquiRectangularCubeTextureAssetTask object
  71255. * @param name defines the name of the task
  71256. * @param url defines the location of the file to load
  71257. * @param size defines the desired size (the more it increases the longer the generation will be)
  71258. * If the size is omitted this implies you are using a preprocessed cubemap.
  71259. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71260. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71261. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71262. * (default is true)
  71263. */
  71264. constructor(
  71265. /**
  71266. * Defines the name of the task
  71267. */
  71268. name: string,
  71269. /**
  71270. * Defines the location of the file to load
  71271. */
  71272. url: string,
  71273. /**
  71274. * Defines the desired size (the more it increases the longer the generation will be)
  71275. */
  71276. size: number,
  71277. /**
  71278. * Defines if mipmaps should not be generated (default is false)
  71279. */
  71280. noMipmap?: boolean,
  71281. /**
  71282. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71283. * but the standard material would require them in Gamma space) (default is true)
  71284. */
  71285. gammaSpace?: boolean);
  71286. /**
  71287. * Execute the current task
  71288. * @param scene defines the scene where you want your assets to be loaded
  71289. * @param onSuccess is a callback called when the task is successfully executed
  71290. * @param onError is a callback called if an error occurs
  71291. */
  71292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71293. }
  71294. /**
  71295. * This class can be used to easily import assets into a scene
  71296. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71297. */
  71298. export class AssetsManager {
  71299. private _scene;
  71300. private _isLoading;
  71301. protected _tasks: AbstractAssetTask[];
  71302. protected _waitingTasksCount: number;
  71303. protected _totalTasksCount: number;
  71304. /**
  71305. * Callback called when all tasks are processed
  71306. */
  71307. onFinish: (tasks: AbstractAssetTask[]) => void;
  71308. /**
  71309. * Callback called when a task is successful
  71310. */
  71311. onTaskSuccess: (task: AbstractAssetTask) => void;
  71312. /**
  71313. * Callback called when a task had an error
  71314. */
  71315. onTaskError: (task: AbstractAssetTask) => void;
  71316. /**
  71317. * Callback called when a task is done (whatever the result is)
  71318. */
  71319. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71320. /**
  71321. * Observable called when all tasks are processed
  71322. */
  71323. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71324. /**
  71325. * Observable called when a task had an error
  71326. */
  71327. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71328. /**
  71329. * Observable called when all tasks were executed
  71330. */
  71331. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71332. /**
  71333. * Observable called when a task is done (whatever the result is)
  71334. */
  71335. onProgressObservable: Observable<IAssetsProgressEvent>;
  71336. /**
  71337. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71338. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71339. */
  71340. useDefaultLoadingScreen: boolean;
  71341. /**
  71342. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71343. * when all assets have been downloaded.
  71344. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71345. */
  71346. autoHideLoadingUI: boolean;
  71347. /**
  71348. * Creates a new AssetsManager
  71349. * @param scene defines the scene to work on
  71350. */
  71351. constructor(scene: Scene);
  71352. /**
  71353. * Add a MeshAssetTask to the list of active tasks
  71354. * @param taskName defines the name of the new task
  71355. * @param meshesNames defines the name of meshes to load
  71356. * @param rootUrl defines the root url to use to locate files
  71357. * @param sceneFilename defines the filename of the scene file
  71358. * @returns a new MeshAssetTask object
  71359. */
  71360. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71361. /**
  71362. * Add a TextFileAssetTask to the list of active tasks
  71363. * @param taskName defines the name of the new task
  71364. * @param url defines the url of the file to load
  71365. * @returns a new TextFileAssetTask object
  71366. */
  71367. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71368. /**
  71369. * Add a BinaryFileAssetTask to the list of active tasks
  71370. * @param taskName defines the name of the new task
  71371. * @param url defines the url of the file to load
  71372. * @returns a new BinaryFileAssetTask object
  71373. */
  71374. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71375. /**
  71376. * Add a ImageAssetTask to the list of active tasks
  71377. * @param taskName defines the name of the new task
  71378. * @param url defines the url of the file to load
  71379. * @returns a new ImageAssetTask object
  71380. */
  71381. addImageTask(taskName: string, url: string): ImageAssetTask;
  71382. /**
  71383. * Add a TextureAssetTask to the list of active tasks
  71384. * @param taskName defines the name of the new task
  71385. * @param url defines the url of the file to load
  71386. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71387. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71388. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71389. * @returns a new TextureAssetTask object
  71390. */
  71391. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71392. /**
  71393. * Add a CubeTextureAssetTask to the list of active tasks
  71394. * @param taskName defines the name of the new task
  71395. * @param url defines the url of the file to load
  71396. * @param extensions defines the extension to use to load the cube map (can be null)
  71397. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71398. * @param files defines the list of files to load (can be null)
  71399. * @returns a new CubeTextureAssetTask object
  71400. */
  71401. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71402. /**
  71403. *
  71404. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71405. * @param taskName defines the name of the new task
  71406. * @param url defines the url of the file to load
  71407. * @param size defines the size you want for the cubemap (can be null)
  71408. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71409. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71410. * @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)
  71411. * @param reserved Internal use only
  71412. * @returns a new HDRCubeTextureAssetTask object
  71413. */
  71414. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71415. /**
  71416. *
  71417. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71418. * @param taskName defines the name of the new task
  71419. * @param url defines the url of the file to load
  71420. * @param size defines the size you want for the cubemap (can be null)
  71421. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71422. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71423. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71424. * @returns a new EquiRectangularCubeTextureAssetTask object
  71425. */
  71426. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71427. /**
  71428. * Remove a task from the assets manager.
  71429. * @param task the task to remove
  71430. */
  71431. removeTask(task: AbstractAssetTask): void;
  71432. private _decreaseWaitingTasksCount;
  71433. private _runTask;
  71434. /**
  71435. * Reset the AssetsManager and remove all tasks
  71436. * @return the current instance of the AssetsManager
  71437. */
  71438. reset(): AssetsManager;
  71439. /**
  71440. * Start the loading process
  71441. * @return the current instance of the AssetsManager
  71442. */
  71443. load(): AssetsManager;
  71444. /**
  71445. * Start the loading process as an async operation
  71446. * @return a promise returning the list of failed tasks
  71447. */
  71448. loadAsync(): Promise<void>;
  71449. }
  71450. }
  71451. declare module "babylonjs/Misc/deferred" {
  71452. /**
  71453. * Wrapper class for promise with external resolve and reject.
  71454. */
  71455. export class Deferred<T> {
  71456. /**
  71457. * The promise associated with this deferred object.
  71458. */
  71459. readonly promise: Promise<T>;
  71460. private _resolve;
  71461. private _reject;
  71462. /**
  71463. * The resolve method of the promise associated with this deferred object.
  71464. */
  71465. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71466. /**
  71467. * The reject method of the promise associated with this deferred object.
  71468. */
  71469. get reject(): (reason?: any) => void;
  71470. /**
  71471. * Constructor for this deferred object.
  71472. */
  71473. constructor();
  71474. }
  71475. }
  71476. declare module "babylonjs/Misc/meshExploder" {
  71477. import { Mesh } from "babylonjs/Meshes/mesh";
  71478. /**
  71479. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71480. */
  71481. export class MeshExploder {
  71482. private _centerMesh;
  71483. private _meshes;
  71484. private _meshesOrigins;
  71485. private _toCenterVectors;
  71486. private _scaledDirection;
  71487. private _newPosition;
  71488. private _centerPosition;
  71489. /**
  71490. * Explodes meshes from a center mesh.
  71491. * @param meshes The meshes to explode.
  71492. * @param centerMesh The mesh to be center of explosion.
  71493. */
  71494. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71495. private _setCenterMesh;
  71496. /**
  71497. * Get class name
  71498. * @returns "MeshExploder"
  71499. */
  71500. getClassName(): string;
  71501. /**
  71502. * "Exploded meshes"
  71503. * @returns Array of meshes with the centerMesh at index 0.
  71504. */
  71505. getMeshes(): Array<Mesh>;
  71506. /**
  71507. * Explodes meshes giving a specific direction
  71508. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71509. */
  71510. explode(direction?: number): void;
  71511. }
  71512. }
  71513. declare module "babylonjs/Misc/filesInput" {
  71514. import { Engine } from "babylonjs/Engines/engine";
  71515. import { Scene } from "babylonjs/scene";
  71516. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71517. /**
  71518. * Class used to help managing file picking and drag'n'drop
  71519. */
  71520. export class FilesInput {
  71521. /**
  71522. * List of files ready to be loaded
  71523. */
  71524. static get FilesToLoad(): {
  71525. [key: string]: File;
  71526. };
  71527. /**
  71528. * Callback called when a file is processed
  71529. */
  71530. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71531. private _engine;
  71532. private _currentScene;
  71533. private _sceneLoadedCallback;
  71534. private _progressCallback;
  71535. private _additionalRenderLoopLogicCallback;
  71536. private _textureLoadingCallback;
  71537. private _startingProcessingFilesCallback;
  71538. private _onReloadCallback;
  71539. private _errorCallback;
  71540. private _elementToMonitor;
  71541. private _sceneFileToLoad;
  71542. private _filesToLoad;
  71543. /**
  71544. * Creates a new FilesInput
  71545. * @param engine defines the rendering engine
  71546. * @param scene defines the hosting scene
  71547. * @param sceneLoadedCallback callback called when scene is loaded
  71548. * @param progressCallback callback called to track progress
  71549. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71550. * @param textureLoadingCallback callback called when a texture is loading
  71551. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71552. * @param onReloadCallback callback called when a reload is requested
  71553. * @param errorCallback callback call if an error occurs
  71554. */
  71555. 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);
  71556. private _dragEnterHandler;
  71557. private _dragOverHandler;
  71558. private _dropHandler;
  71559. /**
  71560. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71561. * @param elementToMonitor defines the DOM element to track
  71562. */
  71563. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71564. /**
  71565. * Release all associated resources
  71566. */
  71567. dispose(): void;
  71568. private renderFunction;
  71569. private drag;
  71570. private drop;
  71571. private _traverseFolder;
  71572. private _processFiles;
  71573. /**
  71574. * Load files from a drop event
  71575. * @param event defines the drop event to use as source
  71576. */
  71577. loadFiles(event: any): void;
  71578. private _processReload;
  71579. /**
  71580. * Reload the current scene from the loaded files
  71581. */
  71582. reload(): void;
  71583. }
  71584. }
  71585. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71586. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71587. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71588. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71589. }
  71590. declare module "babylonjs/Misc/sceneOptimizer" {
  71591. import { Scene, IDisposable } from "babylonjs/scene";
  71592. import { Observable } from "babylonjs/Misc/observable";
  71593. /**
  71594. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71595. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71596. */
  71597. export class SceneOptimization {
  71598. /**
  71599. * Defines the priority of this optimization (0 by default which means first in the list)
  71600. */
  71601. priority: number;
  71602. /**
  71603. * Gets a string describing the action executed by the current optimization
  71604. * @returns description string
  71605. */
  71606. getDescription(): string;
  71607. /**
  71608. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71609. * @param scene defines the current scene where to apply this optimization
  71610. * @param optimizer defines the current optimizer
  71611. * @returns true if everything that can be done was applied
  71612. */
  71613. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71614. /**
  71615. * Creates the SceneOptimization object
  71616. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71617. * @param desc defines the description associated with the optimization
  71618. */
  71619. constructor(
  71620. /**
  71621. * Defines the priority of this optimization (0 by default which means first in the list)
  71622. */
  71623. priority?: number);
  71624. }
  71625. /**
  71626. * Defines an optimization used to reduce the size of render target textures
  71627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71628. */
  71629. export class TextureOptimization extends SceneOptimization {
  71630. /**
  71631. * Defines the priority of this optimization (0 by default which means first in the list)
  71632. */
  71633. priority: number;
  71634. /**
  71635. * 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
  71636. */
  71637. maximumSize: number;
  71638. /**
  71639. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71640. */
  71641. step: number;
  71642. /**
  71643. * Gets a string describing the action executed by the current optimization
  71644. * @returns description string
  71645. */
  71646. getDescription(): string;
  71647. /**
  71648. * Creates the TextureOptimization object
  71649. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71650. * @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
  71651. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71652. */
  71653. constructor(
  71654. /**
  71655. * Defines the priority of this optimization (0 by default which means first in the list)
  71656. */
  71657. priority?: number,
  71658. /**
  71659. * Defines the maximum 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
  71660. */
  71661. maximumSize?: number,
  71662. /**
  71663. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71664. */
  71665. step?: number);
  71666. /**
  71667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71668. * @param scene defines the current scene where to apply this optimization
  71669. * @param optimizer defines the current optimizer
  71670. * @returns true if everything that can be done was applied
  71671. */
  71672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71673. }
  71674. /**
  71675. * Defines an optimization used to increase or decrease the rendering resolution
  71676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71677. */
  71678. export class HardwareScalingOptimization extends SceneOptimization {
  71679. /**
  71680. * Defines the priority of this optimization (0 by default which means first in the list)
  71681. */
  71682. priority: number;
  71683. /**
  71684. * Defines the maximum scale to use (2 by default)
  71685. */
  71686. maximumScale: number;
  71687. /**
  71688. * Defines the step to use between two passes (0.5 by default)
  71689. */
  71690. step: number;
  71691. private _currentScale;
  71692. private _directionOffset;
  71693. /**
  71694. * Gets a string describing the action executed by the current optimization
  71695. * @return description string
  71696. */
  71697. getDescription(): string;
  71698. /**
  71699. * Creates the HardwareScalingOptimization object
  71700. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71701. * @param maximumScale defines the maximum scale to use (2 by default)
  71702. * @param step defines the step to use between two passes (0.5 by default)
  71703. */
  71704. constructor(
  71705. /**
  71706. * Defines the priority of this optimization (0 by default which means first in the list)
  71707. */
  71708. priority?: number,
  71709. /**
  71710. * Defines the maximum scale to use (2 by default)
  71711. */
  71712. maximumScale?: number,
  71713. /**
  71714. * Defines the step to use between two passes (0.5 by default)
  71715. */
  71716. step?: number);
  71717. /**
  71718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71719. * @param scene defines the current scene where to apply this optimization
  71720. * @param optimizer defines the current optimizer
  71721. * @returns true if everything that can be done was applied
  71722. */
  71723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71724. }
  71725. /**
  71726. * Defines an optimization used to remove shadows
  71727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71728. */
  71729. export class ShadowsOptimization extends SceneOptimization {
  71730. /**
  71731. * Gets a string describing the action executed by the current optimization
  71732. * @return description string
  71733. */
  71734. getDescription(): string;
  71735. /**
  71736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71737. * @param scene defines the current scene where to apply this optimization
  71738. * @param optimizer defines the current optimizer
  71739. * @returns true if everything that can be done was applied
  71740. */
  71741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71742. }
  71743. /**
  71744. * Defines an optimization used to turn post-processes off
  71745. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71746. */
  71747. export class PostProcessesOptimization extends SceneOptimization {
  71748. /**
  71749. * Gets a string describing the action executed by the current optimization
  71750. * @return description string
  71751. */
  71752. getDescription(): string;
  71753. /**
  71754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71755. * @param scene defines the current scene where to apply this optimization
  71756. * @param optimizer defines the current optimizer
  71757. * @returns true if everything that can be done was applied
  71758. */
  71759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71760. }
  71761. /**
  71762. * Defines an optimization used to turn lens flares off
  71763. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71764. */
  71765. export class LensFlaresOptimization extends SceneOptimization {
  71766. /**
  71767. * Gets a string describing the action executed by the current optimization
  71768. * @return description string
  71769. */
  71770. getDescription(): string;
  71771. /**
  71772. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71773. * @param scene defines the current scene where to apply this optimization
  71774. * @param optimizer defines the current optimizer
  71775. * @returns true if everything that can be done was applied
  71776. */
  71777. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71778. }
  71779. /**
  71780. * Defines an optimization based on user defined callback.
  71781. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71782. */
  71783. export class CustomOptimization extends SceneOptimization {
  71784. /**
  71785. * Callback called to apply the custom optimization.
  71786. */
  71787. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71788. /**
  71789. * Callback called to get custom description
  71790. */
  71791. onGetDescription: () => string;
  71792. /**
  71793. * Gets a string describing the action executed by the current optimization
  71794. * @returns description string
  71795. */
  71796. getDescription(): string;
  71797. /**
  71798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71799. * @param scene defines the current scene where to apply this optimization
  71800. * @param optimizer defines the current optimizer
  71801. * @returns true if everything that can be done was applied
  71802. */
  71803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71804. }
  71805. /**
  71806. * Defines an optimization used to turn particles off
  71807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71808. */
  71809. export class ParticlesOptimization extends SceneOptimization {
  71810. /**
  71811. * Gets a string describing the action executed by the current optimization
  71812. * @return description string
  71813. */
  71814. getDescription(): string;
  71815. /**
  71816. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71817. * @param scene defines the current scene where to apply this optimization
  71818. * @param optimizer defines the current optimizer
  71819. * @returns true if everything that can be done was applied
  71820. */
  71821. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71822. }
  71823. /**
  71824. * Defines an optimization used to turn render targets off
  71825. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71826. */
  71827. export class RenderTargetsOptimization extends SceneOptimization {
  71828. /**
  71829. * Gets a string describing the action executed by the current optimization
  71830. * @return description string
  71831. */
  71832. getDescription(): string;
  71833. /**
  71834. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71835. * @param scene defines the current scene where to apply this optimization
  71836. * @param optimizer defines the current optimizer
  71837. * @returns true if everything that can be done was applied
  71838. */
  71839. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71840. }
  71841. /**
  71842. * Defines an optimization used to merge meshes with compatible materials
  71843. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71844. */
  71845. export class MergeMeshesOptimization extends SceneOptimization {
  71846. private static _UpdateSelectionTree;
  71847. /**
  71848. * Gets or sets a boolean which defines if optimization octree has to be updated
  71849. */
  71850. static get UpdateSelectionTree(): boolean;
  71851. /**
  71852. * Gets or sets a boolean which defines if optimization octree has to be updated
  71853. */
  71854. static set UpdateSelectionTree(value: boolean);
  71855. /**
  71856. * Gets a string describing the action executed by the current optimization
  71857. * @return description string
  71858. */
  71859. getDescription(): string;
  71860. private _canBeMerged;
  71861. /**
  71862. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71863. * @param scene defines the current scene where to apply this optimization
  71864. * @param optimizer defines the current optimizer
  71865. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71866. * @returns true if everything that can be done was applied
  71867. */
  71868. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71869. }
  71870. /**
  71871. * Defines a list of options used by SceneOptimizer
  71872. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71873. */
  71874. export class SceneOptimizerOptions {
  71875. /**
  71876. * Defines the target frame rate to reach (60 by default)
  71877. */
  71878. targetFrameRate: number;
  71879. /**
  71880. * Defines the interval between two checkes (2000ms by default)
  71881. */
  71882. trackerDuration: number;
  71883. /**
  71884. * Gets the list of optimizations to apply
  71885. */
  71886. optimizations: SceneOptimization[];
  71887. /**
  71888. * Creates a new list of options used by SceneOptimizer
  71889. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71890. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71891. */
  71892. constructor(
  71893. /**
  71894. * Defines the target frame rate to reach (60 by default)
  71895. */
  71896. targetFrameRate?: number,
  71897. /**
  71898. * Defines the interval between two checkes (2000ms by default)
  71899. */
  71900. trackerDuration?: number);
  71901. /**
  71902. * Add a new optimization
  71903. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71904. * @returns the current SceneOptimizerOptions
  71905. */
  71906. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71907. /**
  71908. * Add a new custom optimization
  71909. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71910. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71911. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71912. * @returns the current SceneOptimizerOptions
  71913. */
  71914. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71915. /**
  71916. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71917. * @param targetFrameRate defines the target frame rate (60 by default)
  71918. * @returns a SceneOptimizerOptions object
  71919. */
  71920. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71921. /**
  71922. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71923. * @param targetFrameRate defines the target frame rate (60 by default)
  71924. * @returns a SceneOptimizerOptions object
  71925. */
  71926. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71927. /**
  71928. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71929. * @param targetFrameRate defines the target frame rate (60 by default)
  71930. * @returns a SceneOptimizerOptions object
  71931. */
  71932. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71933. }
  71934. /**
  71935. * Class used to run optimizations in order to reach a target frame rate
  71936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71937. */
  71938. export class SceneOptimizer implements IDisposable {
  71939. private _isRunning;
  71940. private _options;
  71941. private _scene;
  71942. private _currentPriorityLevel;
  71943. private _targetFrameRate;
  71944. private _trackerDuration;
  71945. private _currentFrameRate;
  71946. private _sceneDisposeObserver;
  71947. private _improvementMode;
  71948. /**
  71949. * Defines an observable called when the optimizer reaches the target frame rate
  71950. */
  71951. onSuccessObservable: Observable<SceneOptimizer>;
  71952. /**
  71953. * Defines an observable called when the optimizer enables an optimization
  71954. */
  71955. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71956. /**
  71957. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71958. */
  71959. onFailureObservable: Observable<SceneOptimizer>;
  71960. /**
  71961. * Gets a boolean indicating if the optimizer is in improvement mode
  71962. */
  71963. get isInImprovementMode(): boolean;
  71964. /**
  71965. * Gets the current priority level (0 at start)
  71966. */
  71967. get currentPriorityLevel(): number;
  71968. /**
  71969. * Gets the current frame rate checked by the SceneOptimizer
  71970. */
  71971. get currentFrameRate(): number;
  71972. /**
  71973. * Gets or sets the current target frame rate (60 by default)
  71974. */
  71975. get targetFrameRate(): number;
  71976. /**
  71977. * Gets or sets the current target frame rate (60 by default)
  71978. */
  71979. set targetFrameRate(value: number);
  71980. /**
  71981. * Gets or sets the current interval between two checks (every 2000ms by default)
  71982. */
  71983. get trackerDuration(): number;
  71984. /**
  71985. * Gets or sets the current interval between two checks (every 2000ms by default)
  71986. */
  71987. set trackerDuration(value: number);
  71988. /**
  71989. * Gets the list of active optimizations
  71990. */
  71991. get optimizations(): SceneOptimization[];
  71992. /**
  71993. * Creates a new SceneOptimizer
  71994. * @param scene defines the scene to work on
  71995. * @param options defines the options to use with the SceneOptimizer
  71996. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71997. * @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)
  71998. */
  71999. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72000. /**
  72001. * Stops the current optimizer
  72002. */
  72003. stop(): void;
  72004. /**
  72005. * Reset the optimizer to initial step (current priority level = 0)
  72006. */
  72007. reset(): void;
  72008. /**
  72009. * Start the optimizer. By default it will try to reach a specific framerate
  72010. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72011. */
  72012. start(): void;
  72013. private _checkCurrentState;
  72014. /**
  72015. * Release all resources
  72016. */
  72017. dispose(): void;
  72018. /**
  72019. * Helper function to create a SceneOptimizer with one single line of code
  72020. * @param scene defines the scene to work on
  72021. * @param options defines the options to use with the SceneOptimizer
  72022. * @param onSuccess defines a callback to call on success
  72023. * @param onFailure defines a callback to call on failure
  72024. * @returns the new SceneOptimizer object
  72025. */
  72026. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72027. }
  72028. }
  72029. declare module "babylonjs/Misc/sceneSerializer" {
  72030. import { Scene } from "babylonjs/scene";
  72031. /**
  72032. * Class used to serialize a scene into a string
  72033. */
  72034. export class SceneSerializer {
  72035. /**
  72036. * Clear cache used by a previous serialization
  72037. */
  72038. static ClearCache(): void;
  72039. /**
  72040. * Serialize a scene into a JSON compatible object
  72041. * @param scene defines the scene to serialize
  72042. * @returns a JSON compatible object
  72043. */
  72044. static Serialize(scene: Scene): any;
  72045. /**
  72046. * Serialize a mesh into a JSON compatible object
  72047. * @param toSerialize defines the mesh to serialize
  72048. * @param withParents defines if parents must be serialized as well
  72049. * @param withChildren defines if children must be serialized as well
  72050. * @returns a JSON compatible object
  72051. */
  72052. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72053. }
  72054. }
  72055. declare module "babylonjs/Misc/textureTools" {
  72056. import { Texture } from "babylonjs/Materials/Textures/texture";
  72057. /**
  72058. * Class used to host texture specific utilities
  72059. */
  72060. export class TextureTools {
  72061. /**
  72062. * Uses the GPU to create a copy texture rescaled at a given size
  72063. * @param texture Texture to copy from
  72064. * @param width defines the desired width
  72065. * @param height defines the desired height
  72066. * @param useBilinearMode defines if bilinear mode has to be used
  72067. * @return the generated texture
  72068. */
  72069. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72070. }
  72071. }
  72072. declare module "babylonjs/Misc/videoRecorder" {
  72073. import { Nullable } from "babylonjs/types";
  72074. import { Engine } from "babylonjs/Engines/engine";
  72075. /**
  72076. * This represents the different options available for the video capture.
  72077. */
  72078. export interface VideoRecorderOptions {
  72079. /** Defines the mime type of the video. */
  72080. mimeType: string;
  72081. /** Defines the FPS the video should be recorded at. */
  72082. fps: number;
  72083. /** Defines the chunk size for the recording data. */
  72084. recordChunckSize: number;
  72085. /** The audio tracks to attach to the recording. */
  72086. audioTracks?: MediaStreamTrack[];
  72087. }
  72088. /**
  72089. * This can help with recording videos from BabylonJS.
  72090. * This is based on the available WebRTC functionalities of the browser.
  72091. *
  72092. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72093. */
  72094. export class VideoRecorder {
  72095. private static readonly _defaultOptions;
  72096. /**
  72097. * Returns whether or not the VideoRecorder is available in your browser.
  72098. * @param engine Defines the Babylon Engine.
  72099. * @returns true if supported otherwise false.
  72100. */
  72101. static IsSupported(engine: Engine): boolean;
  72102. private readonly _options;
  72103. private _canvas;
  72104. private _mediaRecorder;
  72105. private _recordedChunks;
  72106. private _fileName;
  72107. private _resolve;
  72108. private _reject;
  72109. /**
  72110. * True when a recording is already in progress.
  72111. */
  72112. get isRecording(): boolean;
  72113. /**
  72114. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72115. * @param engine Defines the BabylonJS Engine you wish to record.
  72116. * @param options Defines options that can be used to customize the capture.
  72117. */
  72118. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72119. /**
  72120. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72121. */
  72122. stopRecording(): void;
  72123. /**
  72124. * Starts recording the canvas for a max duration specified in parameters.
  72125. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72126. * If null no automatic download will start and you can rely on the promise to get the data back.
  72127. * @param maxDuration Defines the maximum recording time in seconds.
  72128. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72129. * @return A promise callback at the end of the recording with the video data in Blob.
  72130. */
  72131. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72132. /**
  72133. * Releases internal resources used during the recording.
  72134. */
  72135. dispose(): void;
  72136. private _handleDataAvailable;
  72137. private _handleError;
  72138. private _handleStop;
  72139. }
  72140. }
  72141. declare module "babylonjs/Misc/screenshotTools" {
  72142. import { Camera } from "babylonjs/Cameras/camera";
  72143. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72144. import { Engine } from "babylonjs/Engines/engine";
  72145. /**
  72146. * Class containing a set of static utilities functions for screenshots
  72147. */
  72148. export class ScreenshotTools {
  72149. /**
  72150. * Captures a screenshot of the current rendering
  72151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72152. * @param engine defines the rendering engine
  72153. * @param camera defines the source camera
  72154. * @param size This parameter can be set to a single number or to an object with the
  72155. * following (optional) properties: precision, width, height. If a single number is passed,
  72156. * it will be used for both width and height. If an object is passed, the screenshot size
  72157. * will be derived from the parameters. The precision property is a multiplier allowing
  72158. * rendering at a higher or lower resolution
  72159. * @param successCallback defines the callback receives a single parameter which contains the
  72160. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72161. * src parameter of an <img> to display it
  72162. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72163. * Check your browser for supported MIME types
  72164. */
  72165. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72166. /**
  72167. * Captures a screenshot of the current rendering
  72168. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72169. * @param engine defines the rendering engine
  72170. * @param camera defines the source camera
  72171. * @param size This parameter can be set to a single number or to an object with the
  72172. * following (optional) properties: precision, width, height. If a single number is passed,
  72173. * it will be used for both width and height. If an object is passed, the screenshot size
  72174. * will be derived from the parameters. The precision property is a multiplier allowing
  72175. * rendering at a higher or lower resolution
  72176. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72177. * Check your browser for supported MIME types
  72178. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72179. * to the src parameter of an <img> to display it
  72180. */
  72181. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72182. /**
  72183. * Generates an image screenshot from the specified camera.
  72184. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72185. * @param engine The engine to use for rendering
  72186. * @param camera The camera to use for rendering
  72187. * @param size This parameter can be set to a single number or to an object with the
  72188. * following (optional) properties: precision, width, height. If a single number is passed,
  72189. * it will be used for both width and height. If an object is passed, the screenshot size
  72190. * will be derived from the parameters. The precision property is a multiplier allowing
  72191. * rendering at a higher or lower resolution
  72192. * @param successCallback The callback receives a single parameter which contains the
  72193. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72194. * src parameter of an <img> to display it
  72195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72196. * Check your browser for supported MIME types
  72197. * @param samples Texture samples (default: 1)
  72198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72199. * @param fileName A name for for the downloaded file.
  72200. */
  72201. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  72202. /**
  72203. * Generates an image screenshot from the specified camera.
  72204. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72205. * @param engine The engine to use for rendering
  72206. * @param camera The camera to use for rendering
  72207. * @param size This parameter can be set to a single number or to an object with the
  72208. * following (optional) properties: precision, width, height. If a single number is passed,
  72209. * it will be used for both width and height. If an object is passed, the screenshot size
  72210. * will be derived from the parameters. The precision property is a multiplier allowing
  72211. * rendering at a higher or lower resolution
  72212. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72213. * Check your browser for supported MIME types
  72214. * @param samples Texture samples (default: 1)
  72215. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72216. * @param fileName A name for for the downloaded file.
  72217. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72218. * to the src parameter of an <img> to display it
  72219. */
  72220. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  72221. /**
  72222. * Gets height and width for screenshot size
  72223. * @private
  72224. */
  72225. private static _getScreenshotSize;
  72226. }
  72227. }
  72228. declare module "babylonjs/Misc/dataReader" {
  72229. /**
  72230. * Interface for a data buffer
  72231. */
  72232. export interface IDataBuffer {
  72233. /**
  72234. * Reads bytes from the data buffer.
  72235. * @param byteOffset The byte offset to read
  72236. * @param byteLength The byte length to read
  72237. * @returns A promise that resolves when the bytes are read
  72238. */
  72239. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72240. /**
  72241. * The byte length of the buffer.
  72242. */
  72243. readonly byteLength: number;
  72244. }
  72245. /**
  72246. * Utility class for reading from a data buffer
  72247. */
  72248. export class DataReader {
  72249. /**
  72250. * The data buffer associated with this data reader.
  72251. */
  72252. readonly buffer: IDataBuffer;
  72253. /**
  72254. * The current byte offset from the beginning of the data buffer.
  72255. */
  72256. byteOffset: number;
  72257. private _dataView;
  72258. private _dataByteOffset;
  72259. /**
  72260. * Constructor
  72261. * @param buffer The buffer to read
  72262. */
  72263. constructor(buffer: IDataBuffer);
  72264. /**
  72265. * Loads the given byte length.
  72266. * @param byteLength The byte length to load
  72267. * @returns A promise that resolves when the load is complete
  72268. */
  72269. loadAsync(byteLength: number): Promise<void>;
  72270. /**
  72271. * Read a unsigned 32-bit integer from the currently loaded data range.
  72272. * @returns The 32-bit integer read
  72273. */
  72274. readUint32(): number;
  72275. /**
  72276. * Read a byte array from the currently loaded data range.
  72277. * @param byteLength The byte length to read
  72278. * @returns The byte array read
  72279. */
  72280. readUint8Array(byteLength: number): Uint8Array;
  72281. /**
  72282. * Read a string from the currently loaded data range.
  72283. * @param byteLength The byte length to read
  72284. * @returns The string read
  72285. */
  72286. readString(byteLength: number): string;
  72287. /**
  72288. * Skips the given byte length the currently loaded data range.
  72289. * @param byteLength The byte length to skip
  72290. */
  72291. skipBytes(byteLength: number): void;
  72292. }
  72293. }
  72294. declare module "babylonjs/Misc/index" {
  72295. export * from "babylonjs/Misc/andOrNotEvaluator";
  72296. export * from "babylonjs/Misc/assetsManager";
  72297. export * from "babylonjs/Misc/basis";
  72298. export * from "babylonjs/Misc/dds";
  72299. export * from "babylonjs/Misc/decorators";
  72300. export * from "babylonjs/Misc/deferred";
  72301. export * from "babylonjs/Misc/environmentTextureTools";
  72302. export * from "babylonjs/Misc/meshExploder";
  72303. export * from "babylonjs/Misc/filesInput";
  72304. export * from "babylonjs/Misc/HighDynamicRange/index";
  72305. export * from "babylonjs/Misc/khronosTextureContainer";
  72306. export * from "babylonjs/Misc/observable";
  72307. export * from "babylonjs/Misc/performanceMonitor";
  72308. export * from "babylonjs/Misc/promise";
  72309. export * from "babylonjs/Misc/sceneOptimizer";
  72310. export * from "babylonjs/Misc/sceneSerializer";
  72311. export * from "babylonjs/Misc/smartArray";
  72312. export * from "babylonjs/Misc/stringDictionary";
  72313. export * from "babylonjs/Misc/tags";
  72314. export * from "babylonjs/Misc/textureTools";
  72315. export * from "babylonjs/Misc/tga";
  72316. export * from "babylonjs/Misc/tools";
  72317. export * from "babylonjs/Misc/videoRecorder";
  72318. export * from "babylonjs/Misc/virtualJoystick";
  72319. export * from "babylonjs/Misc/workerPool";
  72320. export * from "babylonjs/Misc/logger";
  72321. export * from "babylonjs/Misc/typeStore";
  72322. export * from "babylonjs/Misc/filesInputStore";
  72323. export * from "babylonjs/Misc/deepCopier";
  72324. export * from "babylonjs/Misc/pivotTools";
  72325. export * from "babylonjs/Misc/precisionDate";
  72326. export * from "babylonjs/Misc/screenshotTools";
  72327. export * from "babylonjs/Misc/typeStore";
  72328. export * from "babylonjs/Misc/webRequest";
  72329. export * from "babylonjs/Misc/iInspectable";
  72330. export * from "babylonjs/Misc/brdfTextureTools";
  72331. export * from "babylonjs/Misc/rgbdTextureTools";
  72332. export * from "babylonjs/Misc/gradients";
  72333. export * from "babylonjs/Misc/perfCounter";
  72334. export * from "babylonjs/Misc/fileRequest";
  72335. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72336. export * from "babylonjs/Misc/retryStrategy";
  72337. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72338. export * from "babylonjs/Misc/canvasGenerator";
  72339. export * from "babylonjs/Misc/fileTools";
  72340. export * from "babylonjs/Misc/stringTools";
  72341. export * from "babylonjs/Misc/dataReader";
  72342. export * from "babylonjs/Misc/minMaxReducer";
  72343. export * from "babylonjs/Misc/depthReducer";
  72344. }
  72345. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72346. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72347. import { Observable } from "babylonjs/Misc/observable";
  72348. import { Matrix } from "babylonjs/Maths/math.vector";
  72349. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72350. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72351. /**
  72352. * Options used for hit testing
  72353. */
  72354. export interface IWebXRHitTestOptions {
  72355. /**
  72356. * Only test when user interacted with the scene. Default - hit test every frame
  72357. */
  72358. testOnPointerDownOnly?: boolean;
  72359. /**
  72360. * The node to use to transform the local results to world coordinates
  72361. */
  72362. worldParentNode?: TransformNode;
  72363. }
  72364. /**
  72365. * Interface defining the babylon result of raycasting/hit-test
  72366. */
  72367. export interface IWebXRHitResult {
  72368. /**
  72369. * The native hit test result
  72370. */
  72371. xrHitResult: XRHitResult;
  72372. /**
  72373. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72374. */
  72375. transformationMatrix: Matrix;
  72376. }
  72377. /**
  72378. * The currently-working hit-test module.
  72379. * Hit test (or raycasting) is used to interact with the real world.
  72380. * For further information read here - https://github.com/immersive-web/hit-test
  72381. */
  72382. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72383. /**
  72384. * options to use when constructing this feature
  72385. */
  72386. readonly options: IWebXRHitTestOptions;
  72387. /**
  72388. * The module's name
  72389. */
  72390. static readonly Name: string;
  72391. /**
  72392. * The (Babylon) version of this module.
  72393. * This is an integer representing the implementation version.
  72394. * This number does not correspond to the webxr specs version
  72395. */
  72396. static readonly Version: number;
  72397. /**
  72398. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72399. * @param event the (select) event to use to select with
  72400. * @param referenceSpace the reference space to use for this hit test
  72401. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72402. */
  72403. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72404. /**
  72405. * execute a hit test with an XR Ray
  72406. *
  72407. * @param xrSession a native xrSession that will execute this hit test
  72408. * @param xrRay the ray (position and direction) to use for raycasting
  72409. * @param referenceSpace native XR reference space to use for the hit-test
  72410. * @param filter filter function that will filter the results
  72411. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72412. */
  72413. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72414. /**
  72415. * Triggered when new babylon (transformed) hit test results are available
  72416. */
  72417. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72418. private _onSelectEnabled;
  72419. /**
  72420. * Creates a new instance of the (legacy version) hit test feature
  72421. * @param _xrSessionManager an instance of WebXRSessionManager
  72422. * @param options options to use when constructing this feature
  72423. */
  72424. constructor(_xrSessionManager: WebXRSessionManager,
  72425. /**
  72426. * options to use when constructing this feature
  72427. */
  72428. options?: IWebXRHitTestOptions);
  72429. /**
  72430. * Populated with the last native XR Hit Results
  72431. */
  72432. lastNativeXRHitResults: XRHitResult[];
  72433. /**
  72434. * attach this feature
  72435. * Will usually be called by the features manager
  72436. *
  72437. * @returns true if successful.
  72438. */
  72439. attach(): boolean;
  72440. /**
  72441. * detach this feature.
  72442. * Will usually be called by the features manager
  72443. *
  72444. * @returns true if successful.
  72445. */
  72446. detach(): boolean;
  72447. private _onHitTestResults;
  72448. private _origin;
  72449. private _direction;
  72450. private _mat;
  72451. protected _onXRFrame(frame: XRFrame): void;
  72452. private _onSelect;
  72453. /**
  72454. * Dispose this feature and all of the resources attached
  72455. */
  72456. dispose(): void;
  72457. }
  72458. }
  72459. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72460. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72461. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72462. import { Observable } from "babylonjs/Misc/observable";
  72463. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72464. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72465. /**
  72466. * Options used in the plane detector module
  72467. */
  72468. export interface IWebXRPlaneDetectorOptions {
  72469. /**
  72470. * The node to use to transform the local results to world coordinates
  72471. */
  72472. worldParentNode?: TransformNode;
  72473. }
  72474. /**
  72475. * A babylon interface for a webxr plane.
  72476. * A Plane is actually a polygon, built from N points in space
  72477. *
  72478. * Supported in chrome 79, not supported in canary 81 ATM
  72479. */
  72480. export interface IWebXRPlane {
  72481. /**
  72482. * a babylon-assigned ID for this polygon
  72483. */
  72484. id: number;
  72485. /**
  72486. * the native xr-plane object
  72487. */
  72488. xrPlane: XRPlane;
  72489. /**
  72490. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72491. */
  72492. polygonDefinition: Array<Vector3>;
  72493. /**
  72494. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72495. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72496. */
  72497. transformationMatrix: Matrix;
  72498. }
  72499. /**
  72500. * The plane detector is used to detect planes in the real world when in AR
  72501. * For more information see https://github.com/immersive-web/real-world-geometry/
  72502. */
  72503. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72504. private _options;
  72505. /**
  72506. * The module's name
  72507. */
  72508. static readonly Name: string;
  72509. /**
  72510. * The (Babylon) version of this module.
  72511. * This is an integer representing the implementation version.
  72512. * This number does not correspond to the webxr specs version
  72513. */
  72514. static readonly Version: number;
  72515. /**
  72516. * Observers registered here will be executed when a new plane was added to the session
  72517. */
  72518. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72519. /**
  72520. * Observers registered here will be executed when a plane is no longer detected in the session
  72521. */
  72522. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72523. /**
  72524. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72525. * This can execute N times every frame
  72526. */
  72527. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72528. private _enabled;
  72529. private _detectedPlanes;
  72530. private _lastFrameDetected;
  72531. /**
  72532. * construct a new Plane Detector
  72533. * @param _xrSessionManager an instance of xr Session manager
  72534. * @param _options configuration to use when constructing this feature
  72535. */
  72536. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72537. private _init;
  72538. protected _onXRFrame(frame: XRFrame): void;
  72539. /**
  72540. * Dispose this feature and all of the resources attached
  72541. */
  72542. dispose(): void;
  72543. private _updatePlaneWithXRPlane;
  72544. /**
  72545. * avoiding using Array.find for global support.
  72546. * @param xrPlane the plane to find in the array
  72547. */
  72548. private findIndexInPlaneArray;
  72549. }
  72550. }
  72551. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72552. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72553. import { Observable } from "babylonjs/Misc/observable";
  72554. import { Matrix } from "babylonjs/Maths/math.vector";
  72555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72556. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72557. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72558. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72559. /**
  72560. * Configuration options of the anchor system
  72561. */
  72562. export interface IWebXRAnchorSystemOptions {
  72563. /**
  72564. * a node that will be used to convert local to world coordinates
  72565. */
  72566. worldParentNode?: TransformNode;
  72567. /**
  72568. * should the anchor system use plane detection.
  72569. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72570. */
  72571. usePlaneDetection?: boolean;
  72572. /**
  72573. * Should a new anchor be added every time a select event is triggered
  72574. */
  72575. addAnchorOnSelect?: boolean;
  72576. }
  72577. /**
  72578. * A babylon container for an XR Anchor
  72579. */
  72580. export interface IWebXRAnchor {
  72581. /**
  72582. * A babylon-assigned ID for this anchor
  72583. */
  72584. id: number;
  72585. /**
  72586. * The native anchor object
  72587. */
  72588. xrAnchor: XRAnchor;
  72589. /**
  72590. * Transformation matrix to apply to an object attached to this anchor
  72591. */
  72592. transformationMatrix: Matrix;
  72593. }
  72594. /**
  72595. * An implementation of the anchor system of WebXR.
  72596. * Note that the current documented implementation is not available in any browser. Future implementations
  72597. * will use the frame to create an anchor and not the session or a detected plane
  72598. * For further information see https://github.com/immersive-web/anchors/
  72599. */
  72600. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72601. private _options;
  72602. /**
  72603. * The module's name
  72604. */
  72605. static readonly Name: string;
  72606. /**
  72607. * The (Babylon) version of this module.
  72608. * This is an integer representing the implementation version.
  72609. * This number does not correspond to the webxr specs version
  72610. */
  72611. static readonly Version: number;
  72612. /**
  72613. * Observers registered here will be executed when a new anchor was added to the session
  72614. */
  72615. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72616. /**
  72617. * Observers registered here will be executed when an existing anchor updates
  72618. * This can execute N times every frame
  72619. */
  72620. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72621. /**
  72622. * Observers registered here will be executed when an anchor was removed from the session
  72623. */
  72624. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72625. private _planeDetector;
  72626. private _hitTestModule;
  72627. private _enabled;
  72628. private _trackedAnchors;
  72629. private _lastFrameDetected;
  72630. /**
  72631. * constructs a new anchor system
  72632. * @param _xrSessionManager an instance of WebXRSessionManager
  72633. * @param _options configuration object for this feature
  72634. */
  72635. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72636. /**
  72637. * set the plane detector to use in order to create anchors from frames
  72638. * @param planeDetector the plane-detector module to use
  72639. * @param enable enable plane-anchors. default is true
  72640. */
  72641. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72642. /**
  72643. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72644. * @param hitTestModule the hit-test module to use.
  72645. */
  72646. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72647. /**
  72648. * attach this feature
  72649. * Will usually be called by the features manager
  72650. *
  72651. * @returns true if successful.
  72652. */
  72653. attach(): boolean;
  72654. /**
  72655. * detach this feature.
  72656. * Will usually be called by the features manager
  72657. *
  72658. * @returns true if successful.
  72659. */
  72660. detach(): boolean;
  72661. /**
  72662. * Dispose this feature and all of the resources attached
  72663. */
  72664. dispose(): void;
  72665. protected _onXRFrame(frame: XRFrame): void;
  72666. private _onSelect;
  72667. /**
  72668. * Add anchor at a specific XR point.
  72669. *
  72670. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72671. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72672. * @returns a promise the fulfills when the anchor was created
  72673. */
  72674. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72675. private _updateAnchorWithXRFrame;
  72676. /**
  72677. * avoiding using Array.find for global support.
  72678. * @param xrAnchor the plane to find in the array
  72679. */
  72680. private _findIndexInAnchorArray;
  72681. }
  72682. }
  72683. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72684. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72686. import { Observable } from "babylonjs/Misc/observable";
  72687. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72688. /**
  72689. * Options interface for the background remover plugin
  72690. */
  72691. export interface IWebXRBackgroundRemoverOptions {
  72692. /**
  72693. * don't disable the environment helper
  72694. */
  72695. ignoreEnvironmentHelper?: boolean;
  72696. /**
  72697. * flags to configure the removal of the environment helper.
  72698. * If not set, the entire background will be removed. If set, flags should be set as well.
  72699. */
  72700. environmentHelperRemovalFlags?: {
  72701. /**
  72702. * Should the skybox be removed (default false)
  72703. */
  72704. skyBox?: boolean;
  72705. /**
  72706. * Should the ground be removed (default false)
  72707. */
  72708. ground?: boolean;
  72709. };
  72710. /**
  72711. * Further background meshes to disable when entering AR
  72712. */
  72713. backgroundMeshes?: AbstractMesh[];
  72714. }
  72715. /**
  72716. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72717. */
  72718. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72719. /**
  72720. * read-only options to be used in this module
  72721. */
  72722. readonly options: IWebXRBackgroundRemoverOptions;
  72723. /**
  72724. * The module's name
  72725. */
  72726. static readonly Name: string;
  72727. /**
  72728. * The (Babylon) version of this module.
  72729. * This is an integer representing the implementation version.
  72730. * This number does not correspond to the webxr specs version
  72731. */
  72732. static readonly Version: number;
  72733. /**
  72734. * registered observers will be triggered when the background state changes
  72735. */
  72736. onBackgroundStateChangedObservable: Observable<boolean>;
  72737. /**
  72738. * constructs a new background remover module
  72739. * @param _xrSessionManager the session manager for this module
  72740. * @param options read-only options to be used in this module
  72741. */
  72742. constructor(_xrSessionManager: WebXRSessionManager,
  72743. /**
  72744. * read-only options to be used in this module
  72745. */
  72746. options?: IWebXRBackgroundRemoverOptions);
  72747. /**
  72748. * attach this feature
  72749. * Will usually be called by the features manager
  72750. *
  72751. * @returns true if successful.
  72752. */
  72753. attach(): boolean;
  72754. /**
  72755. * detach this feature.
  72756. * Will usually be called by the features manager
  72757. *
  72758. * @returns true if successful.
  72759. */
  72760. detach(): boolean;
  72761. private _setBackgroundState;
  72762. /**
  72763. * Dispose this feature and all of the resources attached
  72764. */
  72765. dispose(): void;
  72766. protected _onXRFrame(_xrFrame: XRFrame): void;
  72767. }
  72768. }
  72769. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72770. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72771. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72772. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72773. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72774. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72775. import { Nullable } from "babylonjs/types";
  72776. /**
  72777. * Options for the controller physics feature
  72778. */
  72779. export class IWebXRControllerPhysicsOptions {
  72780. /**
  72781. * the xr input to use with this pointer selection
  72782. */
  72783. xrInput: WebXRInput;
  72784. /**
  72785. * The physics properties of the future impostors
  72786. */
  72787. physicsProperties?: {
  72788. /**
  72789. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72790. * Note that this requires a physics engine that supports mesh impostors!
  72791. */
  72792. useControllerMesh?: boolean;
  72793. /**
  72794. * The type of impostor to create. Default is sphere
  72795. */
  72796. impostorType?: number;
  72797. /**
  72798. * the size of the impostor. Defaults to 10cm
  72799. */
  72800. impostorSize?: number | {
  72801. width: number;
  72802. height: number;
  72803. depth: number;
  72804. };
  72805. /**
  72806. * Friction definitions
  72807. */
  72808. friction?: number;
  72809. /**
  72810. * Restitution
  72811. */
  72812. restitution?: number;
  72813. };
  72814. /**
  72815. * Should the headset get its own impostor
  72816. */
  72817. enableHeadsetImpostor?: boolean;
  72818. /**
  72819. * Optional parameters for the headset impostor
  72820. */
  72821. headsetImpostorParams?: {
  72822. /**
  72823. * The type of impostor to create. Default is sphere
  72824. */
  72825. impostorType: number;
  72826. /**
  72827. * the size of the impostor. Defaults to 10cm
  72828. */
  72829. impostorSize?: number | {
  72830. width: number;
  72831. height: number;
  72832. depth: number;
  72833. };
  72834. /**
  72835. * Friction definitions
  72836. */
  72837. friction?: number;
  72838. /**
  72839. * Restitution
  72840. */
  72841. restitution?: number;
  72842. };
  72843. }
  72844. /**
  72845. * Add physics impostor to your webxr controllers,
  72846. * including naive calculation of their linear and angular velocity
  72847. */
  72848. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72849. private readonly _options;
  72850. /**
  72851. * The module's name
  72852. */
  72853. static readonly Name: string;
  72854. /**
  72855. * The (Babylon) version of this module.
  72856. * This is an integer representing the implementation version.
  72857. * This number does not correspond to the webxr specs version
  72858. */
  72859. static readonly Version: number;
  72860. private _lastTimestamp;
  72861. private _delta;
  72862. private _controllers;
  72863. private _headsetImpostor?;
  72864. private _headsetMesh?;
  72865. private _tmpVector;
  72866. private _tmpQuaternion;
  72867. /**
  72868. * Construct a new Controller Physics Feature
  72869. * @param _xrSessionManager the corresponding xr session manager
  72870. * @param _options options to create this feature with
  72871. */
  72872. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72873. /**
  72874. * Update the physics properties provided in the constructor
  72875. * @param newProperties the new properties object
  72876. */
  72877. setPhysicsProperties(newProperties: {
  72878. impostorType?: number;
  72879. impostorSize?: number | {
  72880. width: number;
  72881. height: number;
  72882. depth: number;
  72883. };
  72884. friction?: number;
  72885. restitution?: number;
  72886. }): void;
  72887. /**
  72888. * Get the physics impostor of a specific controller.
  72889. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72890. * @param controller the controller or the controller id of which to get the impostor
  72891. * @returns the impostor or null
  72892. */
  72893. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72894. /**
  72895. * Get the headset impostor, if enabled
  72896. * @returns the impostor
  72897. */
  72898. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72899. /**
  72900. * attach this feature
  72901. * Will usually be called by the features manager
  72902. *
  72903. * @returns true if successful.
  72904. */
  72905. attach(): boolean;
  72906. /**
  72907. * detach this feature.
  72908. * Will usually be called by the features manager
  72909. *
  72910. * @returns true if successful.
  72911. */
  72912. detach(): boolean;
  72913. /**
  72914. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72915. * @param xrController the controller to add
  72916. */
  72917. addController(xrController: WebXRInputSource): void;
  72918. private _debugMode;
  72919. /**
  72920. * @hidden
  72921. * enable debugging - will show console outputs and the impostor mesh
  72922. */
  72923. _enablePhysicsDebug(): void;
  72924. private _attachController;
  72925. private _detachController;
  72926. protected _onXRFrame(_xrFrame: any): void;
  72927. }
  72928. }
  72929. declare module "babylonjs/XR/features/index" {
  72930. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72931. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72932. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72933. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72934. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72935. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72936. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72937. }
  72938. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72939. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72941. import { Scene } from "babylonjs/scene";
  72942. /**
  72943. * The motion controller class for all microsoft mixed reality controllers
  72944. */
  72945. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72946. /**
  72947. * The base url used to load the left and right controller models
  72948. */
  72949. static MODEL_BASE_URL: string;
  72950. /**
  72951. * The name of the left controller model file
  72952. */
  72953. static MODEL_LEFT_FILENAME: string;
  72954. /**
  72955. * The name of the right controller model file
  72956. */
  72957. static MODEL_RIGHT_FILENAME: string;
  72958. profileId: string;
  72959. protected readonly _mapping: {
  72960. defaultButton: {
  72961. "valueNodeName": string;
  72962. "unpressedNodeName": string;
  72963. "pressedNodeName": string;
  72964. };
  72965. defaultAxis: {
  72966. "valueNodeName": string;
  72967. "minNodeName": string;
  72968. "maxNodeName": string;
  72969. };
  72970. buttons: {
  72971. "xr-standard-trigger": {
  72972. "rootNodeName": string;
  72973. "componentProperty": string;
  72974. "states": string[];
  72975. };
  72976. "xr-standard-squeeze": {
  72977. "rootNodeName": string;
  72978. "componentProperty": string;
  72979. "states": string[];
  72980. };
  72981. "xr-standard-touchpad": {
  72982. "rootNodeName": string;
  72983. "labelAnchorNodeName": string;
  72984. "touchPointNodeName": string;
  72985. };
  72986. "xr-standard-thumbstick": {
  72987. "rootNodeName": string;
  72988. "componentProperty": string;
  72989. "states": string[];
  72990. };
  72991. };
  72992. axes: {
  72993. "xr-standard-touchpad": {
  72994. "x-axis": {
  72995. "rootNodeName": string;
  72996. };
  72997. "y-axis": {
  72998. "rootNodeName": string;
  72999. };
  73000. };
  73001. "xr-standard-thumbstick": {
  73002. "x-axis": {
  73003. "rootNodeName": string;
  73004. };
  73005. "y-axis": {
  73006. "rootNodeName": string;
  73007. };
  73008. };
  73009. };
  73010. };
  73011. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73012. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73013. protected _getFilenameAndPath(): {
  73014. filename: string;
  73015. path: string;
  73016. };
  73017. protected _updateModel(): void;
  73018. protected _getModelLoadingConstraints(): boolean;
  73019. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73020. }
  73021. }
  73022. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73023. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73025. import { Scene } from "babylonjs/scene";
  73026. /**
  73027. * The motion controller class for oculus touch (quest, rift).
  73028. * This class supports legacy mapping as well the standard xr mapping
  73029. */
  73030. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73031. private _forceLegacyControllers;
  73032. /**
  73033. * The base url used to load the left and right controller models
  73034. */
  73035. static MODEL_BASE_URL: string;
  73036. /**
  73037. * The name of the left controller model file
  73038. */
  73039. static MODEL_LEFT_FILENAME: string;
  73040. /**
  73041. * The name of the right controller model file
  73042. */
  73043. static MODEL_RIGHT_FILENAME: string;
  73044. /**
  73045. * Base Url for the Quest controller model.
  73046. */
  73047. static QUEST_MODEL_BASE_URL: string;
  73048. profileId: string;
  73049. private _modelRootNode;
  73050. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73051. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73052. protected _getFilenameAndPath(): {
  73053. filename: string;
  73054. path: string;
  73055. };
  73056. /**
  73057. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73058. * between the touch and touch 2.
  73059. */
  73060. private _isQuest;
  73061. protected _updateModel(): void;
  73062. protected _getModelLoadingConstraints(): boolean;
  73063. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73064. }
  73065. }
  73066. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73067. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73068. import { Scene } from "babylonjs/scene";
  73069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73070. /**
  73071. * The motion controller class for the standard HTC-Vive controllers
  73072. */
  73073. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73074. /**
  73075. * The base url used to load the left and right controller models
  73076. */
  73077. static MODEL_BASE_URL: string;
  73078. /**
  73079. * File name for the controller model.
  73080. */
  73081. static MODEL_FILENAME: string;
  73082. profileId: string;
  73083. private _modelRootNode;
  73084. /**
  73085. * Create a new Vive motion controller object
  73086. * @param scene the scene to use to create this controller
  73087. * @param gamepadObject the corresponding gamepad object
  73088. * @param handness the handness of the controller
  73089. */
  73090. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73091. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73092. protected _getFilenameAndPath(): {
  73093. filename: string;
  73094. path: string;
  73095. };
  73096. protected _updateModel(): void;
  73097. protected _getModelLoadingConstraints(): boolean;
  73098. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73099. }
  73100. }
  73101. declare module "babylonjs/XR/motionController/index" {
  73102. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73103. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73104. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73105. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73106. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73107. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73108. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73109. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73110. }
  73111. declare module "babylonjs/XR/index" {
  73112. export * from "babylonjs/XR/webXRCamera";
  73113. export * from "babylonjs/XR/webXREnterExitUI";
  73114. export * from "babylonjs/XR/webXRExperienceHelper";
  73115. export * from "babylonjs/XR/webXRInput";
  73116. export * from "babylonjs/XR/webXRInputSource";
  73117. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73118. export * from "babylonjs/XR/webXRTypes";
  73119. export * from "babylonjs/XR/webXRSessionManager";
  73120. export * from "babylonjs/XR/webXRDefaultExperience";
  73121. export * from "babylonjs/XR/webXRFeaturesManager";
  73122. export * from "babylonjs/XR/features/index";
  73123. export * from "babylonjs/XR/motionController/index";
  73124. }
  73125. declare module "babylonjs/index" {
  73126. export * from "babylonjs/abstractScene";
  73127. export * from "babylonjs/Actions/index";
  73128. export * from "babylonjs/Animations/index";
  73129. export * from "babylonjs/assetContainer";
  73130. export * from "babylonjs/Audio/index";
  73131. export * from "babylonjs/Behaviors/index";
  73132. export * from "babylonjs/Bones/index";
  73133. export * from "babylonjs/Cameras/index";
  73134. export * from "babylonjs/Collisions/index";
  73135. export * from "babylonjs/Culling/index";
  73136. export * from "babylonjs/Debug/index";
  73137. export * from "babylonjs/Engines/index";
  73138. export * from "babylonjs/Events/index";
  73139. export * from "babylonjs/Gamepads/index";
  73140. export * from "babylonjs/Gizmos/index";
  73141. export * from "babylonjs/Helpers/index";
  73142. export * from "babylonjs/Instrumentation/index";
  73143. export * from "babylonjs/Layers/index";
  73144. export * from "babylonjs/LensFlares/index";
  73145. export * from "babylonjs/Lights/index";
  73146. export * from "babylonjs/Loading/index";
  73147. export * from "babylonjs/Materials/index";
  73148. export * from "babylonjs/Maths/index";
  73149. export * from "babylonjs/Meshes/index";
  73150. export * from "babylonjs/Morph/index";
  73151. export * from "babylonjs/Navigation/index";
  73152. export * from "babylonjs/node";
  73153. export * from "babylonjs/Offline/index";
  73154. export * from "babylonjs/Particles/index";
  73155. export * from "babylonjs/Physics/index";
  73156. export * from "babylonjs/PostProcesses/index";
  73157. export * from "babylonjs/Probes/index";
  73158. export * from "babylonjs/Rendering/index";
  73159. export * from "babylonjs/scene";
  73160. export * from "babylonjs/sceneComponent";
  73161. export * from "babylonjs/Sprites/index";
  73162. export * from "babylonjs/States/index";
  73163. export * from "babylonjs/Misc/index";
  73164. export * from "babylonjs/XR/index";
  73165. export * from "babylonjs/types";
  73166. }
  73167. declare module "babylonjs/Animations/pathCursor" {
  73168. import { Vector3 } from "babylonjs/Maths/math.vector";
  73169. import { Path2 } from "babylonjs/Maths/math.path";
  73170. /**
  73171. * A cursor which tracks a point on a path
  73172. */
  73173. export class PathCursor {
  73174. private path;
  73175. /**
  73176. * Stores path cursor callbacks for when an onchange event is triggered
  73177. */
  73178. private _onchange;
  73179. /**
  73180. * The value of the path cursor
  73181. */
  73182. value: number;
  73183. /**
  73184. * The animation array of the path cursor
  73185. */
  73186. animations: Animation[];
  73187. /**
  73188. * Initializes the path cursor
  73189. * @param path The path to track
  73190. */
  73191. constructor(path: Path2);
  73192. /**
  73193. * Gets the cursor point on the path
  73194. * @returns A point on the path cursor at the cursor location
  73195. */
  73196. getPoint(): Vector3;
  73197. /**
  73198. * Moves the cursor ahead by the step amount
  73199. * @param step The amount to move the cursor forward
  73200. * @returns This path cursor
  73201. */
  73202. moveAhead(step?: number): PathCursor;
  73203. /**
  73204. * Moves the cursor behind by the step amount
  73205. * @param step The amount to move the cursor back
  73206. * @returns This path cursor
  73207. */
  73208. moveBack(step?: number): PathCursor;
  73209. /**
  73210. * Moves the cursor by the step amount
  73211. * If the step amount is greater than one, an exception is thrown
  73212. * @param step The amount to move the cursor
  73213. * @returns This path cursor
  73214. */
  73215. move(step: number): PathCursor;
  73216. /**
  73217. * Ensures that the value is limited between zero and one
  73218. * @returns This path cursor
  73219. */
  73220. private ensureLimits;
  73221. /**
  73222. * Runs onchange callbacks on change (used by the animation engine)
  73223. * @returns This path cursor
  73224. */
  73225. private raiseOnChange;
  73226. /**
  73227. * Executes a function on change
  73228. * @param f A path cursor onchange callback
  73229. * @returns This path cursor
  73230. */
  73231. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73232. }
  73233. }
  73234. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73235. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73236. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73237. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73238. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73239. }
  73240. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73241. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73242. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73243. }
  73244. declare module "babylonjs/Engines/Processors/index" {
  73245. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73246. export * from "babylonjs/Engines/Processors/Expressions/index";
  73247. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73248. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73249. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73250. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73251. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73252. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73253. }
  73254. declare module "babylonjs/Legacy/legacy" {
  73255. import * as Babylon from "babylonjs/index";
  73256. export * from "babylonjs/index";
  73257. }
  73258. declare module "babylonjs/Shaders/blur.fragment" {
  73259. /** @hidden */
  73260. export var blurPixelShader: {
  73261. name: string;
  73262. shader: string;
  73263. };
  73264. }
  73265. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73266. /** @hidden */
  73267. export var pointCloudVertexDeclaration: {
  73268. name: string;
  73269. shader: string;
  73270. };
  73271. }
  73272. declare module "babylonjs" {
  73273. export * from "babylonjs/Legacy/legacy";
  73274. }
  73275. declare module BABYLON {
  73276. /** Alias type for value that can be null */
  73277. export type Nullable<T> = T | null;
  73278. /**
  73279. * Alias type for number that are floats
  73280. * @ignorenaming
  73281. */
  73282. export type float = number;
  73283. /**
  73284. * Alias type for number that are doubles.
  73285. * @ignorenaming
  73286. */
  73287. export type double = number;
  73288. /**
  73289. * Alias type for number that are integer
  73290. * @ignorenaming
  73291. */
  73292. export type int = number;
  73293. /** Alias type for number array or Float32Array */
  73294. export type FloatArray = number[] | Float32Array;
  73295. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73296. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73297. /**
  73298. * Alias for types that can be used by a Buffer or VertexBuffer.
  73299. */
  73300. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73301. /**
  73302. * Alias type for primitive types
  73303. * @ignorenaming
  73304. */
  73305. type Primitive = undefined | null | boolean | string | number | Function;
  73306. /**
  73307. * Type modifier to make all the properties of an object Readonly
  73308. */
  73309. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73310. /**
  73311. * Type modifier to make all the properties of an object Readonly recursively
  73312. */
  73313. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73314. /**
  73315. * Type modifier to make object properties readonly.
  73316. */
  73317. export type DeepImmutableObject<T> = {
  73318. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73319. };
  73320. /** @hidden */
  73321. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73322. }
  73323. }
  73324. declare module BABYLON {
  73325. /**
  73326. * A class serves as a medium between the observable and its observers
  73327. */
  73328. export class EventState {
  73329. /**
  73330. * Create a new EventState
  73331. * @param mask defines the mask associated with this state
  73332. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73333. * @param target defines the original target of the state
  73334. * @param currentTarget defines the current target of the state
  73335. */
  73336. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73337. /**
  73338. * Initialize the current event state
  73339. * @param mask defines the mask associated with this state
  73340. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73341. * @param target defines the original target of the state
  73342. * @param currentTarget defines the current target of the state
  73343. * @returns the current event state
  73344. */
  73345. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73346. /**
  73347. * An Observer can set this property to true to prevent subsequent observers of being notified
  73348. */
  73349. skipNextObservers: boolean;
  73350. /**
  73351. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73352. */
  73353. mask: number;
  73354. /**
  73355. * The object that originally notified the event
  73356. */
  73357. target?: any;
  73358. /**
  73359. * The current object in the bubbling phase
  73360. */
  73361. currentTarget?: any;
  73362. /**
  73363. * This will be populated with the return value of the last function that was executed.
  73364. * If it is the first function in the callback chain it will be the event data.
  73365. */
  73366. lastReturnValue?: any;
  73367. }
  73368. /**
  73369. * Represent an Observer registered to a given Observable object.
  73370. */
  73371. export class Observer<T> {
  73372. /**
  73373. * Defines the callback to call when the observer is notified
  73374. */
  73375. callback: (eventData: T, eventState: EventState) => void;
  73376. /**
  73377. * Defines the mask of the observer (used to filter notifications)
  73378. */
  73379. mask: number;
  73380. /**
  73381. * Defines the current scope used to restore the JS context
  73382. */
  73383. scope: any;
  73384. /** @hidden */
  73385. _willBeUnregistered: boolean;
  73386. /**
  73387. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73388. */
  73389. unregisterOnNextCall: boolean;
  73390. /**
  73391. * Creates a new observer
  73392. * @param callback defines the callback to call when the observer is notified
  73393. * @param mask defines the mask of the observer (used to filter notifications)
  73394. * @param scope defines the current scope used to restore the JS context
  73395. */
  73396. constructor(
  73397. /**
  73398. * Defines the callback to call when the observer is notified
  73399. */
  73400. callback: (eventData: T, eventState: EventState) => void,
  73401. /**
  73402. * Defines the mask of the observer (used to filter notifications)
  73403. */
  73404. mask: number,
  73405. /**
  73406. * Defines the current scope used to restore the JS context
  73407. */
  73408. scope?: any);
  73409. }
  73410. /**
  73411. * Represent a list of observers registered to multiple Observables object.
  73412. */
  73413. export class MultiObserver<T> {
  73414. private _observers;
  73415. private _observables;
  73416. /**
  73417. * Release associated resources
  73418. */
  73419. dispose(): void;
  73420. /**
  73421. * Raise a callback when one of the observable will notify
  73422. * @param observables defines a list of observables to watch
  73423. * @param callback defines the callback to call on notification
  73424. * @param mask defines the mask used to filter notifications
  73425. * @param scope defines the current scope used to restore the JS context
  73426. * @returns the new MultiObserver
  73427. */
  73428. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73429. }
  73430. /**
  73431. * The Observable class is a simple implementation of the Observable pattern.
  73432. *
  73433. * 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.
  73434. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73435. * 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).
  73436. * 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.
  73437. */
  73438. export class Observable<T> {
  73439. private _observers;
  73440. private _eventState;
  73441. private _onObserverAdded;
  73442. /**
  73443. * Gets the list of observers
  73444. */
  73445. get observers(): Array<Observer<T>>;
  73446. /**
  73447. * Creates a new observable
  73448. * @param onObserverAdded defines a callback to call when a new observer is added
  73449. */
  73450. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73451. /**
  73452. * Create a new Observer with the specified callback
  73453. * @param callback the callback that will be executed for that Observer
  73454. * @param mask the mask used to filter observers
  73455. * @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.
  73456. * @param scope optional scope for the callback to be called from
  73457. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73458. * @returns the new observer created for the callback
  73459. */
  73460. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73461. /**
  73462. * Create a new Observer with the specified callback and unregisters after the next notification
  73463. * @param callback the callback that will be executed for that Observer
  73464. * @returns the new observer created for the callback
  73465. */
  73466. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73467. /**
  73468. * Remove an Observer from the Observable object
  73469. * @param observer the instance of the Observer to remove
  73470. * @returns false if it doesn't belong to this Observable
  73471. */
  73472. remove(observer: Nullable<Observer<T>>): boolean;
  73473. /**
  73474. * Remove a callback from the Observable object
  73475. * @param callback the callback to remove
  73476. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73477. * @returns false if it doesn't belong to this Observable
  73478. */
  73479. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73480. private _deferUnregister;
  73481. private _remove;
  73482. /**
  73483. * Moves the observable to the top of the observer list making it get called first when notified
  73484. * @param observer the observer to move
  73485. */
  73486. makeObserverTopPriority(observer: Observer<T>): void;
  73487. /**
  73488. * Moves the observable to the bottom of the observer list making it get called last when notified
  73489. * @param observer the observer to move
  73490. */
  73491. makeObserverBottomPriority(observer: Observer<T>): void;
  73492. /**
  73493. * Notify all Observers by calling their respective callback with the given data
  73494. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73495. * @param eventData defines the data to send to all observers
  73496. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73497. * @param target defines the original target of the state
  73498. * @param currentTarget defines the current target of the state
  73499. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73500. */
  73501. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73502. /**
  73503. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73504. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73505. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73506. * and it is crucial that all callbacks will be executed.
  73507. * The order of the callbacks is kept, callbacks are not executed parallel.
  73508. *
  73509. * @param eventData The data to be sent to each callback
  73510. * @param mask is used to filter observers defaults to -1
  73511. * @param target defines the callback target (see EventState)
  73512. * @param currentTarget defines he current object in the bubbling phase
  73513. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73514. */
  73515. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73516. /**
  73517. * Notify a specific observer
  73518. * @param observer defines the observer to notify
  73519. * @param eventData defines the data to be sent to each callback
  73520. * @param mask is used to filter observers defaults to -1
  73521. */
  73522. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73523. /**
  73524. * Gets a boolean indicating if the observable has at least one observer
  73525. * @returns true is the Observable has at least one Observer registered
  73526. */
  73527. hasObservers(): boolean;
  73528. /**
  73529. * Clear the list of observers
  73530. */
  73531. clear(): void;
  73532. /**
  73533. * Clone the current observable
  73534. * @returns a new observable
  73535. */
  73536. clone(): Observable<T>;
  73537. /**
  73538. * Does this observable handles observer registered with a given mask
  73539. * @param mask defines the mask to be tested
  73540. * @return whether or not one observer registered with the given mask is handeled
  73541. **/
  73542. hasSpecificMask(mask?: number): boolean;
  73543. }
  73544. }
  73545. declare module BABYLON {
  73546. /**
  73547. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73548. * Babylon.js
  73549. */
  73550. export class DomManagement {
  73551. /**
  73552. * Checks if the window object exists
  73553. * @returns true if the window object exists
  73554. */
  73555. static IsWindowObjectExist(): boolean;
  73556. /**
  73557. * Checks if the navigator object exists
  73558. * @returns true if the navigator object exists
  73559. */
  73560. static IsNavigatorAvailable(): boolean;
  73561. /**
  73562. * Extracts text content from a DOM element hierarchy
  73563. * @param element defines the root element
  73564. * @returns a string
  73565. */
  73566. static GetDOMTextContent(element: HTMLElement): string;
  73567. }
  73568. }
  73569. declare module BABYLON {
  73570. /**
  73571. * Logger used througouht the application to allow configuration of
  73572. * the log level required for the messages.
  73573. */
  73574. export class Logger {
  73575. /**
  73576. * No log
  73577. */
  73578. static readonly NoneLogLevel: number;
  73579. /**
  73580. * Only message logs
  73581. */
  73582. static readonly MessageLogLevel: number;
  73583. /**
  73584. * Only warning logs
  73585. */
  73586. static readonly WarningLogLevel: number;
  73587. /**
  73588. * Only error logs
  73589. */
  73590. static readonly ErrorLogLevel: number;
  73591. /**
  73592. * All logs
  73593. */
  73594. static readonly AllLogLevel: number;
  73595. private static _LogCache;
  73596. /**
  73597. * Gets a value indicating the number of loading errors
  73598. * @ignorenaming
  73599. */
  73600. static errorsCount: number;
  73601. /**
  73602. * Callback called when a new log is added
  73603. */
  73604. static OnNewCacheEntry: (entry: string) => void;
  73605. private static _AddLogEntry;
  73606. private static _FormatMessage;
  73607. private static _LogDisabled;
  73608. private static _LogEnabled;
  73609. private static _WarnDisabled;
  73610. private static _WarnEnabled;
  73611. private static _ErrorDisabled;
  73612. private static _ErrorEnabled;
  73613. /**
  73614. * Log a message to the console
  73615. */
  73616. static Log: (message: string) => void;
  73617. /**
  73618. * Write a warning message to the console
  73619. */
  73620. static Warn: (message: string) => void;
  73621. /**
  73622. * Write an error message to the console
  73623. */
  73624. static Error: (message: string) => void;
  73625. /**
  73626. * Gets current log cache (list of logs)
  73627. */
  73628. static get LogCache(): string;
  73629. /**
  73630. * Clears the log cache
  73631. */
  73632. static ClearLogCache(): void;
  73633. /**
  73634. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73635. */
  73636. static set LogLevels(level: number);
  73637. }
  73638. }
  73639. declare module BABYLON {
  73640. /** @hidden */
  73641. export class _TypeStore {
  73642. /** @hidden */
  73643. static RegisteredTypes: {
  73644. [key: string]: Object;
  73645. };
  73646. /** @hidden */
  73647. static GetClass(fqdn: string): any;
  73648. }
  73649. }
  73650. declare module BABYLON {
  73651. /**
  73652. * Helper to manipulate strings
  73653. */
  73654. export class StringTools {
  73655. /**
  73656. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73657. * @param str Source string
  73658. * @param suffix Suffix to search for in the source string
  73659. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73660. */
  73661. static EndsWith(str: string, suffix: string): boolean;
  73662. /**
  73663. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73664. * @param str Source string
  73665. * @param suffix Suffix to search for in the source string
  73666. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73667. */
  73668. static StartsWith(str: string, suffix: string): boolean;
  73669. /**
  73670. * Decodes a buffer into a string
  73671. * @param buffer The buffer to decode
  73672. * @returns The decoded string
  73673. */
  73674. static Decode(buffer: Uint8Array | Uint16Array): string;
  73675. /**
  73676. * Encode a buffer to a base64 string
  73677. * @param buffer defines the buffer to encode
  73678. * @returns the encoded string
  73679. */
  73680. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73681. }
  73682. }
  73683. declare module BABYLON {
  73684. /**
  73685. * Class containing a set of static utilities functions for deep copy.
  73686. */
  73687. export class DeepCopier {
  73688. /**
  73689. * Tries to copy an object by duplicating every property
  73690. * @param source defines the source object
  73691. * @param destination defines the target object
  73692. * @param doNotCopyList defines a list of properties to avoid
  73693. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73694. */
  73695. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73696. }
  73697. }
  73698. declare module BABYLON {
  73699. /**
  73700. * Class containing a set of static utilities functions for precision date
  73701. */
  73702. export class PrecisionDate {
  73703. /**
  73704. * Gets either window.performance.now() if supported or Date.now() else
  73705. */
  73706. static get Now(): number;
  73707. }
  73708. }
  73709. declare module BABYLON {
  73710. /** @hidden */
  73711. export class _DevTools {
  73712. static WarnImport(name: string): string;
  73713. }
  73714. }
  73715. declare module BABYLON {
  73716. /**
  73717. * Interface used to define the mechanism to get data from the network
  73718. */
  73719. export interface IWebRequest {
  73720. /**
  73721. * Returns client's response url
  73722. */
  73723. responseURL: string;
  73724. /**
  73725. * Returns client's status
  73726. */
  73727. status: number;
  73728. /**
  73729. * Returns client's status as a text
  73730. */
  73731. statusText: string;
  73732. }
  73733. }
  73734. declare module BABYLON {
  73735. /**
  73736. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73737. */
  73738. export class WebRequest implements IWebRequest {
  73739. private _xhr;
  73740. /**
  73741. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73742. * i.e. when loading files, where the server/service expects an Authorization header
  73743. */
  73744. static CustomRequestHeaders: {
  73745. [key: string]: string;
  73746. };
  73747. /**
  73748. * Add callback functions in this array to update all the requests before they get sent to the network
  73749. */
  73750. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73751. private _injectCustomRequestHeaders;
  73752. /**
  73753. * Gets or sets a function to be called when loading progress changes
  73754. */
  73755. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73756. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73757. /**
  73758. * Returns client's state
  73759. */
  73760. get readyState(): number;
  73761. /**
  73762. * Returns client's status
  73763. */
  73764. get status(): number;
  73765. /**
  73766. * Returns client's status as a text
  73767. */
  73768. get statusText(): string;
  73769. /**
  73770. * Returns client's response
  73771. */
  73772. get response(): any;
  73773. /**
  73774. * Returns client's response url
  73775. */
  73776. get responseURL(): string;
  73777. /**
  73778. * Returns client's response as text
  73779. */
  73780. get responseText(): string;
  73781. /**
  73782. * Gets or sets the expected response type
  73783. */
  73784. get responseType(): XMLHttpRequestResponseType;
  73785. set responseType(value: XMLHttpRequestResponseType);
  73786. /** @hidden */
  73787. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73788. /** @hidden */
  73789. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73790. /**
  73791. * Cancels any network activity
  73792. */
  73793. abort(): void;
  73794. /**
  73795. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73796. * @param body defines an optional request body
  73797. */
  73798. send(body?: Document | BodyInit | null): void;
  73799. /**
  73800. * Sets the request method, request URL
  73801. * @param method defines the method to use (GET, POST, etc..)
  73802. * @param url defines the url to connect with
  73803. */
  73804. open(method: string, url: string): void;
  73805. /**
  73806. * Sets the value of a request header.
  73807. * @param name The name of the header whose value is to be set
  73808. * @param value The value to set as the body of the header
  73809. */
  73810. setRequestHeader(name: string, value: string): void;
  73811. /**
  73812. * Get the string containing the text of a particular header's value.
  73813. * @param name The name of the header
  73814. * @returns The string containing the text of the given header name
  73815. */
  73816. getResponseHeader(name: string): Nullable<string>;
  73817. }
  73818. }
  73819. declare module BABYLON {
  73820. /**
  73821. * File request interface
  73822. */
  73823. export interface IFileRequest {
  73824. /**
  73825. * Raised when the request is complete (success or error).
  73826. */
  73827. onCompleteObservable: Observable<IFileRequest>;
  73828. /**
  73829. * Aborts the request for a file.
  73830. */
  73831. abort: () => void;
  73832. }
  73833. }
  73834. declare module BABYLON {
  73835. /**
  73836. * Define options used to create a render target texture
  73837. */
  73838. export class RenderTargetCreationOptions {
  73839. /**
  73840. * Specifies is mipmaps must be generated
  73841. */
  73842. generateMipMaps?: boolean;
  73843. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73844. generateDepthBuffer?: boolean;
  73845. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73846. generateStencilBuffer?: boolean;
  73847. /** Defines texture type (int by default) */
  73848. type?: number;
  73849. /** Defines sampling mode (trilinear by default) */
  73850. samplingMode?: number;
  73851. /** Defines format (RGBA by default) */
  73852. format?: number;
  73853. }
  73854. }
  73855. declare module BABYLON {
  73856. /** Defines the cross module used constants to avoid circular dependncies */
  73857. export class Constants {
  73858. /** Defines that alpha blending is disabled */
  73859. static readonly ALPHA_DISABLE: number;
  73860. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73861. static readonly ALPHA_ADD: number;
  73862. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73863. static readonly ALPHA_COMBINE: number;
  73864. /** Defines that alpha blending is DEST - SRC * DEST */
  73865. static readonly ALPHA_SUBTRACT: number;
  73866. /** Defines that alpha blending is SRC * DEST */
  73867. static readonly ALPHA_MULTIPLY: number;
  73868. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73869. static readonly ALPHA_MAXIMIZED: number;
  73870. /** Defines that alpha blending is SRC + DEST */
  73871. static readonly ALPHA_ONEONE: number;
  73872. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73873. static readonly ALPHA_PREMULTIPLIED: number;
  73874. /**
  73875. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73876. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73877. */
  73878. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73879. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73880. static readonly ALPHA_INTERPOLATE: number;
  73881. /**
  73882. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73883. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73884. */
  73885. static readonly ALPHA_SCREENMODE: number;
  73886. /**
  73887. * Defines that alpha blending is SRC + DST
  73888. * Alpha will be set to SRC ALPHA + DST ALPHA
  73889. */
  73890. static readonly ALPHA_ONEONE_ONEONE: number;
  73891. /**
  73892. * Defines that alpha blending is SRC * DST ALPHA + DST
  73893. * Alpha will be set to 0
  73894. */
  73895. static readonly ALPHA_ALPHATOCOLOR: number;
  73896. /**
  73897. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73898. */
  73899. static readonly ALPHA_REVERSEONEMINUS: number;
  73900. /**
  73901. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73902. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73903. */
  73904. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73905. /**
  73906. * Defines that alpha blending is SRC + DST
  73907. * Alpha will be set to SRC ALPHA
  73908. */
  73909. static readonly ALPHA_ONEONE_ONEZERO: number;
  73910. /**
  73911. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73912. * Alpha will be set to DST ALPHA
  73913. */
  73914. static readonly ALPHA_EXCLUSION: number;
  73915. /** Defines that alpha blending equation a SUM */
  73916. static readonly ALPHA_EQUATION_ADD: number;
  73917. /** Defines that alpha blending equation a SUBSTRACTION */
  73918. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73919. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73920. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73921. /** Defines that alpha blending equation a MAX operation */
  73922. static readonly ALPHA_EQUATION_MAX: number;
  73923. /** Defines that alpha blending equation a MIN operation */
  73924. static readonly ALPHA_EQUATION_MIN: number;
  73925. /**
  73926. * Defines that alpha blending equation a DARKEN operation:
  73927. * It takes the min of the src and sums the alpha channels.
  73928. */
  73929. static readonly ALPHA_EQUATION_DARKEN: number;
  73930. /** Defines that the ressource is not delayed*/
  73931. static readonly DELAYLOADSTATE_NONE: number;
  73932. /** Defines that the ressource was successfully delay loaded */
  73933. static readonly DELAYLOADSTATE_LOADED: number;
  73934. /** Defines that the ressource is currently delay loading */
  73935. static readonly DELAYLOADSTATE_LOADING: number;
  73936. /** Defines that the ressource is delayed and has not started loading */
  73937. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73939. static readonly NEVER: number;
  73940. /** 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 */
  73941. static readonly ALWAYS: number;
  73942. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73943. static readonly LESS: number;
  73944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73945. static readonly EQUAL: number;
  73946. /** 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 */
  73947. static readonly LEQUAL: number;
  73948. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73949. static readonly GREATER: number;
  73950. /** 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 */
  73951. static readonly GEQUAL: number;
  73952. /** 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 */
  73953. static readonly NOTEQUAL: number;
  73954. /** Passed to stencilOperation to specify that stencil value must be kept */
  73955. static readonly KEEP: number;
  73956. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73957. static readonly REPLACE: number;
  73958. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73959. static readonly INCR: number;
  73960. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73961. static readonly DECR: number;
  73962. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73963. static readonly INVERT: number;
  73964. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73965. static readonly INCR_WRAP: number;
  73966. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73967. static readonly DECR_WRAP: number;
  73968. /** Texture is not repeating outside of 0..1 UVs */
  73969. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73970. /** Texture is repeating outside of 0..1 UVs */
  73971. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73972. /** Texture is repeating and mirrored */
  73973. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73974. /** ALPHA */
  73975. static readonly TEXTUREFORMAT_ALPHA: number;
  73976. /** LUMINANCE */
  73977. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73978. /** LUMINANCE_ALPHA */
  73979. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73980. /** RGB */
  73981. static readonly TEXTUREFORMAT_RGB: number;
  73982. /** RGBA */
  73983. static readonly TEXTUREFORMAT_RGBA: number;
  73984. /** RED */
  73985. static readonly TEXTUREFORMAT_RED: number;
  73986. /** RED (2nd reference) */
  73987. static readonly TEXTUREFORMAT_R: number;
  73988. /** RG */
  73989. static readonly TEXTUREFORMAT_RG: number;
  73990. /** RED_INTEGER */
  73991. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73992. /** RED_INTEGER (2nd reference) */
  73993. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73994. /** RG_INTEGER */
  73995. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73996. /** RGB_INTEGER */
  73997. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73998. /** RGBA_INTEGER */
  73999. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74000. /** UNSIGNED_BYTE */
  74001. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74002. /** UNSIGNED_BYTE (2nd reference) */
  74003. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74004. /** FLOAT */
  74005. static readonly TEXTURETYPE_FLOAT: number;
  74006. /** HALF_FLOAT */
  74007. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74008. /** BYTE */
  74009. static readonly TEXTURETYPE_BYTE: number;
  74010. /** SHORT */
  74011. static readonly TEXTURETYPE_SHORT: number;
  74012. /** UNSIGNED_SHORT */
  74013. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74014. /** INT */
  74015. static readonly TEXTURETYPE_INT: number;
  74016. /** UNSIGNED_INT */
  74017. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74018. /** UNSIGNED_SHORT_4_4_4_4 */
  74019. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74020. /** UNSIGNED_SHORT_5_5_5_1 */
  74021. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74022. /** UNSIGNED_SHORT_5_6_5 */
  74023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74024. /** UNSIGNED_INT_2_10_10_10_REV */
  74025. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74026. /** UNSIGNED_INT_24_8 */
  74027. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74028. /** UNSIGNED_INT_10F_11F_11F_REV */
  74029. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74030. /** UNSIGNED_INT_5_9_9_9_REV */
  74031. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74032. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74033. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74034. /** nearest is mag = nearest and min = nearest and no mip */
  74035. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74036. /** mag = nearest and min = nearest and mip = none */
  74037. static readonly TEXTURE_NEAREST_NEAREST: number;
  74038. /** Bilinear is mag = linear and min = linear and no mip */
  74039. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74040. /** mag = linear and min = linear and mip = none */
  74041. static readonly TEXTURE_LINEAR_LINEAR: number;
  74042. /** Trilinear is mag = linear and min = linear and mip = linear */
  74043. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74044. /** Trilinear is mag = linear and min = linear and mip = linear */
  74045. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74046. /** mag = nearest and min = nearest and mip = nearest */
  74047. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74048. /** mag = nearest and min = linear and mip = nearest */
  74049. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74050. /** mag = nearest and min = linear and mip = linear */
  74051. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74052. /** mag = nearest and min = linear and mip = none */
  74053. static readonly TEXTURE_NEAREST_LINEAR: number;
  74054. /** nearest is mag = nearest and min = nearest and mip = linear */
  74055. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74056. /** mag = linear and min = nearest and mip = nearest */
  74057. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74058. /** mag = linear and min = nearest and mip = linear */
  74059. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74060. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74061. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74062. /** mag = linear and min = nearest and mip = none */
  74063. static readonly TEXTURE_LINEAR_NEAREST: number;
  74064. /** Explicit coordinates mode */
  74065. static readonly TEXTURE_EXPLICIT_MODE: number;
  74066. /** Spherical coordinates mode */
  74067. static readonly TEXTURE_SPHERICAL_MODE: number;
  74068. /** Planar coordinates mode */
  74069. static readonly TEXTURE_PLANAR_MODE: number;
  74070. /** Cubic coordinates mode */
  74071. static readonly TEXTURE_CUBIC_MODE: number;
  74072. /** Projection coordinates mode */
  74073. static readonly TEXTURE_PROJECTION_MODE: number;
  74074. /** Skybox coordinates mode */
  74075. static readonly TEXTURE_SKYBOX_MODE: number;
  74076. /** Inverse Cubic coordinates mode */
  74077. static readonly TEXTURE_INVCUBIC_MODE: number;
  74078. /** Equirectangular coordinates mode */
  74079. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74080. /** Equirectangular Fixed coordinates mode */
  74081. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74082. /** Equirectangular Fixed Mirrored coordinates mode */
  74083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74084. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74085. static readonly SCALEMODE_FLOOR: number;
  74086. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74087. static readonly SCALEMODE_NEAREST: number;
  74088. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74089. static readonly SCALEMODE_CEILING: number;
  74090. /**
  74091. * The dirty texture flag value
  74092. */
  74093. static readonly MATERIAL_TextureDirtyFlag: number;
  74094. /**
  74095. * The dirty light flag value
  74096. */
  74097. static readonly MATERIAL_LightDirtyFlag: number;
  74098. /**
  74099. * The dirty fresnel flag value
  74100. */
  74101. static readonly MATERIAL_FresnelDirtyFlag: number;
  74102. /**
  74103. * The dirty attribute flag value
  74104. */
  74105. static readonly MATERIAL_AttributesDirtyFlag: number;
  74106. /**
  74107. * The dirty misc flag value
  74108. */
  74109. static readonly MATERIAL_MiscDirtyFlag: number;
  74110. /**
  74111. * The all dirty flag value
  74112. */
  74113. static readonly MATERIAL_AllDirtyFlag: number;
  74114. /**
  74115. * Returns the triangle fill mode
  74116. */
  74117. static readonly MATERIAL_TriangleFillMode: number;
  74118. /**
  74119. * Returns the wireframe mode
  74120. */
  74121. static readonly MATERIAL_WireFrameFillMode: number;
  74122. /**
  74123. * Returns the point fill mode
  74124. */
  74125. static readonly MATERIAL_PointFillMode: number;
  74126. /**
  74127. * Returns the point list draw mode
  74128. */
  74129. static readonly MATERIAL_PointListDrawMode: number;
  74130. /**
  74131. * Returns the line list draw mode
  74132. */
  74133. static readonly MATERIAL_LineListDrawMode: number;
  74134. /**
  74135. * Returns the line loop draw mode
  74136. */
  74137. static readonly MATERIAL_LineLoopDrawMode: number;
  74138. /**
  74139. * Returns the line strip draw mode
  74140. */
  74141. static readonly MATERIAL_LineStripDrawMode: number;
  74142. /**
  74143. * Returns the triangle strip draw mode
  74144. */
  74145. static readonly MATERIAL_TriangleStripDrawMode: number;
  74146. /**
  74147. * Returns the triangle fan draw mode
  74148. */
  74149. static readonly MATERIAL_TriangleFanDrawMode: number;
  74150. /**
  74151. * Stores the clock-wise side orientation
  74152. */
  74153. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74154. /**
  74155. * Stores the counter clock-wise side orientation
  74156. */
  74157. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74158. /**
  74159. * Nothing
  74160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74161. */
  74162. static readonly ACTION_NothingTrigger: number;
  74163. /**
  74164. * On pick
  74165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74166. */
  74167. static readonly ACTION_OnPickTrigger: number;
  74168. /**
  74169. * On left pick
  74170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74171. */
  74172. static readonly ACTION_OnLeftPickTrigger: number;
  74173. /**
  74174. * On right pick
  74175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74176. */
  74177. static readonly ACTION_OnRightPickTrigger: number;
  74178. /**
  74179. * On center pick
  74180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74181. */
  74182. static readonly ACTION_OnCenterPickTrigger: number;
  74183. /**
  74184. * On pick down
  74185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74186. */
  74187. static readonly ACTION_OnPickDownTrigger: number;
  74188. /**
  74189. * On double pick
  74190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74191. */
  74192. static readonly ACTION_OnDoublePickTrigger: number;
  74193. /**
  74194. * On pick up
  74195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74196. */
  74197. static readonly ACTION_OnPickUpTrigger: number;
  74198. /**
  74199. * On pick out.
  74200. * This trigger will only be raised if you also declared a OnPickDown
  74201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74202. */
  74203. static readonly ACTION_OnPickOutTrigger: number;
  74204. /**
  74205. * On long press
  74206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74207. */
  74208. static readonly ACTION_OnLongPressTrigger: number;
  74209. /**
  74210. * On pointer over
  74211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74212. */
  74213. static readonly ACTION_OnPointerOverTrigger: number;
  74214. /**
  74215. * On pointer out
  74216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74217. */
  74218. static readonly ACTION_OnPointerOutTrigger: number;
  74219. /**
  74220. * On every frame
  74221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74222. */
  74223. static readonly ACTION_OnEveryFrameTrigger: number;
  74224. /**
  74225. * On intersection enter
  74226. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74227. */
  74228. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74229. /**
  74230. * On intersection exit
  74231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74232. */
  74233. static readonly ACTION_OnIntersectionExitTrigger: number;
  74234. /**
  74235. * On key down
  74236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74237. */
  74238. static readonly ACTION_OnKeyDownTrigger: number;
  74239. /**
  74240. * On key up
  74241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74242. */
  74243. static readonly ACTION_OnKeyUpTrigger: number;
  74244. /**
  74245. * Billboard mode will only apply to Y axis
  74246. */
  74247. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74248. /**
  74249. * Billboard mode will apply to all axes
  74250. */
  74251. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74252. /**
  74253. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74254. */
  74255. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74256. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74257. * Test order :
  74258. * Is the bounding sphere outside the frustum ?
  74259. * If not, are the bounding box vertices outside the frustum ?
  74260. * It not, then the cullable object is in the frustum.
  74261. */
  74262. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74263. /** Culling strategy : Bounding Sphere Only.
  74264. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74265. * It's also less accurate than the standard because some not visible objects can still be selected.
  74266. * Test : is the bounding sphere outside the frustum ?
  74267. * If not, then the cullable object is in the frustum.
  74268. */
  74269. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74270. /** Culling strategy : Optimistic Inclusion.
  74271. * This in an inclusion test first, then the standard exclusion test.
  74272. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74273. * 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.
  74274. * Anyway, it's as accurate as the standard strategy.
  74275. * Test :
  74276. * Is the cullable object bounding sphere center in the frustum ?
  74277. * If not, apply the default culling strategy.
  74278. */
  74279. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74280. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74281. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74282. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74283. * 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.
  74284. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74285. * Test :
  74286. * Is the cullable object bounding sphere center in the frustum ?
  74287. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74288. */
  74289. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74290. /**
  74291. * No logging while loading
  74292. */
  74293. static readonly SCENELOADER_NO_LOGGING: number;
  74294. /**
  74295. * Minimal logging while loading
  74296. */
  74297. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74298. /**
  74299. * Summary logging while loading
  74300. */
  74301. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74302. /**
  74303. * Detailled logging while loading
  74304. */
  74305. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74306. }
  74307. }
  74308. declare module BABYLON {
  74309. /**
  74310. * This represents the required contract to create a new type of texture loader.
  74311. */
  74312. export interface IInternalTextureLoader {
  74313. /**
  74314. * Defines wether the loader supports cascade loading the different faces.
  74315. */
  74316. supportCascades: boolean;
  74317. /**
  74318. * This returns if the loader support the current file information.
  74319. * @param extension defines the file extension of the file being loaded
  74320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74321. * @param fallback defines the fallback internal texture if any
  74322. * @param isBase64 defines whether the texture is encoded as a base64
  74323. * @param isBuffer defines whether the texture data are stored as a buffer
  74324. * @returns true if the loader can load the specified file
  74325. */
  74326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74327. /**
  74328. * Transform the url before loading if required.
  74329. * @param rootUrl the url of the texture
  74330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74331. * @returns the transformed texture
  74332. */
  74333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74334. /**
  74335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74336. * @param rootUrl the url of the texture
  74337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74338. * @returns the fallback texture
  74339. */
  74340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74341. /**
  74342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74343. * @param data contains the texture data
  74344. * @param texture defines the BabylonJS internal texture
  74345. * @param createPolynomials will be true if polynomials have been requested
  74346. * @param onLoad defines the callback to trigger once the texture is ready
  74347. * @param onError defines the callback to trigger in case of error
  74348. */
  74349. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74350. /**
  74351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74352. * @param data contains the texture data
  74353. * @param texture defines the BabylonJS internal texture
  74354. * @param callback defines the method to call once ready to upload
  74355. */
  74356. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74357. }
  74358. }
  74359. declare module BABYLON {
  74360. /**
  74361. * Class used to store and describe the pipeline context associated with an effect
  74362. */
  74363. export interface IPipelineContext {
  74364. /**
  74365. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74366. */
  74367. isAsync: boolean;
  74368. /**
  74369. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74370. */
  74371. isReady: boolean;
  74372. /** @hidden */
  74373. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74374. }
  74375. }
  74376. declare module BABYLON {
  74377. /**
  74378. * Class used to store gfx data (like WebGLBuffer)
  74379. */
  74380. export class DataBuffer {
  74381. /**
  74382. * Gets or sets the number of objects referencing this buffer
  74383. */
  74384. references: number;
  74385. /** Gets or sets the size of the underlying buffer */
  74386. capacity: number;
  74387. /**
  74388. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74389. */
  74390. is32Bits: boolean;
  74391. /**
  74392. * Gets the underlying buffer
  74393. */
  74394. get underlyingResource(): any;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /** @hidden */
  74399. export interface IShaderProcessor {
  74400. attributeProcessor?: (attribute: string) => string;
  74401. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74402. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74403. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74404. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74405. lineProcessor?: (line: string, isFragment: boolean) => string;
  74406. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74407. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74408. }
  74409. }
  74410. declare module BABYLON {
  74411. /** @hidden */
  74412. export interface ProcessingOptions {
  74413. defines: string[];
  74414. indexParameters: any;
  74415. isFragment: boolean;
  74416. shouldUseHighPrecisionShader: boolean;
  74417. supportsUniformBuffers: boolean;
  74418. shadersRepository: string;
  74419. includesShadersStore: {
  74420. [key: string]: string;
  74421. };
  74422. processor?: IShaderProcessor;
  74423. version: string;
  74424. platformName: string;
  74425. lookForClosingBracketForUniformBuffer?: boolean;
  74426. }
  74427. }
  74428. declare module BABYLON {
  74429. /** @hidden */
  74430. export class ShaderCodeNode {
  74431. line: string;
  74432. children: ShaderCodeNode[];
  74433. additionalDefineKey?: string;
  74434. additionalDefineValue?: string;
  74435. isValid(preprocessors: {
  74436. [key: string]: string;
  74437. }): boolean;
  74438. process(preprocessors: {
  74439. [key: string]: string;
  74440. }, options: ProcessingOptions): string;
  74441. }
  74442. }
  74443. declare module BABYLON {
  74444. /** @hidden */
  74445. export class ShaderCodeCursor {
  74446. private _lines;
  74447. lineIndex: number;
  74448. get currentLine(): string;
  74449. get canRead(): boolean;
  74450. set lines(value: string[]);
  74451. }
  74452. }
  74453. declare module BABYLON {
  74454. /** @hidden */
  74455. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74456. process(preprocessors: {
  74457. [key: string]: string;
  74458. }, options: ProcessingOptions): string;
  74459. }
  74460. }
  74461. declare module BABYLON {
  74462. /** @hidden */
  74463. export class ShaderDefineExpression {
  74464. isTrue(preprocessors: {
  74465. [key: string]: string;
  74466. }): boolean;
  74467. }
  74468. }
  74469. declare module BABYLON {
  74470. /** @hidden */
  74471. export class ShaderCodeTestNode extends ShaderCodeNode {
  74472. testExpression: ShaderDefineExpression;
  74473. isValid(preprocessors: {
  74474. [key: string]: string;
  74475. }): boolean;
  74476. }
  74477. }
  74478. declare module BABYLON {
  74479. /** @hidden */
  74480. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74481. define: string;
  74482. not: boolean;
  74483. constructor(define: string, not?: boolean);
  74484. isTrue(preprocessors: {
  74485. [key: string]: string;
  74486. }): boolean;
  74487. }
  74488. }
  74489. declare module BABYLON {
  74490. /** @hidden */
  74491. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74492. leftOperand: ShaderDefineExpression;
  74493. rightOperand: ShaderDefineExpression;
  74494. isTrue(preprocessors: {
  74495. [key: string]: string;
  74496. }): boolean;
  74497. }
  74498. }
  74499. declare module BABYLON {
  74500. /** @hidden */
  74501. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74502. leftOperand: ShaderDefineExpression;
  74503. rightOperand: ShaderDefineExpression;
  74504. isTrue(preprocessors: {
  74505. [key: string]: string;
  74506. }): boolean;
  74507. }
  74508. }
  74509. declare module BABYLON {
  74510. /** @hidden */
  74511. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74512. define: string;
  74513. operand: string;
  74514. testValue: string;
  74515. constructor(define: string, operand: string, testValue: string);
  74516. isTrue(preprocessors: {
  74517. [key: string]: string;
  74518. }): boolean;
  74519. }
  74520. }
  74521. declare module BABYLON {
  74522. /**
  74523. * Class used to enable access to offline support
  74524. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74525. */
  74526. export interface IOfflineProvider {
  74527. /**
  74528. * Gets a boolean indicating if scene must be saved in the database
  74529. */
  74530. enableSceneOffline: boolean;
  74531. /**
  74532. * Gets a boolean indicating if textures must be saved in the database
  74533. */
  74534. enableTexturesOffline: boolean;
  74535. /**
  74536. * Open the offline support and make it available
  74537. * @param successCallback defines the callback to call on success
  74538. * @param errorCallback defines the callback to call on error
  74539. */
  74540. open(successCallback: () => void, errorCallback: () => void): void;
  74541. /**
  74542. * Loads an image from the offline support
  74543. * @param url defines the url to load from
  74544. * @param image defines the target DOM image
  74545. */
  74546. loadImage(url: string, image: HTMLImageElement): void;
  74547. /**
  74548. * Loads a file from offline support
  74549. * @param url defines the URL to load from
  74550. * @param sceneLoaded defines a callback to call on success
  74551. * @param progressCallBack defines a callback to call when progress changed
  74552. * @param errorCallback defines a callback to call on error
  74553. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74554. */
  74555. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74556. }
  74557. }
  74558. declare module BABYLON {
  74559. /**
  74560. * Class used to help managing file picking and drag'n'drop
  74561. * File Storage
  74562. */
  74563. export class FilesInputStore {
  74564. /**
  74565. * List of files ready to be loaded
  74566. */
  74567. static FilesToLoad: {
  74568. [key: string]: File;
  74569. };
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * Class used to define a retry strategy when error happens while loading assets
  74575. */
  74576. export class RetryStrategy {
  74577. /**
  74578. * Function used to defines an exponential back off strategy
  74579. * @param maxRetries defines the maximum number of retries (3 by default)
  74580. * @param baseInterval defines the interval between retries
  74581. * @returns the strategy function to use
  74582. */
  74583. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74584. }
  74585. }
  74586. declare module BABYLON {
  74587. /**
  74588. * @ignore
  74589. * Application error to support additional information when loading a file
  74590. */
  74591. export abstract class BaseError extends Error {
  74592. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74593. }
  74594. }
  74595. declare module BABYLON {
  74596. /** @ignore */
  74597. export class LoadFileError extends BaseError {
  74598. request?: WebRequest;
  74599. file?: File;
  74600. /**
  74601. * Creates a new LoadFileError
  74602. * @param message defines the message of the error
  74603. * @param request defines the optional web request
  74604. * @param file defines the optional file
  74605. */
  74606. constructor(message: string, object?: WebRequest | File);
  74607. }
  74608. /** @ignore */
  74609. export class RequestFileError extends BaseError {
  74610. request: WebRequest;
  74611. /**
  74612. * Creates a new LoadFileError
  74613. * @param message defines the message of the error
  74614. * @param request defines the optional web request
  74615. */
  74616. constructor(message: string, request: WebRequest);
  74617. }
  74618. /** @ignore */
  74619. export class ReadFileError extends BaseError {
  74620. file: File;
  74621. /**
  74622. * Creates a new ReadFileError
  74623. * @param message defines the message of the error
  74624. * @param file defines the optional file
  74625. */
  74626. constructor(message: string, file: File);
  74627. }
  74628. /**
  74629. * @hidden
  74630. */
  74631. export class FileTools {
  74632. /**
  74633. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74634. */
  74635. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74636. /**
  74637. * Gets or sets the base URL to use to load assets
  74638. */
  74639. static BaseUrl: string;
  74640. /**
  74641. * Default behaviour for cors in the application.
  74642. * It can be a string if the expected behavior is identical in the entire app.
  74643. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74644. */
  74645. static CorsBehavior: string | ((url: string | string[]) => string);
  74646. /**
  74647. * Gets or sets a function used to pre-process url before using them to load assets
  74648. */
  74649. static PreprocessUrl: (url: string) => string;
  74650. /**
  74651. * Removes unwanted characters from an url
  74652. * @param url defines the url to clean
  74653. * @returns the cleaned url
  74654. */
  74655. private static _CleanUrl;
  74656. /**
  74657. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74658. * @param url define the url we are trying
  74659. * @param element define the dom element where to configure the cors policy
  74660. */
  74661. static SetCorsBehavior(url: string | string[], element: {
  74662. crossOrigin: string | null;
  74663. }): void;
  74664. /**
  74665. * Loads an image as an HTMLImageElement.
  74666. * @param input url string, ArrayBuffer, or Blob to load
  74667. * @param onLoad callback called when the image successfully loads
  74668. * @param onError callback called when the image fails to load
  74669. * @param offlineProvider offline provider for caching
  74670. * @param mimeType optional mime type
  74671. * @returns the HTMLImageElement of the loaded image
  74672. */
  74673. 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>;
  74674. /**
  74675. * Reads a file from a File object
  74676. * @param file defines the file to load
  74677. * @param onSuccess defines the callback to call when data is loaded
  74678. * @param onProgress defines the callback to call during loading process
  74679. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74680. * @param onError defines the callback to call when an error occurs
  74681. * @returns a file request object
  74682. */
  74683. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74684. /**
  74685. * Loads a file from a url
  74686. * @param url url to load
  74687. * @param onSuccess callback called when the file successfully loads
  74688. * @param onProgress callback called while file is loading (if the server supports this mode)
  74689. * @param offlineProvider defines the offline provider for caching
  74690. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74691. * @param onError callback called when the file fails to load
  74692. * @returns a file request object
  74693. */
  74694. 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;
  74695. /**
  74696. * Loads a file
  74697. * @param url url to load
  74698. * @param onSuccess callback called when the file successfully loads
  74699. * @param onProgress callback called while file is loading (if the server supports this mode)
  74700. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74701. * @param onError callback called when the file fails to load
  74702. * @param onOpened callback called when the web request is opened
  74703. * @returns a file request object
  74704. */
  74705. 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;
  74706. /**
  74707. * Checks if the loaded document was accessed via `file:`-Protocol.
  74708. * @returns boolean
  74709. */
  74710. static IsFileURL(): boolean;
  74711. }
  74712. }
  74713. declare module BABYLON {
  74714. /** @hidden */
  74715. export class ShaderProcessor {
  74716. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74717. private static _ProcessPrecision;
  74718. private static _ExtractOperation;
  74719. private static _BuildSubExpression;
  74720. private static _BuildExpression;
  74721. private static _MoveCursorWithinIf;
  74722. private static _MoveCursor;
  74723. private static _EvaluatePreProcessors;
  74724. private static _PreparePreProcessors;
  74725. private static _ProcessShaderConversion;
  74726. private static _ProcessIncludes;
  74727. /**
  74728. * Loads a file from a url
  74729. * @param url url to load
  74730. * @param onSuccess callback called when the file successfully loads
  74731. * @param onProgress callback called while file is loading (if the server supports this mode)
  74732. * @param offlineProvider defines the offline provider for caching
  74733. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74734. * @param onError callback called when the file fails to load
  74735. * @returns a file request object
  74736. * @hidden
  74737. */
  74738. 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;
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * @hidden
  74744. */
  74745. export interface IColor4Like {
  74746. r: float;
  74747. g: float;
  74748. b: float;
  74749. a: float;
  74750. }
  74751. /**
  74752. * @hidden
  74753. */
  74754. export interface IColor3Like {
  74755. r: float;
  74756. g: float;
  74757. b: float;
  74758. }
  74759. /**
  74760. * @hidden
  74761. */
  74762. export interface IVector4Like {
  74763. x: float;
  74764. y: float;
  74765. z: float;
  74766. w: float;
  74767. }
  74768. /**
  74769. * @hidden
  74770. */
  74771. export interface IVector3Like {
  74772. x: float;
  74773. y: float;
  74774. z: float;
  74775. }
  74776. /**
  74777. * @hidden
  74778. */
  74779. export interface IVector2Like {
  74780. x: float;
  74781. y: float;
  74782. }
  74783. /**
  74784. * @hidden
  74785. */
  74786. export interface IMatrixLike {
  74787. toArray(): DeepImmutable<Float32Array>;
  74788. updateFlag: int;
  74789. }
  74790. /**
  74791. * @hidden
  74792. */
  74793. export interface IViewportLike {
  74794. x: float;
  74795. y: float;
  74796. width: float;
  74797. height: float;
  74798. }
  74799. /**
  74800. * @hidden
  74801. */
  74802. export interface IPlaneLike {
  74803. normal: IVector3Like;
  74804. d: float;
  74805. normalize(): void;
  74806. }
  74807. }
  74808. declare module BABYLON {
  74809. /**
  74810. * Interface used to define common properties for effect fallbacks
  74811. */
  74812. export interface IEffectFallbacks {
  74813. /**
  74814. * Removes the defines that should be removed when falling back.
  74815. * @param currentDefines defines the current define statements for the shader.
  74816. * @param effect defines the current effect we try to compile
  74817. * @returns The resulting defines with defines of the current rank removed.
  74818. */
  74819. reduce(currentDefines: string, effect: Effect): string;
  74820. /**
  74821. * Removes the fallback from the bound mesh.
  74822. */
  74823. unBindMesh(): void;
  74824. /**
  74825. * Checks to see if more fallbacks are still availible.
  74826. */
  74827. hasMoreFallbacks: boolean;
  74828. }
  74829. }
  74830. declare module BABYLON {
  74831. /**
  74832. * Class used to evalaute queries containing `and` and `or` operators
  74833. */
  74834. export class AndOrNotEvaluator {
  74835. /**
  74836. * Evaluate a query
  74837. * @param query defines the query to evaluate
  74838. * @param evaluateCallback defines the callback used to filter result
  74839. * @returns true if the query matches
  74840. */
  74841. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74842. private static _HandleParenthesisContent;
  74843. private static _SimplifyNegation;
  74844. }
  74845. }
  74846. declare module BABYLON {
  74847. /**
  74848. * Class used to store custom tags
  74849. */
  74850. export class Tags {
  74851. /**
  74852. * Adds support for tags on the given object
  74853. * @param obj defines the object to use
  74854. */
  74855. static EnableFor(obj: any): void;
  74856. /**
  74857. * Removes tags support
  74858. * @param obj defines the object to use
  74859. */
  74860. static DisableFor(obj: any): void;
  74861. /**
  74862. * Gets a boolean indicating if the given object has tags
  74863. * @param obj defines the object to use
  74864. * @returns a boolean
  74865. */
  74866. static HasTags(obj: any): boolean;
  74867. /**
  74868. * Gets the tags available on a given object
  74869. * @param obj defines the object to use
  74870. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74871. * @returns the tags
  74872. */
  74873. static GetTags(obj: any, asString?: boolean): any;
  74874. /**
  74875. * Adds tags to an object
  74876. * @param obj defines the object to use
  74877. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74878. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74879. */
  74880. static AddTagsTo(obj: any, tagsString: string): void;
  74881. /**
  74882. * @hidden
  74883. */
  74884. static _AddTagTo(obj: any, tag: string): void;
  74885. /**
  74886. * Removes specific tags from a specific object
  74887. * @param obj defines the object to use
  74888. * @param tagsString defines the tags to remove
  74889. */
  74890. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74891. /**
  74892. * @hidden
  74893. */
  74894. static _RemoveTagFrom(obj: any, tag: string): void;
  74895. /**
  74896. * Defines if tags hosted on an object match a given query
  74897. * @param obj defines the object to use
  74898. * @param tagsQuery defines the tag query
  74899. * @returns a boolean
  74900. */
  74901. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74902. }
  74903. }
  74904. declare module BABYLON {
  74905. /**
  74906. * Scalar computation library
  74907. */
  74908. export class Scalar {
  74909. /**
  74910. * Two pi constants convenient for computation.
  74911. */
  74912. static TwoPi: number;
  74913. /**
  74914. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74915. * @param a number
  74916. * @param b number
  74917. * @param epsilon (default = 1.401298E-45)
  74918. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74919. */
  74920. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74921. /**
  74922. * Returns a string : the upper case translation of the number i to hexadecimal.
  74923. * @param i number
  74924. * @returns the upper case translation of the number i to hexadecimal.
  74925. */
  74926. static ToHex(i: number): string;
  74927. /**
  74928. * Returns -1 if value is negative and +1 is value is positive.
  74929. * @param value the value
  74930. * @returns the value itself if it's equal to zero.
  74931. */
  74932. static Sign(value: number): number;
  74933. /**
  74934. * Returns the value itself if it's between min and max.
  74935. * Returns min if the value is lower than min.
  74936. * Returns max if the value is greater than max.
  74937. * @param value the value to clmap
  74938. * @param min the min value to clamp to (default: 0)
  74939. * @param max the max value to clamp to (default: 1)
  74940. * @returns the clamped value
  74941. */
  74942. static Clamp(value: number, min?: number, max?: number): number;
  74943. /**
  74944. * the log2 of value.
  74945. * @param value the value to compute log2 of
  74946. * @returns the log2 of value.
  74947. */
  74948. static Log2(value: number): number;
  74949. /**
  74950. * Loops the value, so that it is never larger than length and never smaller than 0.
  74951. *
  74952. * This is similar to the modulo operator but it works with floating point numbers.
  74953. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74954. * With t = 5 and length = 2.5, the result would be 0.0.
  74955. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74956. * @param value the value
  74957. * @param length the length
  74958. * @returns the looped value
  74959. */
  74960. static Repeat(value: number, length: number): number;
  74961. /**
  74962. * Normalize the value between 0.0 and 1.0 using min and max values
  74963. * @param value value to normalize
  74964. * @param min max to normalize between
  74965. * @param max min to normalize between
  74966. * @returns the normalized value
  74967. */
  74968. static Normalize(value: number, min: number, max: number): number;
  74969. /**
  74970. * Denormalize the value from 0.0 and 1.0 using min and max values
  74971. * @param normalized value to denormalize
  74972. * @param min max to denormalize between
  74973. * @param max min to denormalize between
  74974. * @returns the denormalized value
  74975. */
  74976. static Denormalize(normalized: number, min: number, max: number): number;
  74977. /**
  74978. * Calculates the shortest difference between two given angles given in degrees.
  74979. * @param current current angle in degrees
  74980. * @param target target angle in degrees
  74981. * @returns the delta
  74982. */
  74983. static DeltaAngle(current: number, target: number): number;
  74984. /**
  74985. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74986. * @param tx value
  74987. * @param length length
  74988. * @returns The returned value will move back and forth between 0 and length
  74989. */
  74990. static PingPong(tx: number, length: number): number;
  74991. /**
  74992. * Interpolates between min and max with smoothing at the limits.
  74993. *
  74994. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74995. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74996. * @param from from
  74997. * @param to to
  74998. * @param tx value
  74999. * @returns the smooth stepped value
  75000. */
  75001. static SmoothStep(from: number, to: number, tx: number): number;
  75002. /**
  75003. * Moves a value current towards target.
  75004. *
  75005. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75006. * Negative values of maxDelta pushes the value away from target.
  75007. * @param current current value
  75008. * @param target target value
  75009. * @param maxDelta max distance to move
  75010. * @returns resulting value
  75011. */
  75012. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75013. /**
  75014. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75015. *
  75016. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75017. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75018. * @param current current value
  75019. * @param target target value
  75020. * @param maxDelta max distance to move
  75021. * @returns resulting angle
  75022. */
  75023. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75024. /**
  75025. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75026. * @param start start value
  75027. * @param end target value
  75028. * @param amount amount to lerp between
  75029. * @returns the lerped value
  75030. */
  75031. static Lerp(start: number, end: number, amount: number): number;
  75032. /**
  75033. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75034. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75035. * @param start start value
  75036. * @param end target value
  75037. * @param amount amount to lerp between
  75038. * @returns the lerped value
  75039. */
  75040. static LerpAngle(start: number, end: number, amount: number): number;
  75041. /**
  75042. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75043. * @param a start value
  75044. * @param b target value
  75045. * @param value value between a and b
  75046. * @returns the inverseLerp value
  75047. */
  75048. static InverseLerp(a: number, b: number, value: number): number;
  75049. /**
  75050. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75051. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75052. * @param value1 spline value
  75053. * @param tangent1 spline value
  75054. * @param value2 spline value
  75055. * @param tangent2 spline value
  75056. * @param amount input value
  75057. * @returns hermite result
  75058. */
  75059. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75060. /**
  75061. * Returns a random float number between and min and max values
  75062. * @param min min value of random
  75063. * @param max max value of random
  75064. * @returns random value
  75065. */
  75066. static RandomRange(min: number, max: number): number;
  75067. /**
  75068. * This function returns percentage of a number in a given range.
  75069. *
  75070. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75071. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75072. * @param number to convert to percentage
  75073. * @param min min range
  75074. * @param max max range
  75075. * @returns the percentage
  75076. */
  75077. static RangeToPercent(number: number, min: number, max: number): number;
  75078. /**
  75079. * This function returns number that corresponds to the percentage in a given range.
  75080. *
  75081. * PercentToRange(0.34,0,100) will return 34.
  75082. * @param percent to convert to number
  75083. * @param min min range
  75084. * @param max max range
  75085. * @returns the number
  75086. */
  75087. static PercentToRange(percent: number, min: number, max: number): number;
  75088. /**
  75089. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75090. * @param angle The angle to normalize in radian.
  75091. * @return The converted angle.
  75092. */
  75093. static NormalizeRadians(angle: number): number;
  75094. }
  75095. }
  75096. declare module BABYLON {
  75097. /**
  75098. * Constant used to convert a value to gamma space
  75099. * @ignorenaming
  75100. */
  75101. export const ToGammaSpace: number;
  75102. /**
  75103. * Constant used to convert a value to linear space
  75104. * @ignorenaming
  75105. */
  75106. export const ToLinearSpace = 2.2;
  75107. /**
  75108. * Constant used to define the minimal number value in Babylon.js
  75109. * @ignorenaming
  75110. */
  75111. let Epsilon: number;
  75112. }
  75113. declare module BABYLON {
  75114. /**
  75115. * Class used to represent a viewport on screen
  75116. */
  75117. export class Viewport {
  75118. /** viewport left coordinate */
  75119. x: number;
  75120. /** viewport top coordinate */
  75121. y: number;
  75122. /**viewport width */
  75123. width: number;
  75124. /** viewport height */
  75125. height: number;
  75126. /**
  75127. * Creates a Viewport object located at (x, y) and sized (width, height)
  75128. * @param x defines viewport left coordinate
  75129. * @param y defines viewport top coordinate
  75130. * @param width defines the viewport width
  75131. * @param height defines the viewport height
  75132. */
  75133. constructor(
  75134. /** viewport left coordinate */
  75135. x: number,
  75136. /** viewport top coordinate */
  75137. y: number,
  75138. /**viewport width */
  75139. width: number,
  75140. /** viewport height */
  75141. height: number);
  75142. /**
  75143. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75144. * @param renderWidth defines the rendering width
  75145. * @param renderHeight defines the rendering height
  75146. * @returns a new Viewport
  75147. */
  75148. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75149. /**
  75150. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75151. * @param renderWidth defines the rendering width
  75152. * @param renderHeight defines the rendering height
  75153. * @param ref defines the target viewport
  75154. * @returns the current viewport
  75155. */
  75156. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75157. /**
  75158. * Returns a new Viewport copied from the current one
  75159. * @returns a new Viewport
  75160. */
  75161. clone(): Viewport;
  75162. }
  75163. }
  75164. declare module BABYLON {
  75165. /**
  75166. * Class containing a set of static utilities functions for arrays.
  75167. */
  75168. export class ArrayTools {
  75169. /**
  75170. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75171. * @param size the number of element to construct and put in the array
  75172. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75173. * @returns a new array filled with new objects
  75174. */
  75175. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75176. }
  75177. }
  75178. declare module BABYLON {
  75179. /**
  75180. * Class representing a vector containing 2 coordinates
  75181. */
  75182. export class Vector2 {
  75183. /** defines the first coordinate */
  75184. x: number;
  75185. /** defines the second coordinate */
  75186. y: number;
  75187. /**
  75188. * Creates a new Vector2 from the given x and y coordinates
  75189. * @param x defines the first coordinate
  75190. * @param y defines the second coordinate
  75191. */
  75192. constructor(
  75193. /** defines the first coordinate */
  75194. x?: number,
  75195. /** defines the second coordinate */
  75196. y?: number);
  75197. /**
  75198. * Gets a string with the Vector2 coordinates
  75199. * @returns a string with the Vector2 coordinates
  75200. */
  75201. toString(): string;
  75202. /**
  75203. * Gets class name
  75204. * @returns the string "Vector2"
  75205. */
  75206. getClassName(): string;
  75207. /**
  75208. * Gets current vector hash code
  75209. * @returns the Vector2 hash code as a number
  75210. */
  75211. getHashCode(): number;
  75212. /**
  75213. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75214. * @param array defines the source array
  75215. * @param index defines the offset in source array
  75216. * @returns the current Vector2
  75217. */
  75218. toArray(array: FloatArray, index?: number): Vector2;
  75219. /**
  75220. * Copy the current vector to an array
  75221. * @returns a new array with 2 elements: the Vector2 coordinates.
  75222. */
  75223. asArray(): number[];
  75224. /**
  75225. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75226. * @param source defines the source Vector2
  75227. * @returns the current updated Vector2
  75228. */
  75229. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75230. /**
  75231. * Sets the Vector2 coordinates with the given floats
  75232. * @param x defines the first coordinate
  75233. * @param y defines the second coordinate
  75234. * @returns the current updated Vector2
  75235. */
  75236. copyFromFloats(x: number, y: number): Vector2;
  75237. /**
  75238. * Sets the Vector2 coordinates with the given floats
  75239. * @param x defines the first coordinate
  75240. * @param y defines the second coordinate
  75241. * @returns the current updated Vector2
  75242. */
  75243. set(x: number, y: number): Vector2;
  75244. /**
  75245. * Add another vector with the current one
  75246. * @param otherVector defines the other vector
  75247. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75248. */
  75249. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75250. /**
  75251. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75252. * @param otherVector defines the other vector
  75253. * @param result defines the target vector
  75254. * @returns the unmodified current Vector2
  75255. */
  75256. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75257. /**
  75258. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75259. * @param otherVector defines the other vector
  75260. * @returns the current updated Vector2
  75261. */
  75262. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75263. /**
  75264. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75265. * @param otherVector defines the other vector
  75266. * @returns a new Vector2
  75267. */
  75268. addVector3(otherVector: Vector3): Vector2;
  75269. /**
  75270. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75271. * @param otherVector defines the other vector
  75272. * @returns a new Vector2
  75273. */
  75274. subtract(otherVector: Vector2): Vector2;
  75275. /**
  75276. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75277. * @param otherVector defines the other vector
  75278. * @param result defines the target vector
  75279. * @returns the unmodified current Vector2
  75280. */
  75281. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75282. /**
  75283. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75284. * @param otherVector defines the other vector
  75285. * @returns the current updated Vector2
  75286. */
  75287. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75288. /**
  75289. * Multiplies in place the current Vector2 coordinates by the given ones
  75290. * @param otherVector defines the other vector
  75291. * @returns the current updated Vector2
  75292. */
  75293. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75294. /**
  75295. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75296. * @param otherVector defines the other vector
  75297. * @returns a new Vector2
  75298. */
  75299. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75300. /**
  75301. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75302. * @param otherVector defines the other vector
  75303. * @param result defines the target vector
  75304. * @returns the unmodified current Vector2
  75305. */
  75306. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75307. /**
  75308. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75309. * @param x defines the first coordinate
  75310. * @param y defines the second coordinate
  75311. * @returns a new Vector2
  75312. */
  75313. multiplyByFloats(x: number, y: number): Vector2;
  75314. /**
  75315. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75316. * @param otherVector defines the other vector
  75317. * @returns a new Vector2
  75318. */
  75319. divide(otherVector: Vector2): Vector2;
  75320. /**
  75321. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75322. * @param otherVector defines the other vector
  75323. * @param result defines the target vector
  75324. * @returns the unmodified current Vector2
  75325. */
  75326. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75327. /**
  75328. * Divides the current Vector2 coordinates by the given ones
  75329. * @param otherVector defines the other vector
  75330. * @returns the current updated Vector2
  75331. */
  75332. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75333. /**
  75334. * Gets a new Vector2 with current Vector2 negated coordinates
  75335. * @returns a new Vector2
  75336. */
  75337. negate(): Vector2;
  75338. /**
  75339. * Negate this vector in place
  75340. * @returns this
  75341. */
  75342. negateInPlace(): Vector2;
  75343. /**
  75344. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75345. * @param result defines the Vector3 object where to store the result
  75346. * @returns the current Vector2
  75347. */
  75348. negateToRef(result: Vector2): Vector2;
  75349. /**
  75350. * Multiply the Vector2 coordinates by scale
  75351. * @param scale defines the scaling factor
  75352. * @returns the current updated Vector2
  75353. */
  75354. scaleInPlace(scale: number): Vector2;
  75355. /**
  75356. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75357. * @param scale defines the scaling factor
  75358. * @returns a new Vector2
  75359. */
  75360. scale(scale: number): Vector2;
  75361. /**
  75362. * Scale the current Vector2 values by a factor to a given Vector2
  75363. * @param scale defines the scale factor
  75364. * @param result defines the Vector2 object where to store the result
  75365. * @returns the unmodified current Vector2
  75366. */
  75367. scaleToRef(scale: number, result: Vector2): Vector2;
  75368. /**
  75369. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75370. * @param scale defines the scale factor
  75371. * @param result defines the Vector2 object where to store the result
  75372. * @returns the unmodified current Vector2
  75373. */
  75374. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75375. /**
  75376. * Gets a boolean if two vectors are equals
  75377. * @param otherVector defines the other vector
  75378. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75379. */
  75380. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75381. /**
  75382. * Gets a boolean if two vectors are equals (using an epsilon value)
  75383. * @param otherVector defines the other vector
  75384. * @param epsilon defines the minimal distance to consider equality
  75385. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75386. */
  75387. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75388. /**
  75389. * Gets a new Vector2 from current Vector2 floored values
  75390. * @returns a new Vector2
  75391. */
  75392. floor(): Vector2;
  75393. /**
  75394. * Gets a new Vector2 from current Vector2 floored values
  75395. * @returns a new Vector2
  75396. */
  75397. fract(): Vector2;
  75398. /**
  75399. * Gets the length of the vector
  75400. * @returns the vector length (float)
  75401. */
  75402. length(): number;
  75403. /**
  75404. * Gets the vector squared length
  75405. * @returns the vector squared length (float)
  75406. */
  75407. lengthSquared(): number;
  75408. /**
  75409. * Normalize the vector
  75410. * @returns the current updated Vector2
  75411. */
  75412. normalize(): Vector2;
  75413. /**
  75414. * Gets a new Vector2 copied from the Vector2
  75415. * @returns a new Vector2
  75416. */
  75417. clone(): Vector2;
  75418. /**
  75419. * Gets a new Vector2(0, 0)
  75420. * @returns a new Vector2
  75421. */
  75422. static Zero(): Vector2;
  75423. /**
  75424. * Gets a new Vector2(1, 1)
  75425. * @returns a new Vector2
  75426. */
  75427. static One(): Vector2;
  75428. /**
  75429. * Gets a new Vector2 set from the given index element of the given array
  75430. * @param array defines the data source
  75431. * @param offset defines the offset in the data source
  75432. * @returns a new Vector2
  75433. */
  75434. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75435. /**
  75436. * Sets "result" from the given index element of the given array
  75437. * @param array defines the data source
  75438. * @param offset defines the offset in the data source
  75439. * @param result defines the target vector
  75440. */
  75441. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75442. /**
  75443. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75444. * @param value1 defines 1st point of control
  75445. * @param value2 defines 2nd point of control
  75446. * @param value3 defines 3rd point of control
  75447. * @param value4 defines 4th point of control
  75448. * @param amount defines the interpolation factor
  75449. * @returns a new Vector2
  75450. */
  75451. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75452. /**
  75453. * 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".
  75454. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75455. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75456. * @param value defines the value to clamp
  75457. * @param min defines the lower limit
  75458. * @param max defines the upper limit
  75459. * @returns a new Vector2
  75460. */
  75461. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75462. /**
  75463. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75464. * @param value1 defines the 1st control point
  75465. * @param tangent1 defines the outgoing tangent
  75466. * @param value2 defines the 2nd control point
  75467. * @param tangent2 defines the incoming tangent
  75468. * @param amount defines the interpolation factor
  75469. * @returns a new Vector2
  75470. */
  75471. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75472. /**
  75473. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75474. * @param start defines the start vector
  75475. * @param end defines the end vector
  75476. * @param amount defines the interpolation factor
  75477. * @returns a new Vector2
  75478. */
  75479. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75480. /**
  75481. * Gets the dot product of the vector "left" and the vector "right"
  75482. * @param left defines first vector
  75483. * @param right defines second vector
  75484. * @returns the dot product (float)
  75485. */
  75486. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75487. /**
  75488. * Returns a new Vector2 equal to the normalized given vector
  75489. * @param vector defines the vector to normalize
  75490. * @returns a new Vector2
  75491. */
  75492. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75493. /**
  75494. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75495. * @param left defines 1st vector
  75496. * @param right defines 2nd vector
  75497. * @returns a new Vector2
  75498. */
  75499. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75500. /**
  75501. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75502. * @param left defines 1st vector
  75503. * @param right defines 2nd vector
  75504. * @returns a new Vector2
  75505. */
  75506. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75507. /**
  75508. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75509. * @param vector defines the vector to transform
  75510. * @param transformation defines the matrix to apply
  75511. * @returns a new Vector2
  75512. */
  75513. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75514. /**
  75515. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75516. * @param vector defines the vector to transform
  75517. * @param transformation defines the matrix to apply
  75518. * @param result defines the target vector
  75519. */
  75520. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75521. /**
  75522. * Determines if a given vector is included in a triangle
  75523. * @param p defines the vector to test
  75524. * @param p0 defines 1st triangle point
  75525. * @param p1 defines 2nd triangle point
  75526. * @param p2 defines 3rd triangle point
  75527. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75528. */
  75529. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75530. /**
  75531. * Gets the distance between the vectors "value1" and "value2"
  75532. * @param value1 defines first vector
  75533. * @param value2 defines second vector
  75534. * @returns the distance between vectors
  75535. */
  75536. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75537. /**
  75538. * Returns the squared distance between the vectors "value1" and "value2"
  75539. * @param value1 defines first vector
  75540. * @param value2 defines second vector
  75541. * @returns the squared distance between vectors
  75542. */
  75543. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75544. /**
  75545. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75546. * @param value1 defines first vector
  75547. * @param value2 defines second vector
  75548. * @returns a new Vector2
  75549. */
  75550. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75551. /**
  75552. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75553. * @param p defines the middle point
  75554. * @param segA defines one point of the segment
  75555. * @param segB defines the other point of the segment
  75556. * @returns the shortest distance
  75557. */
  75558. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75559. }
  75560. /**
  75561. * Class used to store (x,y,z) vector representation
  75562. * A Vector3 is the main object used in 3D geometry
  75563. * It can represent etiher the coordinates of a point the space, either a direction
  75564. * Reminder: js uses a left handed forward facing system
  75565. */
  75566. export class Vector3 {
  75567. /**
  75568. * Defines the first coordinates (on X axis)
  75569. */
  75570. x: number;
  75571. /**
  75572. * Defines the second coordinates (on Y axis)
  75573. */
  75574. y: number;
  75575. /**
  75576. * Defines the third coordinates (on Z axis)
  75577. */
  75578. z: number;
  75579. private static _UpReadOnly;
  75580. private static _ZeroReadOnly;
  75581. /**
  75582. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75583. * @param x defines the first coordinates (on X axis)
  75584. * @param y defines the second coordinates (on Y axis)
  75585. * @param z defines the third coordinates (on Z axis)
  75586. */
  75587. constructor(
  75588. /**
  75589. * Defines the first coordinates (on X axis)
  75590. */
  75591. x?: number,
  75592. /**
  75593. * Defines the second coordinates (on Y axis)
  75594. */
  75595. y?: number,
  75596. /**
  75597. * Defines the third coordinates (on Z axis)
  75598. */
  75599. z?: number);
  75600. /**
  75601. * Creates a string representation of the Vector3
  75602. * @returns a string with the Vector3 coordinates.
  75603. */
  75604. toString(): string;
  75605. /**
  75606. * Gets the class name
  75607. * @returns the string "Vector3"
  75608. */
  75609. getClassName(): string;
  75610. /**
  75611. * Creates the Vector3 hash code
  75612. * @returns a number which tends to be unique between Vector3 instances
  75613. */
  75614. getHashCode(): number;
  75615. /**
  75616. * Creates an array containing three elements : the coordinates of the Vector3
  75617. * @returns a new array of numbers
  75618. */
  75619. asArray(): number[];
  75620. /**
  75621. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75622. * @param array defines the destination array
  75623. * @param index defines the offset in the destination array
  75624. * @returns the current Vector3
  75625. */
  75626. toArray(array: FloatArray, index?: number): Vector3;
  75627. /**
  75628. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75629. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75630. */
  75631. toQuaternion(): Quaternion;
  75632. /**
  75633. * Adds the given vector to the current Vector3
  75634. * @param otherVector defines the second operand
  75635. * @returns the current updated Vector3
  75636. */
  75637. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75638. /**
  75639. * Adds the given coordinates to the current Vector3
  75640. * @param x defines the x coordinate of the operand
  75641. * @param y defines the y coordinate of the operand
  75642. * @param z defines the z coordinate of the operand
  75643. * @returns the current updated Vector3
  75644. */
  75645. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75646. /**
  75647. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75648. * @param otherVector defines the second operand
  75649. * @returns the resulting Vector3
  75650. */
  75651. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75652. /**
  75653. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75654. * @param otherVector defines the second operand
  75655. * @param result defines the Vector3 object where to store the result
  75656. * @returns the current Vector3
  75657. */
  75658. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75659. /**
  75660. * Subtract the given vector from the current Vector3
  75661. * @param otherVector defines the second operand
  75662. * @returns the current updated Vector3
  75663. */
  75664. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75665. /**
  75666. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75667. * @param otherVector defines the second operand
  75668. * @returns the resulting Vector3
  75669. */
  75670. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75671. /**
  75672. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75673. * @param otherVector defines the second operand
  75674. * @param result defines the Vector3 object where to store the result
  75675. * @returns the current Vector3
  75676. */
  75677. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75678. /**
  75679. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75680. * @param x defines the x coordinate of the operand
  75681. * @param y defines the y coordinate of the operand
  75682. * @param z defines the z coordinate of the operand
  75683. * @returns the resulting Vector3
  75684. */
  75685. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75686. /**
  75687. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75688. * @param x defines the x coordinate of the operand
  75689. * @param y defines the y coordinate of the operand
  75690. * @param z defines the z coordinate of the operand
  75691. * @param result defines the Vector3 object where to store the result
  75692. * @returns the current Vector3
  75693. */
  75694. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75695. /**
  75696. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75697. * @returns a new Vector3
  75698. */
  75699. negate(): Vector3;
  75700. /**
  75701. * Negate this vector in place
  75702. * @returns this
  75703. */
  75704. negateInPlace(): Vector3;
  75705. /**
  75706. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75707. * @param result defines the Vector3 object where to store the result
  75708. * @returns the current Vector3
  75709. */
  75710. negateToRef(result: Vector3): Vector3;
  75711. /**
  75712. * Multiplies the Vector3 coordinates by the float "scale"
  75713. * @param scale defines the multiplier factor
  75714. * @returns the current updated Vector3
  75715. */
  75716. scaleInPlace(scale: number): Vector3;
  75717. /**
  75718. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75719. * @param scale defines the multiplier factor
  75720. * @returns a new Vector3
  75721. */
  75722. scale(scale: number): Vector3;
  75723. /**
  75724. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75725. * @param scale defines the multiplier factor
  75726. * @param result defines the Vector3 object where to store the result
  75727. * @returns the current Vector3
  75728. */
  75729. scaleToRef(scale: number, result: Vector3): Vector3;
  75730. /**
  75731. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75732. * @param scale defines the scale factor
  75733. * @param result defines the Vector3 object where to store the result
  75734. * @returns the unmodified current Vector3
  75735. */
  75736. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75737. /**
  75738. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75739. * @param otherVector defines the second operand
  75740. * @returns true if both vectors are equals
  75741. */
  75742. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75743. /**
  75744. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75745. * @param otherVector defines the second operand
  75746. * @param epsilon defines the minimal distance to define values as equals
  75747. * @returns true if both vectors are distant less than epsilon
  75748. */
  75749. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75750. /**
  75751. * Returns true if the current Vector3 coordinates equals the given floats
  75752. * @param x defines the x coordinate of the operand
  75753. * @param y defines the y coordinate of the operand
  75754. * @param z defines the z coordinate of the operand
  75755. * @returns true if both vectors are equals
  75756. */
  75757. equalsToFloats(x: number, y: number, z: number): boolean;
  75758. /**
  75759. * Multiplies the current Vector3 coordinates by the given ones
  75760. * @param otherVector defines the second operand
  75761. * @returns the current updated Vector3
  75762. */
  75763. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75764. /**
  75765. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75766. * @param otherVector defines the second operand
  75767. * @returns the new Vector3
  75768. */
  75769. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75770. /**
  75771. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75772. * @param otherVector defines the second operand
  75773. * @param result defines the Vector3 object where to store the result
  75774. * @returns the current Vector3
  75775. */
  75776. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75777. /**
  75778. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75779. * @param x defines the x coordinate of the operand
  75780. * @param y defines the y coordinate of the operand
  75781. * @param z defines the z coordinate of the operand
  75782. * @returns the new Vector3
  75783. */
  75784. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75785. /**
  75786. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75787. * @param otherVector defines the second operand
  75788. * @returns the new Vector3
  75789. */
  75790. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75791. /**
  75792. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75793. * @param otherVector defines the second operand
  75794. * @param result defines the Vector3 object where to store the result
  75795. * @returns the current Vector3
  75796. */
  75797. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75798. /**
  75799. * Divides the current Vector3 coordinates by the given ones.
  75800. * @param otherVector defines the second operand
  75801. * @returns the current updated Vector3
  75802. */
  75803. divideInPlace(otherVector: Vector3): Vector3;
  75804. /**
  75805. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75806. * @param other defines the second operand
  75807. * @returns the current updated Vector3
  75808. */
  75809. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75810. /**
  75811. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75812. * @param other defines the second operand
  75813. * @returns the current updated Vector3
  75814. */
  75815. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75816. /**
  75817. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75818. * @param x defines the x coordinate of the operand
  75819. * @param y defines the y coordinate of the operand
  75820. * @param z defines the z coordinate of the operand
  75821. * @returns the current updated Vector3
  75822. */
  75823. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75824. /**
  75825. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75826. * @param x defines the x coordinate of the operand
  75827. * @param y defines the y coordinate of the operand
  75828. * @param z defines the z coordinate of the operand
  75829. * @returns the current updated Vector3
  75830. */
  75831. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75832. /**
  75833. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75834. * Check if is non uniform within a certain amount of decimal places to account for this
  75835. * @param epsilon the amount the values can differ
  75836. * @returns if the the vector is non uniform to a certain number of decimal places
  75837. */
  75838. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75839. /**
  75840. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75841. */
  75842. get isNonUniform(): boolean;
  75843. /**
  75844. * Gets a new Vector3 from current Vector3 floored values
  75845. * @returns a new Vector3
  75846. */
  75847. floor(): Vector3;
  75848. /**
  75849. * Gets a new Vector3 from current Vector3 floored values
  75850. * @returns a new Vector3
  75851. */
  75852. fract(): Vector3;
  75853. /**
  75854. * Gets the length of the Vector3
  75855. * @returns the length of the Vector3
  75856. */
  75857. length(): number;
  75858. /**
  75859. * Gets the squared length of the Vector3
  75860. * @returns squared length of the Vector3
  75861. */
  75862. lengthSquared(): number;
  75863. /**
  75864. * Normalize the current Vector3.
  75865. * Please note that this is an in place operation.
  75866. * @returns the current updated Vector3
  75867. */
  75868. normalize(): Vector3;
  75869. /**
  75870. * Reorders the x y z properties of the vector in place
  75871. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75872. * @returns the current updated vector
  75873. */
  75874. reorderInPlace(order: string): this;
  75875. /**
  75876. * Rotates the vector around 0,0,0 by a quaternion
  75877. * @param quaternion the rotation quaternion
  75878. * @param result vector to store the result
  75879. * @returns the resulting vector
  75880. */
  75881. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75882. /**
  75883. * Rotates a vector around a given point
  75884. * @param quaternion the rotation quaternion
  75885. * @param point the point to rotate around
  75886. * @param result vector to store the result
  75887. * @returns the resulting vector
  75888. */
  75889. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75890. /**
  75891. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75892. * The cross product is then orthogonal to both current and "other"
  75893. * @param other defines the right operand
  75894. * @returns the cross product
  75895. */
  75896. cross(other: Vector3): Vector3;
  75897. /**
  75898. * Normalize the current Vector3 with the given input length.
  75899. * Please note that this is an in place operation.
  75900. * @param len the length of the vector
  75901. * @returns the current updated Vector3
  75902. */
  75903. normalizeFromLength(len: number): Vector3;
  75904. /**
  75905. * Normalize the current Vector3 to a new vector
  75906. * @returns the new Vector3
  75907. */
  75908. normalizeToNew(): Vector3;
  75909. /**
  75910. * Normalize the current Vector3 to the reference
  75911. * @param reference define the Vector3 to update
  75912. * @returns the updated Vector3
  75913. */
  75914. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75915. /**
  75916. * Creates a new Vector3 copied from the current Vector3
  75917. * @returns the new Vector3
  75918. */
  75919. clone(): Vector3;
  75920. /**
  75921. * Copies the given vector coordinates to the current Vector3 ones
  75922. * @param source defines the source Vector3
  75923. * @returns the current updated Vector3
  75924. */
  75925. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75926. /**
  75927. * Copies the given floats to the current Vector3 coordinates
  75928. * @param x defines the x coordinate of the operand
  75929. * @param y defines the y coordinate of the operand
  75930. * @param z defines the z coordinate of the operand
  75931. * @returns the current updated Vector3
  75932. */
  75933. copyFromFloats(x: number, y: number, z: number): Vector3;
  75934. /**
  75935. * Copies the given floats to the current Vector3 coordinates
  75936. * @param x defines the x coordinate of the operand
  75937. * @param y defines the y coordinate of the operand
  75938. * @param z defines the z coordinate of the operand
  75939. * @returns the current updated Vector3
  75940. */
  75941. set(x: number, y: number, z: number): Vector3;
  75942. /**
  75943. * Copies the given float to the current Vector3 coordinates
  75944. * @param v defines the x, y and z coordinates of the operand
  75945. * @returns the current updated Vector3
  75946. */
  75947. setAll(v: number): Vector3;
  75948. /**
  75949. * Get the clip factor between two vectors
  75950. * @param vector0 defines the first operand
  75951. * @param vector1 defines the second operand
  75952. * @param axis defines the axis to use
  75953. * @param size defines the size along the axis
  75954. * @returns the clip factor
  75955. */
  75956. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75957. /**
  75958. * Get angle between two vectors
  75959. * @param vector0 angle between vector0 and vector1
  75960. * @param vector1 angle between vector0 and vector1
  75961. * @param normal direction of the normal
  75962. * @return the angle between vector0 and vector1
  75963. */
  75964. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75965. /**
  75966. * Returns a new Vector3 set from the index "offset" of the given array
  75967. * @param array defines the source array
  75968. * @param offset defines the offset in the source array
  75969. * @returns the new Vector3
  75970. */
  75971. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75972. /**
  75973. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75974. * @param array defines the source array
  75975. * @param offset defines the offset in the source array
  75976. * @returns the new Vector3
  75977. * @deprecated Please use FromArray instead.
  75978. */
  75979. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75980. /**
  75981. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75982. * @param array defines the source array
  75983. * @param offset defines the offset in the source array
  75984. * @param result defines the Vector3 where to store the result
  75985. */
  75986. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75987. /**
  75988. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75989. * @param array defines the source array
  75990. * @param offset defines the offset in the source array
  75991. * @param result defines the Vector3 where to store the result
  75992. * @deprecated Please use FromArrayToRef instead.
  75993. */
  75994. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75995. /**
  75996. * Sets the given vector "result" with the given floats.
  75997. * @param x defines the x coordinate of the source
  75998. * @param y defines the y coordinate of the source
  75999. * @param z defines the z coordinate of the source
  76000. * @param result defines the Vector3 where to store the result
  76001. */
  76002. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76003. /**
  76004. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76005. * @returns a new empty Vector3
  76006. */
  76007. static Zero(): Vector3;
  76008. /**
  76009. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76010. * @returns a new unit Vector3
  76011. */
  76012. static One(): Vector3;
  76013. /**
  76014. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76015. * @returns a new up Vector3
  76016. */
  76017. static Up(): Vector3;
  76018. /**
  76019. * Gets a up Vector3 that must not be updated
  76020. */
  76021. static get UpReadOnly(): DeepImmutable<Vector3>;
  76022. /**
  76023. * Gets a zero Vector3 that must not be updated
  76024. */
  76025. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76026. /**
  76027. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76028. * @returns a new down Vector3
  76029. */
  76030. static Down(): Vector3;
  76031. /**
  76032. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76033. * @returns a new forward Vector3
  76034. */
  76035. static Forward(): Vector3;
  76036. /**
  76037. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76038. * @returns a new forward Vector3
  76039. */
  76040. static Backward(): Vector3;
  76041. /**
  76042. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76043. * @returns a new right Vector3
  76044. */
  76045. static Right(): Vector3;
  76046. /**
  76047. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76048. * @returns a new left Vector3
  76049. */
  76050. static Left(): Vector3;
  76051. /**
  76052. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76053. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76054. * @param vector defines the Vector3 to transform
  76055. * @param transformation defines the transformation matrix
  76056. * @returns the transformed Vector3
  76057. */
  76058. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76059. /**
  76060. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76061. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76062. * @param vector defines the Vector3 to transform
  76063. * @param transformation defines the transformation matrix
  76064. * @param result defines the Vector3 where to store the result
  76065. */
  76066. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76067. /**
  76068. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76069. * This method computes tranformed coordinates only, not transformed direction vectors
  76070. * @param x define the x coordinate of the source vector
  76071. * @param y define the y coordinate of the source vector
  76072. * @param z define the z coordinate of the source vector
  76073. * @param transformation defines the transformation matrix
  76074. * @param result defines the Vector3 where to store the result
  76075. */
  76076. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76077. /**
  76078. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76079. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76080. * @param vector defines the Vector3 to transform
  76081. * @param transformation defines the transformation matrix
  76082. * @returns the new Vector3
  76083. */
  76084. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76085. /**
  76086. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76087. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76088. * @param vector defines the Vector3 to transform
  76089. * @param transformation defines the transformation matrix
  76090. * @param result defines the Vector3 where to store the result
  76091. */
  76092. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76093. /**
  76094. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76095. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76096. * @param x define the x coordinate of the source vector
  76097. * @param y define the y coordinate of the source vector
  76098. * @param z define the z coordinate of the source vector
  76099. * @param transformation defines the transformation matrix
  76100. * @param result defines the Vector3 where to store the result
  76101. */
  76102. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76103. /**
  76104. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76105. * @param value1 defines the first control point
  76106. * @param value2 defines the second control point
  76107. * @param value3 defines the third control point
  76108. * @param value4 defines the fourth control point
  76109. * @param amount defines the amount on the spline to use
  76110. * @returns the new Vector3
  76111. */
  76112. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76113. /**
  76114. * 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"
  76115. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76116. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76117. * @param value defines the current value
  76118. * @param min defines the lower range value
  76119. * @param max defines the upper range value
  76120. * @returns the new Vector3
  76121. */
  76122. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76123. /**
  76124. * 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"
  76125. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76126. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76127. * @param value defines the current value
  76128. * @param min defines the lower range value
  76129. * @param max defines the upper range value
  76130. * @param result defines the Vector3 where to store the result
  76131. */
  76132. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76133. /**
  76134. * Checks if a given vector is inside a specific range
  76135. * @param v defines the vector to test
  76136. * @param min defines the minimum range
  76137. * @param max defines the maximum range
  76138. */
  76139. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76140. /**
  76141. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76142. * @param value1 defines the first control point
  76143. * @param tangent1 defines the first tangent vector
  76144. * @param value2 defines the second control point
  76145. * @param tangent2 defines the second tangent vector
  76146. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76147. * @returns the new Vector3
  76148. */
  76149. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76150. /**
  76151. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76152. * @param start defines the start value
  76153. * @param end defines the end value
  76154. * @param amount max defines amount between both (between 0 and 1)
  76155. * @returns the new Vector3
  76156. */
  76157. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76158. /**
  76159. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76160. * @param start defines the start value
  76161. * @param end defines the end value
  76162. * @param amount max defines amount between both (between 0 and 1)
  76163. * @param result defines the Vector3 where to store the result
  76164. */
  76165. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76166. /**
  76167. * Returns the dot product (float) between the vectors "left" and "right"
  76168. * @param left defines the left operand
  76169. * @param right defines the right operand
  76170. * @returns the dot product
  76171. */
  76172. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76173. /**
  76174. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76175. * The cross product is then orthogonal to both "left" and "right"
  76176. * @param left defines the left operand
  76177. * @param right defines the right operand
  76178. * @returns the cross product
  76179. */
  76180. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76181. /**
  76182. * Sets the given vector "result" with the cross product of "left" and "right"
  76183. * The cross product is then orthogonal to both "left" and "right"
  76184. * @param left defines the left operand
  76185. * @param right defines the right operand
  76186. * @param result defines the Vector3 where to store the result
  76187. */
  76188. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76189. /**
  76190. * Returns a new Vector3 as the normalization of the given vector
  76191. * @param vector defines the Vector3 to normalize
  76192. * @returns the new Vector3
  76193. */
  76194. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76195. /**
  76196. * Sets the given vector "result" with the normalization of the given first vector
  76197. * @param vector defines the Vector3 to normalize
  76198. * @param result defines the Vector3 where to store the result
  76199. */
  76200. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76201. /**
  76202. * Project a Vector3 onto screen space
  76203. * @param vector defines the Vector3 to project
  76204. * @param world defines the world matrix to use
  76205. * @param transform defines the transform (view x projection) matrix to use
  76206. * @param viewport defines the screen viewport to use
  76207. * @returns the new Vector3
  76208. */
  76209. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76210. /** @hidden */
  76211. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76212. /**
  76213. * Unproject from screen space to object space
  76214. * @param source defines the screen space Vector3 to use
  76215. * @param viewportWidth defines the current width of the viewport
  76216. * @param viewportHeight defines the current height of the viewport
  76217. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76218. * @param transform defines the transform (view x projection) matrix to use
  76219. * @returns the new Vector3
  76220. */
  76221. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76222. /**
  76223. * Unproject from screen space to object space
  76224. * @param source defines the screen space Vector3 to use
  76225. * @param viewportWidth defines the current width of the viewport
  76226. * @param viewportHeight defines the current height of the viewport
  76227. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76228. * @param view defines the view matrix to use
  76229. * @param projection defines the projection matrix to use
  76230. * @returns the new Vector3
  76231. */
  76232. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76233. /**
  76234. * Unproject from screen space to object space
  76235. * @param source defines the screen space Vector3 to use
  76236. * @param viewportWidth defines the current width of the viewport
  76237. * @param viewportHeight defines the current height of the viewport
  76238. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76239. * @param view defines the view matrix to use
  76240. * @param projection defines the projection matrix to use
  76241. * @param result defines the Vector3 where to store the result
  76242. */
  76243. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76244. /**
  76245. * Unproject from screen space to object space
  76246. * @param sourceX defines the screen space x coordinate to use
  76247. * @param sourceY defines the screen space y coordinate to use
  76248. * @param sourceZ defines the screen space z coordinate to use
  76249. * @param viewportWidth defines the current width of the viewport
  76250. * @param viewportHeight defines the current height of the viewport
  76251. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76252. * @param view defines the view matrix to use
  76253. * @param projection defines the projection matrix to use
  76254. * @param result defines the Vector3 where to store the result
  76255. */
  76256. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76257. /**
  76258. * Gets the minimal coordinate values between two Vector3
  76259. * @param left defines the first operand
  76260. * @param right defines the second operand
  76261. * @returns the new Vector3
  76262. */
  76263. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76264. /**
  76265. * Gets the maximal coordinate values between two Vector3
  76266. * @param left defines the first operand
  76267. * @param right defines the second operand
  76268. * @returns the new Vector3
  76269. */
  76270. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76271. /**
  76272. * Returns the distance between the vectors "value1" and "value2"
  76273. * @param value1 defines the first operand
  76274. * @param value2 defines the second operand
  76275. * @returns the distance
  76276. */
  76277. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76278. /**
  76279. * Returns the squared distance between the vectors "value1" and "value2"
  76280. * @param value1 defines the first operand
  76281. * @param value2 defines the second operand
  76282. * @returns the squared distance
  76283. */
  76284. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76285. /**
  76286. * Returns a new Vector3 located at the center between "value1" and "value2"
  76287. * @param value1 defines the first operand
  76288. * @param value2 defines the second operand
  76289. * @returns the new Vector3
  76290. */
  76291. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76292. /**
  76293. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76294. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76295. * to something in order to rotate it from its local system to the given target system
  76296. * Note: axis1, axis2 and axis3 are normalized during this operation
  76297. * @param axis1 defines the first axis
  76298. * @param axis2 defines the second axis
  76299. * @param axis3 defines the third axis
  76300. * @returns a new Vector3
  76301. */
  76302. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76303. /**
  76304. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76305. * @param axis1 defines the first axis
  76306. * @param axis2 defines the second axis
  76307. * @param axis3 defines the third axis
  76308. * @param ref defines the Vector3 where to store the result
  76309. */
  76310. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76311. }
  76312. /**
  76313. * Vector4 class created for EulerAngle class conversion to Quaternion
  76314. */
  76315. export class Vector4 {
  76316. /** x value of the vector */
  76317. x: number;
  76318. /** y value of the vector */
  76319. y: number;
  76320. /** z value of the vector */
  76321. z: number;
  76322. /** w value of the vector */
  76323. w: number;
  76324. /**
  76325. * Creates a Vector4 object from the given floats.
  76326. * @param x x value of the vector
  76327. * @param y y value of the vector
  76328. * @param z z value of the vector
  76329. * @param w w value of the vector
  76330. */
  76331. constructor(
  76332. /** x value of the vector */
  76333. x: number,
  76334. /** y value of the vector */
  76335. y: number,
  76336. /** z value of the vector */
  76337. z: number,
  76338. /** w value of the vector */
  76339. w: number);
  76340. /**
  76341. * Returns the string with the Vector4 coordinates.
  76342. * @returns a string containing all the vector values
  76343. */
  76344. toString(): string;
  76345. /**
  76346. * Returns the string "Vector4".
  76347. * @returns "Vector4"
  76348. */
  76349. getClassName(): string;
  76350. /**
  76351. * Returns the Vector4 hash code.
  76352. * @returns a unique hash code
  76353. */
  76354. getHashCode(): number;
  76355. /**
  76356. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76357. * @returns the resulting array
  76358. */
  76359. asArray(): number[];
  76360. /**
  76361. * Populates the given array from the given index with the Vector4 coordinates.
  76362. * @param array array to populate
  76363. * @param index index of the array to start at (default: 0)
  76364. * @returns the Vector4.
  76365. */
  76366. toArray(array: FloatArray, index?: number): Vector4;
  76367. /**
  76368. * Adds the given vector to the current Vector4.
  76369. * @param otherVector the vector to add
  76370. * @returns the updated Vector4.
  76371. */
  76372. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76373. /**
  76374. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76375. * @param otherVector the vector to add
  76376. * @returns the resulting vector
  76377. */
  76378. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76379. /**
  76380. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76381. * @param otherVector the vector to add
  76382. * @param result the vector to store the result
  76383. * @returns the current Vector4.
  76384. */
  76385. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76386. /**
  76387. * Subtract in place the given vector from the current Vector4.
  76388. * @param otherVector the vector to subtract
  76389. * @returns the updated Vector4.
  76390. */
  76391. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76392. /**
  76393. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76394. * @param otherVector the vector to add
  76395. * @returns the new vector with the result
  76396. */
  76397. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76398. /**
  76399. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76400. * @param otherVector the vector to subtract
  76401. * @param result the vector to store the result
  76402. * @returns the current Vector4.
  76403. */
  76404. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76405. /**
  76406. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76407. */
  76408. /**
  76409. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76410. * @param x value to subtract
  76411. * @param y value to subtract
  76412. * @param z value to subtract
  76413. * @param w value to subtract
  76414. * @returns new vector containing the result
  76415. */
  76416. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76417. /**
  76418. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76419. * @param x value to subtract
  76420. * @param y value to subtract
  76421. * @param z value to subtract
  76422. * @param w value to subtract
  76423. * @param result the vector to store the result in
  76424. * @returns the current Vector4.
  76425. */
  76426. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76427. /**
  76428. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76429. * @returns a new vector with the negated values
  76430. */
  76431. negate(): Vector4;
  76432. /**
  76433. * Negate this vector in place
  76434. * @returns this
  76435. */
  76436. negateInPlace(): Vector4;
  76437. /**
  76438. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76439. * @param result defines the Vector3 object where to store the result
  76440. * @returns the current Vector4
  76441. */
  76442. negateToRef(result: Vector4): Vector4;
  76443. /**
  76444. * Multiplies the current Vector4 coordinates by scale (float).
  76445. * @param scale the number to scale with
  76446. * @returns the updated Vector4.
  76447. */
  76448. scaleInPlace(scale: number): Vector4;
  76449. /**
  76450. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76451. * @param scale the number to scale with
  76452. * @returns a new vector with the result
  76453. */
  76454. scale(scale: number): Vector4;
  76455. /**
  76456. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76457. * @param scale the number to scale with
  76458. * @param result a vector to store the result in
  76459. * @returns the current Vector4.
  76460. */
  76461. scaleToRef(scale: number, result: Vector4): Vector4;
  76462. /**
  76463. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76464. * @param scale defines the scale factor
  76465. * @param result defines the Vector4 object where to store the result
  76466. * @returns the unmodified current Vector4
  76467. */
  76468. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76469. /**
  76470. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76471. * @param otherVector the vector to compare against
  76472. * @returns true if they are equal
  76473. */
  76474. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76475. /**
  76476. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76477. * @param otherVector vector to compare against
  76478. * @param epsilon (Default: very small number)
  76479. * @returns true if they are equal
  76480. */
  76481. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76482. /**
  76483. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76484. * @param x x value to compare against
  76485. * @param y y value to compare against
  76486. * @param z z value to compare against
  76487. * @param w w value to compare against
  76488. * @returns true if equal
  76489. */
  76490. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76491. /**
  76492. * Multiplies in place the current Vector4 by the given one.
  76493. * @param otherVector vector to multiple with
  76494. * @returns the updated Vector4.
  76495. */
  76496. multiplyInPlace(otherVector: Vector4): Vector4;
  76497. /**
  76498. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76499. * @param otherVector vector to multiple with
  76500. * @returns resulting new vector
  76501. */
  76502. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76503. /**
  76504. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76505. * @param otherVector vector to multiple with
  76506. * @param result vector to store the result
  76507. * @returns the current Vector4.
  76508. */
  76509. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76510. /**
  76511. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76512. * @param x x value multiply with
  76513. * @param y y value multiply with
  76514. * @param z z value multiply with
  76515. * @param w w value multiply with
  76516. * @returns resulting new vector
  76517. */
  76518. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76519. /**
  76520. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76521. * @param otherVector vector to devide with
  76522. * @returns resulting new vector
  76523. */
  76524. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76525. /**
  76526. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76527. * @param otherVector vector to devide with
  76528. * @param result vector to store the result
  76529. * @returns the current Vector4.
  76530. */
  76531. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76532. /**
  76533. * Divides the current Vector3 coordinates by the given ones.
  76534. * @param otherVector vector to devide with
  76535. * @returns the updated Vector3.
  76536. */
  76537. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76538. /**
  76539. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76540. * @param other defines the second operand
  76541. * @returns the current updated Vector4
  76542. */
  76543. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76544. /**
  76545. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76546. * @param other defines the second operand
  76547. * @returns the current updated Vector4
  76548. */
  76549. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76550. /**
  76551. * Gets a new Vector4 from current Vector4 floored values
  76552. * @returns a new Vector4
  76553. */
  76554. floor(): Vector4;
  76555. /**
  76556. * Gets a new Vector4 from current Vector3 floored values
  76557. * @returns a new Vector4
  76558. */
  76559. fract(): Vector4;
  76560. /**
  76561. * Returns the Vector4 length (float).
  76562. * @returns the length
  76563. */
  76564. length(): number;
  76565. /**
  76566. * Returns the Vector4 squared length (float).
  76567. * @returns the length squared
  76568. */
  76569. lengthSquared(): number;
  76570. /**
  76571. * Normalizes in place the Vector4.
  76572. * @returns the updated Vector4.
  76573. */
  76574. normalize(): Vector4;
  76575. /**
  76576. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76577. * @returns this converted to a new vector3
  76578. */
  76579. toVector3(): Vector3;
  76580. /**
  76581. * Returns a new Vector4 copied from the current one.
  76582. * @returns the new cloned vector
  76583. */
  76584. clone(): Vector4;
  76585. /**
  76586. * Updates the current Vector4 with the given one coordinates.
  76587. * @param source the source vector to copy from
  76588. * @returns the updated Vector4.
  76589. */
  76590. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76591. /**
  76592. * Updates the current Vector4 coordinates with the given floats.
  76593. * @param x float to copy from
  76594. * @param y float to copy from
  76595. * @param z float to copy from
  76596. * @param w float to copy from
  76597. * @returns the updated Vector4.
  76598. */
  76599. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76600. /**
  76601. * Updates the current Vector4 coordinates with the given floats.
  76602. * @param x float to set from
  76603. * @param y float to set from
  76604. * @param z float to set from
  76605. * @param w float to set from
  76606. * @returns the updated Vector4.
  76607. */
  76608. set(x: number, y: number, z: number, w: number): Vector4;
  76609. /**
  76610. * Copies the given float to the current Vector3 coordinates
  76611. * @param v defines the x, y, z and w coordinates of the operand
  76612. * @returns the current updated Vector3
  76613. */
  76614. setAll(v: number): Vector4;
  76615. /**
  76616. * Returns a new Vector4 set from the starting index of the given array.
  76617. * @param array the array to pull values from
  76618. * @param offset the offset into the array to start at
  76619. * @returns the new vector
  76620. */
  76621. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76622. /**
  76623. * Updates the given vector "result" from the starting index of the given array.
  76624. * @param array the array to pull values from
  76625. * @param offset the offset into the array to start at
  76626. * @param result the vector to store the result in
  76627. */
  76628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76629. /**
  76630. * Updates the given vector "result" from the starting index of the given Float32Array.
  76631. * @param array the array to pull values from
  76632. * @param offset the offset into the array to start at
  76633. * @param result the vector to store the result in
  76634. */
  76635. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76636. /**
  76637. * Updates the given vector "result" coordinates from the given floats.
  76638. * @param x float to set from
  76639. * @param y float to set from
  76640. * @param z float to set from
  76641. * @param w float to set from
  76642. * @param result the vector to the floats in
  76643. */
  76644. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76645. /**
  76646. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76647. * @returns the new vector
  76648. */
  76649. static Zero(): Vector4;
  76650. /**
  76651. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76652. * @returns the new vector
  76653. */
  76654. static One(): Vector4;
  76655. /**
  76656. * Returns a new normalized Vector4 from the given one.
  76657. * @param vector the vector to normalize
  76658. * @returns the vector
  76659. */
  76660. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76661. /**
  76662. * Updates the given vector "result" from the normalization of the given one.
  76663. * @param vector the vector to normalize
  76664. * @param result the vector to store the result in
  76665. */
  76666. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76667. /**
  76668. * Returns a vector with the minimum values from the left and right vectors
  76669. * @param left left vector to minimize
  76670. * @param right right vector to minimize
  76671. * @returns a new vector with the minimum of the left and right vector values
  76672. */
  76673. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76674. /**
  76675. * Returns a vector with the maximum values from the left and right vectors
  76676. * @param left left vector to maximize
  76677. * @param right right vector to maximize
  76678. * @returns a new vector with the maximum of the left and right vector values
  76679. */
  76680. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76681. /**
  76682. * Returns the distance (float) between the vectors "value1" and "value2".
  76683. * @param value1 value to calulate the distance between
  76684. * @param value2 value to calulate the distance between
  76685. * @return the distance between the two vectors
  76686. */
  76687. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76688. /**
  76689. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76690. * @param value1 value to calulate the distance between
  76691. * @param value2 value to calulate the distance between
  76692. * @return the distance between the two vectors squared
  76693. */
  76694. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76695. /**
  76696. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76697. * @param value1 value to calulate the center between
  76698. * @param value2 value to calulate the center between
  76699. * @return the center between the two vectors
  76700. */
  76701. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76702. /**
  76703. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76704. * This methods computes transformed normalized direction vectors only.
  76705. * @param vector the vector to transform
  76706. * @param transformation the transformation matrix to apply
  76707. * @returns the new vector
  76708. */
  76709. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76710. /**
  76711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76712. * This methods computes transformed normalized direction vectors only.
  76713. * @param vector the vector to transform
  76714. * @param transformation the transformation matrix to apply
  76715. * @param result the vector to store the result in
  76716. */
  76717. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76718. /**
  76719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76720. * This methods computes transformed normalized direction vectors only.
  76721. * @param x value to transform
  76722. * @param y value to transform
  76723. * @param z value to transform
  76724. * @param w value to transform
  76725. * @param transformation the transformation matrix to apply
  76726. * @param result the vector to store the results in
  76727. */
  76728. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76729. /**
  76730. * Creates a new Vector4 from a Vector3
  76731. * @param source defines the source data
  76732. * @param w defines the 4th component (default is 0)
  76733. * @returns a new Vector4
  76734. */
  76735. static FromVector3(source: Vector3, w?: number): Vector4;
  76736. }
  76737. /**
  76738. * Class used to store quaternion data
  76739. * @see https://en.wikipedia.org/wiki/Quaternion
  76740. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76741. */
  76742. export class Quaternion {
  76743. /** defines the first component (0 by default) */
  76744. x: number;
  76745. /** defines the second component (0 by default) */
  76746. y: number;
  76747. /** defines the third component (0 by default) */
  76748. z: number;
  76749. /** defines the fourth component (1.0 by default) */
  76750. w: number;
  76751. /**
  76752. * Creates a new Quaternion from the given floats
  76753. * @param x defines the first component (0 by default)
  76754. * @param y defines the second component (0 by default)
  76755. * @param z defines the third component (0 by default)
  76756. * @param w defines the fourth component (1.0 by default)
  76757. */
  76758. constructor(
  76759. /** defines the first component (0 by default) */
  76760. x?: number,
  76761. /** defines the second component (0 by default) */
  76762. y?: number,
  76763. /** defines the third component (0 by default) */
  76764. z?: number,
  76765. /** defines the fourth component (1.0 by default) */
  76766. w?: number);
  76767. /**
  76768. * Gets a string representation for the current quaternion
  76769. * @returns a string with the Quaternion coordinates
  76770. */
  76771. toString(): string;
  76772. /**
  76773. * Gets the class name of the quaternion
  76774. * @returns the string "Quaternion"
  76775. */
  76776. getClassName(): string;
  76777. /**
  76778. * Gets a hash code for this quaternion
  76779. * @returns the quaternion hash code
  76780. */
  76781. getHashCode(): number;
  76782. /**
  76783. * Copy the quaternion to an array
  76784. * @returns a new array populated with 4 elements from the quaternion coordinates
  76785. */
  76786. asArray(): number[];
  76787. /**
  76788. * Check if two quaternions are equals
  76789. * @param otherQuaternion defines the second operand
  76790. * @return true if the current quaternion and the given one coordinates are strictly equals
  76791. */
  76792. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76793. /**
  76794. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76795. * @param otherQuaternion defines the other quaternion
  76796. * @param epsilon defines the minimal distance to consider equality
  76797. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76798. */
  76799. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76800. /**
  76801. * Clone the current quaternion
  76802. * @returns a new quaternion copied from the current one
  76803. */
  76804. clone(): Quaternion;
  76805. /**
  76806. * Copy a quaternion to the current one
  76807. * @param other defines the other quaternion
  76808. * @returns the updated current quaternion
  76809. */
  76810. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76811. /**
  76812. * Updates the current quaternion with the given float coordinates
  76813. * @param x defines the x coordinate
  76814. * @param y defines the y coordinate
  76815. * @param z defines the z coordinate
  76816. * @param w defines the w coordinate
  76817. * @returns the updated current quaternion
  76818. */
  76819. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76820. /**
  76821. * Updates the current quaternion from the given float coordinates
  76822. * @param x defines the x coordinate
  76823. * @param y defines the y coordinate
  76824. * @param z defines the z coordinate
  76825. * @param w defines the w coordinate
  76826. * @returns the updated current quaternion
  76827. */
  76828. set(x: number, y: number, z: number, w: number): Quaternion;
  76829. /**
  76830. * Adds two quaternions
  76831. * @param other defines the second operand
  76832. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76833. */
  76834. add(other: DeepImmutable<Quaternion>): Quaternion;
  76835. /**
  76836. * Add a quaternion to the current one
  76837. * @param other defines the quaternion to add
  76838. * @returns the current quaternion
  76839. */
  76840. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76841. /**
  76842. * Subtract two quaternions
  76843. * @param other defines the second operand
  76844. * @returns a new quaternion as the subtraction result of the given one from the current one
  76845. */
  76846. subtract(other: Quaternion): Quaternion;
  76847. /**
  76848. * Multiplies the current quaternion by a scale factor
  76849. * @param value defines the scale factor
  76850. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76851. */
  76852. scale(value: number): Quaternion;
  76853. /**
  76854. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76855. * @param scale defines the scale factor
  76856. * @param result defines the Quaternion object where to store the result
  76857. * @returns the unmodified current quaternion
  76858. */
  76859. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76860. /**
  76861. * Multiplies in place the current quaternion by a scale factor
  76862. * @param value defines the scale factor
  76863. * @returns the current modified quaternion
  76864. */
  76865. scaleInPlace(value: number): Quaternion;
  76866. /**
  76867. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76868. * @param scale defines the scale factor
  76869. * @param result defines the Quaternion object where to store the result
  76870. * @returns the unmodified current quaternion
  76871. */
  76872. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76873. /**
  76874. * Multiplies two quaternions
  76875. * @param q1 defines the second operand
  76876. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76877. */
  76878. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76879. /**
  76880. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76881. * @param q1 defines the second operand
  76882. * @param result defines the target quaternion
  76883. * @returns the current quaternion
  76884. */
  76885. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76886. /**
  76887. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76888. * @param q1 defines the second operand
  76889. * @returns the currentupdated quaternion
  76890. */
  76891. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76892. /**
  76893. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76894. * @param ref defines the target quaternion
  76895. * @returns the current quaternion
  76896. */
  76897. conjugateToRef(ref: Quaternion): Quaternion;
  76898. /**
  76899. * Conjugates in place (1-q) the current quaternion
  76900. * @returns the current updated quaternion
  76901. */
  76902. conjugateInPlace(): Quaternion;
  76903. /**
  76904. * Conjugates in place (1-q) the current quaternion
  76905. * @returns a new quaternion
  76906. */
  76907. conjugate(): Quaternion;
  76908. /**
  76909. * Gets length of current quaternion
  76910. * @returns the quaternion length (float)
  76911. */
  76912. length(): number;
  76913. /**
  76914. * Normalize in place the current quaternion
  76915. * @returns the current updated quaternion
  76916. */
  76917. normalize(): Quaternion;
  76918. /**
  76919. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76920. * @param order is a reserved parameter and is ignore for now
  76921. * @returns a new Vector3 containing the Euler angles
  76922. */
  76923. toEulerAngles(order?: string): Vector3;
  76924. /**
  76925. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76926. * @param result defines the vector which will be filled with the Euler angles
  76927. * @param order is a reserved parameter and is ignore for now
  76928. * @returns the current unchanged quaternion
  76929. */
  76930. toEulerAnglesToRef(result: Vector3): Quaternion;
  76931. /**
  76932. * Updates the given rotation matrix with the current quaternion values
  76933. * @param result defines the target matrix
  76934. * @returns the current unchanged quaternion
  76935. */
  76936. toRotationMatrix(result: Matrix): Quaternion;
  76937. /**
  76938. * Updates the current quaternion from the given rotation matrix values
  76939. * @param matrix defines the source matrix
  76940. * @returns the current updated quaternion
  76941. */
  76942. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76943. /**
  76944. * Creates a new quaternion from a rotation matrix
  76945. * @param matrix defines the source matrix
  76946. * @returns a new quaternion created from the given rotation matrix values
  76947. */
  76948. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76949. /**
  76950. * Updates the given quaternion with the given rotation matrix values
  76951. * @param matrix defines the source matrix
  76952. * @param result defines the target quaternion
  76953. */
  76954. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76955. /**
  76956. * Returns the dot product (float) between the quaternions "left" and "right"
  76957. * @param left defines the left operand
  76958. * @param right defines the right operand
  76959. * @returns the dot product
  76960. */
  76961. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76962. /**
  76963. * Checks if the two quaternions are close to each other
  76964. * @param quat0 defines the first quaternion to check
  76965. * @param quat1 defines the second quaternion to check
  76966. * @returns true if the two quaternions are close to each other
  76967. */
  76968. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76969. /**
  76970. * Creates an empty quaternion
  76971. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76972. */
  76973. static Zero(): Quaternion;
  76974. /**
  76975. * Inverse a given quaternion
  76976. * @param q defines the source quaternion
  76977. * @returns a new quaternion as the inverted current quaternion
  76978. */
  76979. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76980. /**
  76981. * Inverse a given quaternion
  76982. * @param q defines the source quaternion
  76983. * @param result the quaternion the result will be stored in
  76984. * @returns the result quaternion
  76985. */
  76986. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76987. /**
  76988. * Creates an identity quaternion
  76989. * @returns the identity quaternion
  76990. */
  76991. static Identity(): Quaternion;
  76992. /**
  76993. * Gets a boolean indicating if the given quaternion is identity
  76994. * @param quaternion defines the quaternion to check
  76995. * @returns true if the quaternion is identity
  76996. */
  76997. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76998. /**
  76999. * Creates a quaternion from a rotation around an axis
  77000. * @param axis defines the axis to use
  77001. * @param angle defines the angle to use
  77002. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77003. */
  77004. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77005. /**
  77006. * Creates a rotation around an axis and stores it into the given quaternion
  77007. * @param axis defines the axis to use
  77008. * @param angle defines the angle to use
  77009. * @param result defines the target quaternion
  77010. * @returns the target quaternion
  77011. */
  77012. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77013. /**
  77014. * Creates a new quaternion from data stored into an array
  77015. * @param array defines the data source
  77016. * @param offset defines the offset in the source array where the data starts
  77017. * @returns a new quaternion
  77018. */
  77019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77020. /**
  77021. * Create a quaternion from Euler rotation angles
  77022. * @param x Pitch
  77023. * @param y Yaw
  77024. * @param z Roll
  77025. * @returns the new Quaternion
  77026. */
  77027. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77028. /**
  77029. * Updates a quaternion from Euler rotation angles
  77030. * @param x Pitch
  77031. * @param y Yaw
  77032. * @param z Roll
  77033. * @param result the quaternion to store the result
  77034. * @returns the updated quaternion
  77035. */
  77036. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77037. /**
  77038. * Create a quaternion from Euler rotation vector
  77039. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77040. * @returns the new Quaternion
  77041. */
  77042. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77043. /**
  77044. * Updates a quaternion from Euler rotation vector
  77045. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77046. * @param result the quaternion to store the result
  77047. * @returns the updated quaternion
  77048. */
  77049. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77050. /**
  77051. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77052. * @param yaw defines the rotation around Y axis
  77053. * @param pitch defines the rotation around X axis
  77054. * @param roll defines the rotation around Z axis
  77055. * @returns the new quaternion
  77056. */
  77057. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77058. /**
  77059. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77060. * @param yaw defines the rotation around Y axis
  77061. * @param pitch defines the rotation around X axis
  77062. * @param roll defines the rotation around Z axis
  77063. * @param result defines the target quaternion
  77064. */
  77065. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77066. /**
  77067. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77068. * @param alpha defines the rotation around first axis
  77069. * @param beta defines the rotation around second axis
  77070. * @param gamma defines the rotation around third axis
  77071. * @returns the new quaternion
  77072. */
  77073. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77074. /**
  77075. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77076. * @param alpha defines the rotation around first axis
  77077. * @param beta defines the rotation around second axis
  77078. * @param gamma defines the rotation around third axis
  77079. * @param result defines the target quaternion
  77080. */
  77081. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77082. /**
  77083. * 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)
  77084. * @param axis1 defines the first axis
  77085. * @param axis2 defines the second axis
  77086. * @param axis3 defines the third axis
  77087. * @returns the new quaternion
  77088. */
  77089. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77090. /**
  77091. * 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
  77092. * @param axis1 defines the first axis
  77093. * @param axis2 defines the second axis
  77094. * @param axis3 defines the third axis
  77095. * @param ref defines the target quaternion
  77096. */
  77097. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77098. /**
  77099. * Interpolates between two quaternions
  77100. * @param left defines first quaternion
  77101. * @param right defines second quaternion
  77102. * @param amount defines the gradient to use
  77103. * @returns the new interpolated quaternion
  77104. */
  77105. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77106. /**
  77107. * Interpolates between two quaternions and stores it into a target quaternion
  77108. * @param left defines first quaternion
  77109. * @param right defines second quaternion
  77110. * @param amount defines the gradient to use
  77111. * @param result defines the target quaternion
  77112. */
  77113. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77114. /**
  77115. * Interpolate between two quaternions using Hermite interpolation
  77116. * @param value1 defines first quaternion
  77117. * @param tangent1 defines the incoming tangent
  77118. * @param value2 defines second quaternion
  77119. * @param tangent2 defines the outgoing tangent
  77120. * @param amount defines the target quaternion
  77121. * @returns the new interpolated quaternion
  77122. */
  77123. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77124. }
  77125. /**
  77126. * Class used to store matrix data (4x4)
  77127. */
  77128. export class Matrix {
  77129. private static _updateFlagSeed;
  77130. private static _identityReadOnly;
  77131. private _isIdentity;
  77132. private _isIdentityDirty;
  77133. private _isIdentity3x2;
  77134. private _isIdentity3x2Dirty;
  77135. /**
  77136. * Gets the update flag of the matrix which is an unique number for the matrix.
  77137. * It will be incremented every time the matrix data change.
  77138. * You can use it to speed the comparison between two versions of the same matrix.
  77139. */
  77140. updateFlag: number;
  77141. private readonly _m;
  77142. /**
  77143. * Gets the internal data of the matrix
  77144. */
  77145. get m(): DeepImmutable<Float32Array>;
  77146. /** @hidden */
  77147. _markAsUpdated(): void;
  77148. /** @hidden */
  77149. private _updateIdentityStatus;
  77150. /**
  77151. * Creates an empty matrix (filled with zeros)
  77152. */
  77153. constructor();
  77154. /**
  77155. * Check if the current matrix is identity
  77156. * @returns true is the matrix is the identity matrix
  77157. */
  77158. isIdentity(): boolean;
  77159. /**
  77160. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77161. * @returns true is the matrix is the identity matrix
  77162. */
  77163. isIdentityAs3x2(): boolean;
  77164. /**
  77165. * Gets the determinant of the matrix
  77166. * @returns the matrix determinant
  77167. */
  77168. determinant(): number;
  77169. /**
  77170. * Returns the matrix as a Float32Array
  77171. * @returns the matrix underlying array
  77172. */
  77173. toArray(): DeepImmutable<Float32Array>;
  77174. /**
  77175. * Returns the matrix as a Float32Array
  77176. * @returns the matrix underlying array.
  77177. */
  77178. asArray(): DeepImmutable<Float32Array>;
  77179. /**
  77180. * Inverts the current matrix in place
  77181. * @returns the current inverted matrix
  77182. */
  77183. invert(): Matrix;
  77184. /**
  77185. * Sets all the matrix elements to zero
  77186. * @returns the current matrix
  77187. */
  77188. reset(): Matrix;
  77189. /**
  77190. * Adds the current matrix with a second one
  77191. * @param other defines the matrix to add
  77192. * @returns a new matrix as the addition of the current matrix and the given one
  77193. */
  77194. add(other: DeepImmutable<Matrix>): Matrix;
  77195. /**
  77196. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77197. * @param other defines the matrix to add
  77198. * @param result defines the target matrix
  77199. * @returns the current matrix
  77200. */
  77201. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77202. /**
  77203. * Adds in place the given matrix to the current matrix
  77204. * @param other defines the second operand
  77205. * @returns the current updated matrix
  77206. */
  77207. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77208. /**
  77209. * Sets the given matrix to the current inverted Matrix
  77210. * @param other defines the target matrix
  77211. * @returns the unmodified current matrix
  77212. */
  77213. invertToRef(other: Matrix): Matrix;
  77214. /**
  77215. * add a value at the specified position in the current Matrix
  77216. * @param index the index of the value within the matrix. between 0 and 15.
  77217. * @param value the value to be added
  77218. * @returns the current updated matrix
  77219. */
  77220. addAtIndex(index: number, value: number): Matrix;
  77221. /**
  77222. * mutiply the specified position in the current Matrix by a value
  77223. * @param index the index of the value within the matrix. between 0 and 15.
  77224. * @param value the value to be added
  77225. * @returns the current updated matrix
  77226. */
  77227. multiplyAtIndex(index: number, value: number): Matrix;
  77228. /**
  77229. * Inserts the translation vector (using 3 floats) in the current matrix
  77230. * @param x defines the 1st component of the translation
  77231. * @param y defines the 2nd component of the translation
  77232. * @param z defines the 3rd component of the translation
  77233. * @returns the current updated matrix
  77234. */
  77235. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77236. /**
  77237. * Adds the translation vector (using 3 floats) in the current matrix
  77238. * @param x defines the 1st component of the translation
  77239. * @param y defines the 2nd component of the translation
  77240. * @param z defines the 3rd component of the translation
  77241. * @returns the current updated matrix
  77242. */
  77243. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77244. /**
  77245. * Inserts the translation vector in the current matrix
  77246. * @param vector3 defines the translation to insert
  77247. * @returns the current updated matrix
  77248. */
  77249. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77250. /**
  77251. * Gets the translation value of the current matrix
  77252. * @returns a new Vector3 as the extracted translation from the matrix
  77253. */
  77254. getTranslation(): Vector3;
  77255. /**
  77256. * Fill a Vector3 with the extracted translation from the matrix
  77257. * @param result defines the Vector3 where to store the translation
  77258. * @returns the current matrix
  77259. */
  77260. getTranslationToRef(result: Vector3): Matrix;
  77261. /**
  77262. * Remove rotation and scaling part from the matrix
  77263. * @returns the updated matrix
  77264. */
  77265. removeRotationAndScaling(): Matrix;
  77266. /**
  77267. * Multiply two matrices
  77268. * @param other defines the second operand
  77269. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77270. */
  77271. multiply(other: DeepImmutable<Matrix>): Matrix;
  77272. /**
  77273. * Copy the current matrix from the given one
  77274. * @param other defines the source matrix
  77275. * @returns the current updated matrix
  77276. */
  77277. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77278. /**
  77279. * Populates the given array from the starting index with the current matrix values
  77280. * @param array defines the target array
  77281. * @param offset defines the offset in the target array where to start storing values
  77282. * @returns the current matrix
  77283. */
  77284. copyToArray(array: Float32Array, offset?: number): Matrix;
  77285. /**
  77286. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77287. * @param other defines the second operand
  77288. * @param result defines the matrix where to store the multiplication
  77289. * @returns the current matrix
  77290. */
  77291. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77292. /**
  77293. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77294. * @param other defines the second operand
  77295. * @param result defines the array where to store the multiplication
  77296. * @param offset defines the offset in the target array where to start storing values
  77297. * @returns the current matrix
  77298. */
  77299. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77300. /**
  77301. * Check equality between this matrix and a second one
  77302. * @param value defines the second matrix to compare
  77303. * @returns true is the current matrix and the given one values are strictly equal
  77304. */
  77305. equals(value: DeepImmutable<Matrix>): boolean;
  77306. /**
  77307. * Clone the current matrix
  77308. * @returns a new matrix from the current matrix
  77309. */
  77310. clone(): Matrix;
  77311. /**
  77312. * Returns the name of the current matrix class
  77313. * @returns the string "Matrix"
  77314. */
  77315. getClassName(): string;
  77316. /**
  77317. * Gets the hash code of the current matrix
  77318. * @returns the hash code
  77319. */
  77320. getHashCode(): number;
  77321. /**
  77322. * Decomposes the current Matrix into a translation, rotation and scaling components
  77323. * @param scale defines the scale vector3 given as a reference to update
  77324. * @param rotation defines the rotation quaternion given as a reference to update
  77325. * @param translation defines the translation vector3 given as a reference to update
  77326. * @returns true if operation was successful
  77327. */
  77328. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77329. /**
  77330. * Gets specific row of the matrix
  77331. * @param index defines the number of the row to get
  77332. * @returns the index-th row of the current matrix as a new Vector4
  77333. */
  77334. getRow(index: number): Nullable<Vector4>;
  77335. /**
  77336. * Sets the index-th row of the current matrix to the vector4 values
  77337. * @param index defines the number of the row to set
  77338. * @param row defines the target vector4
  77339. * @returns the updated current matrix
  77340. */
  77341. setRow(index: number, row: Vector4): Matrix;
  77342. /**
  77343. * Compute the transpose of the matrix
  77344. * @returns the new transposed matrix
  77345. */
  77346. transpose(): Matrix;
  77347. /**
  77348. * Compute the transpose of the matrix and store it in a given matrix
  77349. * @param result defines the target matrix
  77350. * @returns the current matrix
  77351. */
  77352. transposeToRef(result: Matrix): Matrix;
  77353. /**
  77354. * Sets the index-th row of the current matrix with the given 4 x float values
  77355. * @param index defines the row index
  77356. * @param x defines the x component to set
  77357. * @param y defines the y component to set
  77358. * @param z defines the z component to set
  77359. * @param w defines the w component to set
  77360. * @returns the updated current matrix
  77361. */
  77362. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77363. /**
  77364. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77365. * @param scale defines the scale factor
  77366. * @returns a new matrix
  77367. */
  77368. scale(scale: number): Matrix;
  77369. /**
  77370. * Scale the current matrix values by a factor to a given result matrix
  77371. * @param scale defines the scale factor
  77372. * @param result defines the matrix to store the result
  77373. * @returns the current matrix
  77374. */
  77375. scaleToRef(scale: number, result: Matrix): Matrix;
  77376. /**
  77377. * Scale the current matrix values by a factor and add the result to a given matrix
  77378. * @param scale defines the scale factor
  77379. * @param result defines the Matrix to store the result
  77380. * @returns the current matrix
  77381. */
  77382. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77383. /**
  77384. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77385. * @param ref matrix to store the result
  77386. */
  77387. toNormalMatrix(ref: Matrix): void;
  77388. /**
  77389. * Gets only rotation part of the current matrix
  77390. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77391. */
  77392. getRotationMatrix(): Matrix;
  77393. /**
  77394. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77395. * @param result defines the target matrix to store data to
  77396. * @returns the current matrix
  77397. */
  77398. getRotationMatrixToRef(result: Matrix): Matrix;
  77399. /**
  77400. * Toggles model matrix from being right handed to left handed in place and vice versa
  77401. */
  77402. toggleModelMatrixHandInPlace(): void;
  77403. /**
  77404. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77405. */
  77406. toggleProjectionMatrixHandInPlace(): void;
  77407. /**
  77408. * Creates a matrix from an array
  77409. * @param array defines the source array
  77410. * @param offset defines an offset in the source array
  77411. * @returns a new Matrix set from the starting index of the given array
  77412. */
  77413. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77414. /**
  77415. * Copy the content of an array into a given matrix
  77416. * @param array defines the source array
  77417. * @param offset defines an offset in the source array
  77418. * @param result defines the target matrix
  77419. */
  77420. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77421. /**
  77422. * Stores an array into a matrix after having multiplied each component by a given factor
  77423. * @param array defines the source array
  77424. * @param offset defines the offset in the source array
  77425. * @param scale defines the scaling factor
  77426. * @param result defines the target matrix
  77427. */
  77428. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77429. /**
  77430. * Gets an identity matrix that must not be updated
  77431. */
  77432. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77433. /**
  77434. * Stores a list of values (16) inside a given matrix
  77435. * @param initialM11 defines 1st value of 1st row
  77436. * @param initialM12 defines 2nd value of 1st row
  77437. * @param initialM13 defines 3rd value of 1st row
  77438. * @param initialM14 defines 4th value of 1st row
  77439. * @param initialM21 defines 1st value of 2nd row
  77440. * @param initialM22 defines 2nd value of 2nd row
  77441. * @param initialM23 defines 3rd value of 2nd row
  77442. * @param initialM24 defines 4th value of 2nd row
  77443. * @param initialM31 defines 1st value of 3rd row
  77444. * @param initialM32 defines 2nd value of 3rd row
  77445. * @param initialM33 defines 3rd value of 3rd row
  77446. * @param initialM34 defines 4th value of 3rd row
  77447. * @param initialM41 defines 1st value of 4th row
  77448. * @param initialM42 defines 2nd value of 4th row
  77449. * @param initialM43 defines 3rd value of 4th row
  77450. * @param initialM44 defines 4th value of 4th row
  77451. * @param result defines the target matrix
  77452. */
  77453. 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;
  77454. /**
  77455. * Creates new matrix from a list of values (16)
  77456. * @param initialM11 defines 1st value of 1st row
  77457. * @param initialM12 defines 2nd value of 1st row
  77458. * @param initialM13 defines 3rd value of 1st row
  77459. * @param initialM14 defines 4th value of 1st row
  77460. * @param initialM21 defines 1st value of 2nd row
  77461. * @param initialM22 defines 2nd value of 2nd row
  77462. * @param initialM23 defines 3rd value of 2nd row
  77463. * @param initialM24 defines 4th value of 2nd row
  77464. * @param initialM31 defines 1st value of 3rd row
  77465. * @param initialM32 defines 2nd value of 3rd row
  77466. * @param initialM33 defines 3rd value of 3rd row
  77467. * @param initialM34 defines 4th value of 3rd row
  77468. * @param initialM41 defines 1st value of 4th row
  77469. * @param initialM42 defines 2nd value of 4th row
  77470. * @param initialM43 defines 3rd value of 4th row
  77471. * @param initialM44 defines 4th value of 4th row
  77472. * @returns the new matrix
  77473. */
  77474. 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;
  77475. /**
  77476. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77477. * @param scale defines the scale vector3
  77478. * @param rotation defines the rotation quaternion
  77479. * @param translation defines the translation vector3
  77480. * @returns a new matrix
  77481. */
  77482. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77483. /**
  77484. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77485. * @param scale defines the scale vector3
  77486. * @param rotation defines the rotation quaternion
  77487. * @param translation defines the translation vector3
  77488. * @param result defines the target matrix
  77489. */
  77490. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77491. /**
  77492. * Creates a new identity matrix
  77493. * @returns a new identity matrix
  77494. */
  77495. static Identity(): Matrix;
  77496. /**
  77497. * Creates a new identity matrix and stores the result in a given matrix
  77498. * @param result defines the target matrix
  77499. */
  77500. static IdentityToRef(result: Matrix): void;
  77501. /**
  77502. * Creates a new zero matrix
  77503. * @returns a new zero matrix
  77504. */
  77505. static Zero(): Matrix;
  77506. /**
  77507. * Creates a new rotation matrix for "angle" radians around the X axis
  77508. * @param angle defines the angle (in radians) to use
  77509. * @return the new matrix
  77510. */
  77511. static RotationX(angle: number): Matrix;
  77512. /**
  77513. * Creates a new matrix as the invert of a given matrix
  77514. * @param source defines the source matrix
  77515. * @returns the new matrix
  77516. */
  77517. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77518. /**
  77519. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77520. * @param angle defines the angle (in radians) to use
  77521. * @param result defines the target matrix
  77522. */
  77523. static RotationXToRef(angle: number, result: Matrix): void;
  77524. /**
  77525. * Creates a new rotation matrix for "angle" radians around the Y axis
  77526. * @param angle defines the angle (in radians) to use
  77527. * @return the new matrix
  77528. */
  77529. static RotationY(angle: number): Matrix;
  77530. /**
  77531. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77532. * @param angle defines the angle (in radians) to use
  77533. * @param result defines the target matrix
  77534. */
  77535. static RotationYToRef(angle: number, result: Matrix): void;
  77536. /**
  77537. * Creates a new rotation matrix for "angle" radians around the Z axis
  77538. * @param angle defines the angle (in radians) to use
  77539. * @return the new matrix
  77540. */
  77541. static RotationZ(angle: number): Matrix;
  77542. /**
  77543. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77544. * @param angle defines the angle (in radians) to use
  77545. * @param result defines the target matrix
  77546. */
  77547. static RotationZToRef(angle: number, result: Matrix): void;
  77548. /**
  77549. * Creates a new rotation matrix for "angle" radians around the given axis
  77550. * @param axis defines the axis to use
  77551. * @param angle defines the angle (in radians) to use
  77552. * @return the new matrix
  77553. */
  77554. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77555. /**
  77556. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77557. * @param axis defines the axis to use
  77558. * @param angle defines the angle (in radians) to use
  77559. * @param result defines the target matrix
  77560. */
  77561. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77562. /**
  77563. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77564. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77565. * @param from defines the vector to align
  77566. * @param to defines the vector to align to
  77567. * @param result defines the target matrix
  77568. */
  77569. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77570. /**
  77571. * Creates a rotation matrix
  77572. * @param yaw defines the yaw angle in radians (Y axis)
  77573. * @param pitch defines the pitch angle in radians (X axis)
  77574. * @param roll defines the roll angle in radians (X axis)
  77575. * @returns the new rotation matrix
  77576. */
  77577. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77578. /**
  77579. * Creates a rotation matrix and stores it in a given matrix
  77580. * @param yaw defines the yaw angle in radians (Y axis)
  77581. * @param pitch defines the pitch angle in radians (X axis)
  77582. * @param roll defines the roll angle in radians (X axis)
  77583. * @param result defines the target matrix
  77584. */
  77585. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77586. /**
  77587. * Creates a scaling matrix
  77588. * @param x defines the scale factor on X axis
  77589. * @param y defines the scale factor on Y axis
  77590. * @param z defines the scale factor on Z axis
  77591. * @returns the new matrix
  77592. */
  77593. static Scaling(x: number, y: number, z: number): Matrix;
  77594. /**
  77595. * Creates a scaling matrix and stores it in a given matrix
  77596. * @param x defines the scale factor on X axis
  77597. * @param y defines the scale factor on Y axis
  77598. * @param z defines the scale factor on Z axis
  77599. * @param result defines the target matrix
  77600. */
  77601. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77602. /**
  77603. * Creates a translation matrix
  77604. * @param x defines the translation on X axis
  77605. * @param y defines the translation on Y axis
  77606. * @param z defines the translationon Z axis
  77607. * @returns the new matrix
  77608. */
  77609. static Translation(x: number, y: number, z: number): Matrix;
  77610. /**
  77611. * Creates a translation matrix and stores it in a given matrix
  77612. * @param x defines the translation on X axis
  77613. * @param y defines the translation on Y axis
  77614. * @param z defines the translationon Z axis
  77615. * @param result defines the target matrix
  77616. */
  77617. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77618. /**
  77619. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77620. * @param startValue defines the start value
  77621. * @param endValue defines the end value
  77622. * @param gradient defines the gradient factor
  77623. * @returns the new matrix
  77624. */
  77625. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77626. /**
  77627. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77628. * @param startValue defines the start value
  77629. * @param endValue defines the end value
  77630. * @param gradient defines the gradient factor
  77631. * @param result defines the Matrix object where to store data
  77632. */
  77633. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77634. /**
  77635. * Builds a new matrix whose values are computed by:
  77636. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77637. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77638. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77639. * @param startValue defines the first matrix
  77640. * @param endValue defines the second matrix
  77641. * @param gradient defines the gradient between the two matrices
  77642. * @returns the new matrix
  77643. */
  77644. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77645. /**
  77646. * Update a matrix to values which are computed by:
  77647. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77648. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77649. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77650. * @param startValue defines the first matrix
  77651. * @param endValue defines the second matrix
  77652. * @param gradient defines the gradient between the two matrices
  77653. * @param result defines the target matrix
  77654. */
  77655. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77656. /**
  77657. * 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"
  77658. * This function works in left handed mode
  77659. * @param eye defines the final position of the entity
  77660. * @param target defines where the entity should look at
  77661. * @param up defines the up vector for the entity
  77662. * @returns the new matrix
  77663. */
  77664. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77665. /**
  77666. * 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".
  77667. * This function works in left handed mode
  77668. * @param eye defines the final position of the entity
  77669. * @param target defines where the entity should look at
  77670. * @param up defines the up vector for the entity
  77671. * @param result defines the target matrix
  77672. */
  77673. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77674. /**
  77675. * 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"
  77676. * This function works in right handed mode
  77677. * @param eye defines the final position of the entity
  77678. * @param target defines where the entity should look at
  77679. * @param up defines the up vector for the entity
  77680. * @returns the new matrix
  77681. */
  77682. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77683. /**
  77684. * 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".
  77685. * This function works in right handed mode
  77686. * @param eye defines the final position of the entity
  77687. * @param target defines where the entity should look at
  77688. * @param up defines the up vector for the entity
  77689. * @param result defines the target matrix
  77690. */
  77691. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77692. /**
  77693. * Create a left-handed orthographic projection matrix
  77694. * @param width defines the viewport width
  77695. * @param height defines the viewport height
  77696. * @param znear defines the near clip plane
  77697. * @param zfar defines the far clip plane
  77698. * @returns a new matrix as a left-handed orthographic projection matrix
  77699. */
  77700. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77701. /**
  77702. * Store a left-handed orthographic projection to a given matrix
  77703. * @param width defines the viewport width
  77704. * @param height defines the viewport height
  77705. * @param znear defines the near clip plane
  77706. * @param zfar defines the far clip plane
  77707. * @param result defines the target matrix
  77708. */
  77709. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77710. /**
  77711. * Create a left-handed orthographic projection matrix
  77712. * @param left defines the viewport left coordinate
  77713. * @param right defines the viewport right coordinate
  77714. * @param bottom defines the viewport bottom coordinate
  77715. * @param top defines the viewport top coordinate
  77716. * @param znear defines the near clip plane
  77717. * @param zfar defines the far clip plane
  77718. * @returns a new matrix as a left-handed orthographic projection matrix
  77719. */
  77720. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77721. /**
  77722. * Stores a left-handed orthographic projection into a given matrix
  77723. * @param left defines the viewport left coordinate
  77724. * @param right defines the viewport right coordinate
  77725. * @param bottom defines the viewport bottom coordinate
  77726. * @param top defines the viewport top coordinate
  77727. * @param znear defines the near clip plane
  77728. * @param zfar defines the far clip plane
  77729. * @param result defines the target matrix
  77730. */
  77731. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77732. /**
  77733. * Creates a right-handed orthographic projection matrix
  77734. * @param left defines the viewport left coordinate
  77735. * @param right defines the viewport right coordinate
  77736. * @param bottom defines the viewport bottom coordinate
  77737. * @param top defines the viewport top coordinate
  77738. * @param znear defines the near clip plane
  77739. * @param zfar defines the far clip plane
  77740. * @returns a new matrix as a right-handed orthographic projection matrix
  77741. */
  77742. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77743. /**
  77744. * Stores a right-handed orthographic projection into a given matrix
  77745. * @param left defines the viewport left coordinate
  77746. * @param right defines the viewport right coordinate
  77747. * @param bottom defines the viewport bottom coordinate
  77748. * @param top defines the viewport top coordinate
  77749. * @param znear defines the near clip plane
  77750. * @param zfar defines the far clip plane
  77751. * @param result defines the target matrix
  77752. */
  77753. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77754. /**
  77755. * Creates a left-handed perspective projection matrix
  77756. * @param width defines the viewport width
  77757. * @param height defines the viewport height
  77758. * @param znear defines the near clip plane
  77759. * @param zfar defines the far clip plane
  77760. * @returns a new matrix as a left-handed perspective projection matrix
  77761. */
  77762. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77763. /**
  77764. * Creates a left-handed perspective projection matrix
  77765. * @param fov defines the horizontal field of view
  77766. * @param aspect defines the aspect ratio
  77767. * @param znear defines the near clip plane
  77768. * @param zfar defines the far clip plane
  77769. * @returns a new matrix as a left-handed perspective projection matrix
  77770. */
  77771. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77772. /**
  77773. * Stores a left-handed perspective projection into a given matrix
  77774. * @param fov defines the horizontal field of view
  77775. * @param aspect defines the aspect ratio
  77776. * @param znear defines the near clip plane
  77777. * @param zfar defines the far clip plane
  77778. * @param result defines the target matrix
  77779. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77780. */
  77781. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77782. /**
  77783. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77784. * @param fov defines the horizontal field of view
  77785. * @param aspect defines the aspect ratio
  77786. * @param znear defines the near clip plane
  77787. * @param zfar not used as infinity is used as far clip
  77788. * @param result defines the target matrix
  77789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77790. */
  77791. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77792. /**
  77793. * Creates a right-handed perspective projection matrix
  77794. * @param fov defines the horizontal field of view
  77795. * @param aspect defines the aspect ratio
  77796. * @param znear defines the near clip plane
  77797. * @param zfar defines the far clip plane
  77798. * @returns a new matrix as a right-handed perspective projection matrix
  77799. */
  77800. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77801. /**
  77802. * Stores a right-handed perspective projection into a given matrix
  77803. * @param fov defines the horizontal field of view
  77804. * @param aspect defines the aspect ratio
  77805. * @param znear defines the near clip plane
  77806. * @param zfar defines the far clip plane
  77807. * @param result defines the target matrix
  77808. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77809. */
  77810. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77811. /**
  77812. * Stores a right-handed perspective projection into a given matrix
  77813. * @param fov defines the horizontal field of view
  77814. * @param aspect defines the aspect ratio
  77815. * @param znear defines the near clip plane
  77816. * @param zfar not used as infinity is used as far clip
  77817. * @param result defines the target matrix
  77818. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77819. */
  77820. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77821. /**
  77822. * Stores a perspective projection for WebVR info a given matrix
  77823. * @param fov defines the field of view
  77824. * @param znear defines the near clip plane
  77825. * @param zfar defines the far clip plane
  77826. * @param result defines the target matrix
  77827. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77828. */
  77829. static PerspectiveFovWebVRToRef(fov: {
  77830. upDegrees: number;
  77831. downDegrees: number;
  77832. leftDegrees: number;
  77833. rightDegrees: number;
  77834. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77835. /**
  77836. * Computes a complete transformation matrix
  77837. * @param viewport defines the viewport to use
  77838. * @param world defines the world matrix
  77839. * @param view defines the view matrix
  77840. * @param projection defines the projection matrix
  77841. * @param zmin defines the near clip plane
  77842. * @param zmax defines the far clip plane
  77843. * @returns the transformation matrix
  77844. */
  77845. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77846. /**
  77847. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77848. * @param matrix defines the matrix to use
  77849. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77850. */
  77851. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77852. /**
  77853. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77854. * @param matrix defines the matrix to use
  77855. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77856. */
  77857. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77858. /**
  77859. * Compute the transpose of a given matrix
  77860. * @param matrix defines the matrix to transpose
  77861. * @returns the new matrix
  77862. */
  77863. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77864. /**
  77865. * Compute the transpose of a matrix and store it in a target matrix
  77866. * @param matrix defines the matrix to transpose
  77867. * @param result defines the target matrix
  77868. */
  77869. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77870. /**
  77871. * Computes a reflection matrix from a plane
  77872. * @param plane defines the reflection plane
  77873. * @returns a new matrix
  77874. */
  77875. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77876. /**
  77877. * Computes a reflection matrix from a plane
  77878. * @param plane defines the reflection plane
  77879. * @param result defines the target matrix
  77880. */
  77881. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77882. /**
  77883. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77884. * @param xaxis defines the value of the 1st axis
  77885. * @param yaxis defines the value of the 2nd axis
  77886. * @param zaxis defines the value of the 3rd axis
  77887. * @param result defines the target matrix
  77888. */
  77889. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77890. /**
  77891. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77892. * @param quat defines the quaternion to use
  77893. * @param result defines the target matrix
  77894. */
  77895. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77896. }
  77897. /**
  77898. * @hidden
  77899. */
  77900. export class TmpVectors {
  77901. static Vector2: Vector2[];
  77902. static Vector3: Vector3[];
  77903. static Vector4: Vector4[];
  77904. static Quaternion: Quaternion[];
  77905. static Matrix: Matrix[];
  77906. }
  77907. }
  77908. declare module BABYLON {
  77909. /**
  77910. * Defines potential orientation for back face culling
  77911. */
  77912. export enum Orientation {
  77913. /**
  77914. * Clockwise
  77915. */
  77916. CW = 0,
  77917. /** Counter clockwise */
  77918. CCW = 1
  77919. }
  77920. /** Class used to represent a Bezier curve */
  77921. export class BezierCurve {
  77922. /**
  77923. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77924. * @param t defines the time
  77925. * @param x1 defines the left coordinate on X axis
  77926. * @param y1 defines the left coordinate on Y axis
  77927. * @param x2 defines the right coordinate on X axis
  77928. * @param y2 defines the right coordinate on Y axis
  77929. * @returns the interpolated value
  77930. */
  77931. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77932. }
  77933. /**
  77934. * Defines angle representation
  77935. */
  77936. export class Angle {
  77937. private _radians;
  77938. /**
  77939. * Creates an Angle object of "radians" radians (float).
  77940. * @param radians the angle in radians
  77941. */
  77942. constructor(radians: number);
  77943. /**
  77944. * Get value in degrees
  77945. * @returns the Angle value in degrees (float)
  77946. */
  77947. degrees(): number;
  77948. /**
  77949. * Get value in radians
  77950. * @returns the Angle value in radians (float)
  77951. */
  77952. radians(): number;
  77953. /**
  77954. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77955. * @param a defines first vector
  77956. * @param b defines second vector
  77957. * @returns a new Angle
  77958. */
  77959. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77960. /**
  77961. * Gets a new Angle object from the given float in radians
  77962. * @param radians defines the angle value in radians
  77963. * @returns a new Angle
  77964. */
  77965. static FromRadians(radians: number): Angle;
  77966. /**
  77967. * Gets a new Angle object from the given float in degrees
  77968. * @param degrees defines the angle value in degrees
  77969. * @returns a new Angle
  77970. */
  77971. static FromDegrees(degrees: number): Angle;
  77972. }
  77973. /**
  77974. * This represents an arc in a 2d space.
  77975. */
  77976. export class Arc2 {
  77977. /** Defines the start point of the arc */
  77978. startPoint: Vector2;
  77979. /** Defines the mid point of the arc */
  77980. midPoint: Vector2;
  77981. /** Defines the end point of the arc */
  77982. endPoint: Vector2;
  77983. /**
  77984. * Defines the center point of the arc.
  77985. */
  77986. centerPoint: Vector2;
  77987. /**
  77988. * Defines the radius of the arc.
  77989. */
  77990. radius: number;
  77991. /**
  77992. * Defines the angle of the arc (from mid point to end point).
  77993. */
  77994. angle: Angle;
  77995. /**
  77996. * Defines the start angle of the arc (from start point to middle point).
  77997. */
  77998. startAngle: Angle;
  77999. /**
  78000. * Defines the orientation of the arc (clock wise/counter clock wise).
  78001. */
  78002. orientation: Orientation;
  78003. /**
  78004. * Creates an Arc object from the three given points : start, middle and end.
  78005. * @param startPoint Defines the start point of the arc
  78006. * @param midPoint Defines the midlle point of the arc
  78007. * @param endPoint Defines the end point of the arc
  78008. */
  78009. constructor(
  78010. /** Defines the start point of the arc */
  78011. startPoint: Vector2,
  78012. /** Defines the mid point of the arc */
  78013. midPoint: Vector2,
  78014. /** Defines the end point of the arc */
  78015. endPoint: Vector2);
  78016. }
  78017. /**
  78018. * Represents a 2D path made up of multiple 2D points
  78019. */
  78020. export class Path2 {
  78021. private _points;
  78022. private _length;
  78023. /**
  78024. * If the path start and end point are the same
  78025. */
  78026. closed: boolean;
  78027. /**
  78028. * Creates a Path2 object from the starting 2D coordinates x and y.
  78029. * @param x the starting points x value
  78030. * @param y the starting points y value
  78031. */
  78032. constructor(x: number, y: number);
  78033. /**
  78034. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78035. * @param x the added points x value
  78036. * @param y the added points y value
  78037. * @returns the updated Path2.
  78038. */
  78039. addLineTo(x: number, y: number): Path2;
  78040. /**
  78041. * 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.
  78042. * @param midX middle point x value
  78043. * @param midY middle point y value
  78044. * @param endX end point x value
  78045. * @param endY end point y value
  78046. * @param numberOfSegments (default: 36)
  78047. * @returns the updated Path2.
  78048. */
  78049. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78050. /**
  78051. * Closes the Path2.
  78052. * @returns the Path2.
  78053. */
  78054. close(): Path2;
  78055. /**
  78056. * Gets the sum of the distance between each sequential point in the path
  78057. * @returns the Path2 total length (float).
  78058. */
  78059. length(): number;
  78060. /**
  78061. * Gets the points which construct the path
  78062. * @returns the Path2 internal array of points.
  78063. */
  78064. getPoints(): Vector2[];
  78065. /**
  78066. * Retreives the point at the distance aways from the starting point
  78067. * @param normalizedLengthPosition the length along the path to retreive the point from
  78068. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78069. */
  78070. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78071. /**
  78072. * Creates a new path starting from an x and y position
  78073. * @param x starting x value
  78074. * @param y starting y value
  78075. * @returns a new Path2 starting at the coordinates (x, y).
  78076. */
  78077. static StartingAt(x: number, y: number): Path2;
  78078. }
  78079. /**
  78080. * Represents a 3D path made up of multiple 3D points
  78081. */
  78082. export class Path3D {
  78083. /**
  78084. * an array of Vector3, the curve axis of the Path3D
  78085. */
  78086. path: Vector3[];
  78087. private _curve;
  78088. private _distances;
  78089. private _tangents;
  78090. private _normals;
  78091. private _binormals;
  78092. private _raw;
  78093. private _alignTangentsWithPath;
  78094. private readonly _pointAtData;
  78095. /**
  78096. * new Path3D(path, normal, raw)
  78097. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78098. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78099. * @param path an array of Vector3, the curve axis of the Path3D
  78100. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78101. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78102. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78103. */
  78104. constructor(
  78105. /**
  78106. * an array of Vector3, the curve axis of the Path3D
  78107. */
  78108. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78109. /**
  78110. * Returns the Path3D array of successive Vector3 designing its curve.
  78111. * @returns the Path3D array of successive Vector3 designing its curve.
  78112. */
  78113. getCurve(): Vector3[];
  78114. /**
  78115. * Returns the Path3D array of successive Vector3 designing its curve.
  78116. * @returns the Path3D array of successive Vector3 designing its curve.
  78117. */
  78118. getPoints(): Vector3[];
  78119. /**
  78120. * @returns the computed length (float) of the path.
  78121. */
  78122. length(): number;
  78123. /**
  78124. * Returns an array populated with tangent vectors on each Path3D curve point.
  78125. * @returns an array populated with tangent vectors on each Path3D curve point.
  78126. */
  78127. getTangents(): Vector3[];
  78128. /**
  78129. * Returns an array populated with normal vectors on each Path3D curve point.
  78130. * @returns an array populated with normal vectors on each Path3D curve point.
  78131. */
  78132. getNormals(): Vector3[];
  78133. /**
  78134. * Returns an array populated with binormal vectors on each Path3D curve point.
  78135. * @returns an array populated with binormal vectors on each Path3D curve point.
  78136. */
  78137. getBinormals(): Vector3[];
  78138. /**
  78139. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78140. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78141. */
  78142. getDistances(): number[];
  78143. /**
  78144. * Returns an interpolated point along this path
  78145. * @param position the position of the point along this path, from 0.0 to 1.0
  78146. * @returns a new Vector3 as the point
  78147. */
  78148. getPointAt(position: number): Vector3;
  78149. /**
  78150. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78151. * @param position the position of the point along this path, from 0.0 to 1.0
  78152. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78153. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78154. */
  78155. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78156. /**
  78157. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78158. * @param position the position of the point along this path, from 0.0 to 1.0
  78159. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78160. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78161. */
  78162. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78163. /**
  78164. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78165. * @param position the position of the point along this path, from 0.0 to 1.0
  78166. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78167. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78168. */
  78169. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78170. /**
  78171. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78172. * @param position the position of the point along this path, from 0.0 to 1.0
  78173. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78174. */
  78175. getDistanceAt(position: number): number;
  78176. /**
  78177. * Returns the array index of the previous point of an interpolated point along this path
  78178. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78179. * @returns the array index
  78180. */
  78181. getPreviousPointIndexAt(position: number): number;
  78182. /**
  78183. * 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)
  78184. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78185. * @returns the sub position
  78186. */
  78187. getSubPositionAt(position: number): number;
  78188. /**
  78189. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78190. * @param target the vector of which to get the closest position to
  78191. * @returns the position of the closest virtual point on this path to the target vector
  78192. */
  78193. getClosestPositionTo(target: Vector3): number;
  78194. /**
  78195. * Returns a sub path (slice) of this path
  78196. * @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
  78197. * @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
  78198. * @returns a sub path (slice) of this path
  78199. */
  78200. slice(start?: number, end?: number): Path3D;
  78201. /**
  78202. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78203. * @param path path which all values are copied into the curves points
  78204. * @param firstNormal which should be projected onto the curve
  78205. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78206. * @returns the same object updated.
  78207. */
  78208. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78209. private _compute;
  78210. private _getFirstNonNullVector;
  78211. private _getLastNonNullVector;
  78212. private _normalVector;
  78213. /**
  78214. * Updates the point at data for an interpolated point along this curve
  78215. * @param position the position of the point along this curve, from 0.0 to 1.0
  78216. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78217. * @returns the (updated) point at data
  78218. */
  78219. private _updatePointAtData;
  78220. /**
  78221. * Updates the point at data from the specified parameters
  78222. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78223. * @param point the interpolated point
  78224. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78225. */
  78226. private _setPointAtData;
  78227. /**
  78228. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78229. */
  78230. private _updateInterpolationMatrix;
  78231. }
  78232. /**
  78233. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78234. * A Curve3 is designed from a series of successive Vector3.
  78235. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78236. */
  78237. export class Curve3 {
  78238. private _points;
  78239. private _length;
  78240. /**
  78241. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78242. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78243. * @param v1 (Vector3) the control point
  78244. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78245. * @param nbPoints (integer) the wanted number of points in the curve
  78246. * @returns the created Curve3
  78247. */
  78248. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78249. /**
  78250. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78251. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78252. * @param v1 (Vector3) the first control point
  78253. * @param v2 (Vector3) the second control point
  78254. * @param v3 (Vector3) the end point of the Cubic Bezier
  78255. * @param nbPoints (integer) the wanted number of points in the curve
  78256. * @returns the created Curve3
  78257. */
  78258. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78259. /**
  78260. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78261. * @param p1 (Vector3) the origin point of the Hermite Spline
  78262. * @param t1 (Vector3) the tangent vector at the origin point
  78263. * @param p2 (Vector3) the end point of the Hermite Spline
  78264. * @param t2 (Vector3) the tangent vector at the end point
  78265. * @param nbPoints (integer) the wanted number of points in the curve
  78266. * @returns the created Curve3
  78267. */
  78268. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78269. /**
  78270. * Returns a Curve3 object along a CatmullRom Spline curve :
  78271. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78272. * @param nbPoints (integer) the wanted number of points between each curve control points
  78273. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78274. * @returns the created Curve3
  78275. */
  78276. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78277. /**
  78278. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78279. * A Curve3 is designed from a series of successive Vector3.
  78280. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78281. * @param points points which make up the curve
  78282. */
  78283. constructor(points: Vector3[]);
  78284. /**
  78285. * @returns the Curve3 stored array of successive Vector3
  78286. */
  78287. getPoints(): Vector3[];
  78288. /**
  78289. * @returns the computed length (float) of the curve.
  78290. */
  78291. length(): number;
  78292. /**
  78293. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78294. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78295. * curveA and curveB keep unchanged.
  78296. * @param curve the curve to continue from this curve
  78297. * @returns the newly constructed curve
  78298. */
  78299. continue(curve: DeepImmutable<Curve3>): Curve3;
  78300. private _computeLength;
  78301. }
  78302. }
  78303. declare module BABYLON {
  78304. /**
  78305. * This represents the main contract an easing function should follow.
  78306. * Easing functions are used throughout the animation system.
  78307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78308. */
  78309. export interface IEasingFunction {
  78310. /**
  78311. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78312. * of the easing function.
  78313. * The link below provides some of the most common examples of easing functions.
  78314. * @see https://easings.net/
  78315. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78316. * @returns the corresponding value on the curve defined by the easing function
  78317. */
  78318. ease(gradient: number): number;
  78319. }
  78320. /**
  78321. * Base class used for every default easing function.
  78322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78323. */
  78324. export class EasingFunction implements IEasingFunction {
  78325. /**
  78326. * Interpolation follows the mathematical formula associated with the easing function.
  78327. */
  78328. static readonly EASINGMODE_EASEIN: number;
  78329. /**
  78330. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78331. */
  78332. static readonly EASINGMODE_EASEOUT: number;
  78333. /**
  78334. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78335. */
  78336. static readonly EASINGMODE_EASEINOUT: number;
  78337. private _easingMode;
  78338. /**
  78339. * Sets the easing mode of the current function.
  78340. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78341. */
  78342. setEasingMode(easingMode: number): void;
  78343. /**
  78344. * Gets the current easing mode.
  78345. * @returns the easing mode
  78346. */
  78347. getEasingMode(): number;
  78348. /**
  78349. * @hidden
  78350. */
  78351. easeInCore(gradient: number): number;
  78352. /**
  78353. * Given an input gradient between 0 and 1, this returns the corresponding value
  78354. * of the easing function.
  78355. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78356. * @returns the corresponding value on the curve defined by the easing function
  78357. */
  78358. ease(gradient: number): number;
  78359. }
  78360. /**
  78361. * Easing function with a circle shape (see link below).
  78362. * @see https://easings.net/#easeInCirc
  78363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78364. */
  78365. export class CircleEase extends EasingFunction implements IEasingFunction {
  78366. /** @hidden */
  78367. easeInCore(gradient: number): number;
  78368. }
  78369. /**
  78370. * Easing function with a ease back shape (see link below).
  78371. * @see https://easings.net/#easeInBack
  78372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78373. */
  78374. export class BackEase extends EasingFunction implements IEasingFunction {
  78375. /** Defines the amplitude of the function */
  78376. amplitude: number;
  78377. /**
  78378. * Instantiates a back ease easing
  78379. * @see https://easings.net/#easeInBack
  78380. * @param amplitude Defines the amplitude of the function
  78381. */
  78382. constructor(
  78383. /** Defines the amplitude of the function */
  78384. amplitude?: number);
  78385. /** @hidden */
  78386. easeInCore(gradient: number): number;
  78387. }
  78388. /**
  78389. * Easing function with a bouncing shape (see link below).
  78390. * @see https://easings.net/#easeInBounce
  78391. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78392. */
  78393. export class BounceEase extends EasingFunction implements IEasingFunction {
  78394. /** Defines the number of bounces */
  78395. bounces: number;
  78396. /** Defines the amplitude of the bounce */
  78397. bounciness: number;
  78398. /**
  78399. * Instantiates a bounce easing
  78400. * @see https://easings.net/#easeInBounce
  78401. * @param bounces Defines the number of bounces
  78402. * @param bounciness Defines the amplitude of the bounce
  78403. */
  78404. constructor(
  78405. /** Defines the number of bounces */
  78406. bounces?: number,
  78407. /** Defines the amplitude of the bounce */
  78408. bounciness?: number);
  78409. /** @hidden */
  78410. easeInCore(gradient: number): number;
  78411. }
  78412. /**
  78413. * Easing function with a power of 3 shape (see link below).
  78414. * @see https://easings.net/#easeInCubic
  78415. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78416. */
  78417. export class CubicEase extends EasingFunction implements IEasingFunction {
  78418. /** @hidden */
  78419. easeInCore(gradient: number): number;
  78420. }
  78421. /**
  78422. * Easing function with an elastic shape (see link below).
  78423. * @see https://easings.net/#easeInElastic
  78424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78425. */
  78426. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78427. /** Defines the number of oscillations*/
  78428. oscillations: number;
  78429. /** Defines the amplitude of the oscillations*/
  78430. springiness: number;
  78431. /**
  78432. * Instantiates an elastic easing function
  78433. * @see https://easings.net/#easeInElastic
  78434. * @param oscillations Defines the number of oscillations
  78435. * @param springiness Defines the amplitude of the oscillations
  78436. */
  78437. constructor(
  78438. /** Defines the number of oscillations*/
  78439. oscillations?: number,
  78440. /** Defines the amplitude of the oscillations*/
  78441. springiness?: number);
  78442. /** @hidden */
  78443. easeInCore(gradient: number): number;
  78444. }
  78445. /**
  78446. * Easing function with an exponential shape (see link below).
  78447. * @see https://easings.net/#easeInExpo
  78448. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78449. */
  78450. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78451. /** Defines the exponent of the function */
  78452. exponent: number;
  78453. /**
  78454. * Instantiates an exponential easing function
  78455. * @see https://easings.net/#easeInExpo
  78456. * @param exponent Defines the exponent of the function
  78457. */
  78458. constructor(
  78459. /** Defines the exponent of the function */
  78460. exponent?: number);
  78461. /** @hidden */
  78462. easeInCore(gradient: number): number;
  78463. }
  78464. /**
  78465. * Easing function with a power shape (see link below).
  78466. * @see https://easings.net/#easeInQuad
  78467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78468. */
  78469. export class PowerEase extends EasingFunction implements IEasingFunction {
  78470. /** Defines the power of the function */
  78471. power: number;
  78472. /**
  78473. * Instantiates an power base easing function
  78474. * @see https://easings.net/#easeInQuad
  78475. * @param power Defines the power of the function
  78476. */
  78477. constructor(
  78478. /** Defines the power of the function */
  78479. power?: number);
  78480. /** @hidden */
  78481. easeInCore(gradient: number): number;
  78482. }
  78483. /**
  78484. * Easing function with a power of 2 shape (see link below).
  78485. * @see https://easings.net/#easeInQuad
  78486. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78487. */
  78488. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78489. /** @hidden */
  78490. easeInCore(gradient: number): number;
  78491. }
  78492. /**
  78493. * Easing function with a power of 4 shape (see link below).
  78494. * @see https://easings.net/#easeInQuart
  78495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78496. */
  78497. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78498. /** @hidden */
  78499. easeInCore(gradient: number): number;
  78500. }
  78501. /**
  78502. * Easing function with a power of 5 shape (see link below).
  78503. * @see https://easings.net/#easeInQuint
  78504. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78505. */
  78506. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78507. /** @hidden */
  78508. easeInCore(gradient: number): number;
  78509. }
  78510. /**
  78511. * Easing function with a sin shape (see link below).
  78512. * @see https://easings.net/#easeInSine
  78513. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78514. */
  78515. export class SineEase extends EasingFunction implements IEasingFunction {
  78516. /** @hidden */
  78517. easeInCore(gradient: number): number;
  78518. }
  78519. /**
  78520. * Easing function with a bezier shape (see link below).
  78521. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78523. */
  78524. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78525. /** Defines the x component of the start tangent in the bezier curve */
  78526. x1: number;
  78527. /** Defines the y component of the start tangent in the bezier curve */
  78528. y1: number;
  78529. /** Defines the x component of the end tangent in the bezier curve */
  78530. x2: number;
  78531. /** Defines the y component of the end tangent in the bezier curve */
  78532. y2: number;
  78533. /**
  78534. * Instantiates a bezier function
  78535. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78536. * @param x1 Defines the x component of the start tangent in the bezier curve
  78537. * @param y1 Defines the y component of the start tangent in the bezier curve
  78538. * @param x2 Defines the x component of the end tangent in the bezier curve
  78539. * @param y2 Defines the y component of the end tangent in the bezier curve
  78540. */
  78541. constructor(
  78542. /** Defines the x component of the start tangent in the bezier curve */
  78543. x1?: number,
  78544. /** Defines the y component of the start tangent in the bezier curve */
  78545. y1?: number,
  78546. /** Defines the x component of the end tangent in the bezier curve */
  78547. x2?: number,
  78548. /** Defines the y component of the end tangent in the bezier curve */
  78549. y2?: number);
  78550. /** @hidden */
  78551. easeInCore(gradient: number): number;
  78552. }
  78553. }
  78554. declare module BABYLON {
  78555. /**
  78556. * Class used to hold a RBG color
  78557. */
  78558. export class Color3 {
  78559. /**
  78560. * Defines the red component (between 0 and 1, default is 0)
  78561. */
  78562. r: number;
  78563. /**
  78564. * Defines the green component (between 0 and 1, default is 0)
  78565. */
  78566. g: number;
  78567. /**
  78568. * Defines the blue component (between 0 and 1, default is 0)
  78569. */
  78570. b: number;
  78571. /**
  78572. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78573. * @param r defines the red component (between 0 and 1, default is 0)
  78574. * @param g defines the green component (between 0 and 1, default is 0)
  78575. * @param b defines the blue component (between 0 and 1, default is 0)
  78576. */
  78577. constructor(
  78578. /**
  78579. * Defines the red component (between 0 and 1, default is 0)
  78580. */
  78581. r?: number,
  78582. /**
  78583. * Defines the green component (between 0 and 1, default is 0)
  78584. */
  78585. g?: number,
  78586. /**
  78587. * Defines the blue component (between 0 and 1, default is 0)
  78588. */
  78589. b?: number);
  78590. /**
  78591. * Creates a string with the Color3 current values
  78592. * @returns the string representation of the Color3 object
  78593. */
  78594. toString(): string;
  78595. /**
  78596. * Returns the string "Color3"
  78597. * @returns "Color3"
  78598. */
  78599. getClassName(): string;
  78600. /**
  78601. * Compute the Color3 hash code
  78602. * @returns an unique number that can be used to hash Color3 objects
  78603. */
  78604. getHashCode(): number;
  78605. /**
  78606. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78607. * @param array defines the array where to store the r,g,b components
  78608. * @param index defines an optional index in the target array to define where to start storing values
  78609. * @returns the current Color3 object
  78610. */
  78611. toArray(array: FloatArray, index?: number): Color3;
  78612. /**
  78613. * Returns a new Color4 object from the current Color3 and the given alpha
  78614. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78615. * @returns a new Color4 object
  78616. */
  78617. toColor4(alpha?: number): Color4;
  78618. /**
  78619. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78620. * @returns the new array
  78621. */
  78622. asArray(): number[];
  78623. /**
  78624. * Returns the luminance value
  78625. * @returns a float value
  78626. */
  78627. toLuminance(): number;
  78628. /**
  78629. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78630. * @param otherColor defines the second operand
  78631. * @returns the new Color3 object
  78632. */
  78633. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78634. /**
  78635. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78636. * @param otherColor defines the second operand
  78637. * @param result defines the Color3 object where to store the result
  78638. * @returns the current Color3
  78639. */
  78640. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78641. /**
  78642. * Determines equality between Color3 objects
  78643. * @param otherColor defines the second operand
  78644. * @returns true if the rgb values are equal to the given ones
  78645. */
  78646. equals(otherColor: DeepImmutable<Color3>): boolean;
  78647. /**
  78648. * Determines equality between the current Color3 object and a set of r,b,g values
  78649. * @param r defines the red component to check
  78650. * @param g defines the green component to check
  78651. * @param b defines the blue component to check
  78652. * @returns true if the rgb values are equal to the given ones
  78653. */
  78654. equalsFloats(r: number, g: number, b: number): boolean;
  78655. /**
  78656. * Multiplies in place each rgb value by scale
  78657. * @param scale defines the scaling factor
  78658. * @returns the updated Color3
  78659. */
  78660. scale(scale: number): Color3;
  78661. /**
  78662. * Multiplies the rgb values by scale and stores the result into "result"
  78663. * @param scale defines the scaling factor
  78664. * @param result defines the Color3 object where to store the result
  78665. * @returns the unmodified current Color3
  78666. */
  78667. scaleToRef(scale: number, result: Color3): Color3;
  78668. /**
  78669. * Scale the current Color3 values by a factor and add the result to a given Color3
  78670. * @param scale defines the scale factor
  78671. * @param result defines color to store the result into
  78672. * @returns the unmodified current Color3
  78673. */
  78674. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78675. /**
  78676. * Clamps the rgb values by the min and max values and stores the result into "result"
  78677. * @param min defines minimum clamping value (default is 0)
  78678. * @param max defines maximum clamping value (default is 1)
  78679. * @param result defines color to store the result into
  78680. * @returns the original Color3
  78681. */
  78682. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78683. /**
  78684. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78685. * @param otherColor defines the second operand
  78686. * @returns the new Color3
  78687. */
  78688. add(otherColor: DeepImmutable<Color3>): Color3;
  78689. /**
  78690. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78691. * @param otherColor defines the second operand
  78692. * @param result defines Color3 object to store the result into
  78693. * @returns the unmodified current Color3
  78694. */
  78695. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78696. /**
  78697. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78698. * @param otherColor defines the second operand
  78699. * @returns the new Color3
  78700. */
  78701. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78702. /**
  78703. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78704. * @param otherColor defines the second operand
  78705. * @param result defines Color3 object to store the result into
  78706. * @returns the unmodified current Color3
  78707. */
  78708. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78709. /**
  78710. * Copy the current object
  78711. * @returns a new Color3 copied the current one
  78712. */
  78713. clone(): Color3;
  78714. /**
  78715. * Copies the rgb values from the source in the current Color3
  78716. * @param source defines the source Color3 object
  78717. * @returns the updated Color3 object
  78718. */
  78719. copyFrom(source: DeepImmutable<Color3>): Color3;
  78720. /**
  78721. * Updates the Color3 rgb values from the given floats
  78722. * @param r defines the red component to read from
  78723. * @param g defines the green component to read from
  78724. * @param b defines the blue component to read from
  78725. * @returns the current Color3 object
  78726. */
  78727. copyFromFloats(r: number, g: number, b: number): Color3;
  78728. /**
  78729. * Updates the Color3 rgb values from the given floats
  78730. * @param r defines the red component to read from
  78731. * @param g defines the green component to read from
  78732. * @param b defines the blue component to read from
  78733. * @returns the current Color3 object
  78734. */
  78735. set(r: number, g: number, b: number): Color3;
  78736. /**
  78737. * Compute the Color3 hexadecimal code as a string
  78738. * @returns a string containing the hexadecimal representation of the Color3 object
  78739. */
  78740. toHexString(): string;
  78741. /**
  78742. * Computes a new Color3 converted from the current one to linear space
  78743. * @returns a new Color3 object
  78744. */
  78745. toLinearSpace(): Color3;
  78746. /**
  78747. * Converts current color in rgb space to HSV values
  78748. * @returns a new color3 representing the HSV values
  78749. */
  78750. toHSV(): Color3;
  78751. /**
  78752. * Converts current color in rgb space to HSV values
  78753. * @param result defines the Color3 where to store the HSV values
  78754. */
  78755. toHSVToRef(result: Color3): void;
  78756. /**
  78757. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78758. * @param convertedColor defines the Color3 object where to store the linear space version
  78759. * @returns the unmodified Color3
  78760. */
  78761. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78762. /**
  78763. * Computes a new Color3 converted from the current one to gamma space
  78764. * @returns a new Color3 object
  78765. */
  78766. toGammaSpace(): Color3;
  78767. /**
  78768. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78769. * @param convertedColor defines the Color3 object where to store the gamma space version
  78770. * @returns the unmodified Color3
  78771. */
  78772. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78773. private static _BlackReadOnly;
  78774. /**
  78775. * Convert Hue, saturation and value to a Color3 (RGB)
  78776. * @param hue defines the hue
  78777. * @param saturation defines the saturation
  78778. * @param value defines the value
  78779. * @param result defines the Color3 where to store the RGB values
  78780. */
  78781. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78782. /**
  78783. * Creates a new Color3 from the string containing valid hexadecimal values
  78784. * @param hex defines a string containing valid hexadecimal values
  78785. * @returns a new Color3 object
  78786. */
  78787. static FromHexString(hex: string): Color3;
  78788. /**
  78789. * Creates a new Color3 from the starting index of the given array
  78790. * @param array defines the source array
  78791. * @param offset defines an offset in the source array
  78792. * @returns a new Color3 object
  78793. */
  78794. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78795. /**
  78796. * Creates a new Color3 from integer values (< 256)
  78797. * @param r defines the red component to read from (value between 0 and 255)
  78798. * @param g defines the green component to read from (value between 0 and 255)
  78799. * @param b defines the blue component to read from (value between 0 and 255)
  78800. * @returns a new Color3 object
  78801. */
  78802. static FromInts(r: number, g: number, b: number): Color3;
  78803. /**
  78804. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78805. * @param start defines the start Color3 value
  78806. * @param end defines the end Color3 value
  78807. * @param amount defines the gradient value between start and end
  78808. * @returns a new Color3 object
  78809. */
  78810. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78811. /**
  78812. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78813. * @param left defines the start value
  78814. * @param right defines the end value
  78815. * @param amount defines the gradient factor
  78816. * @param result defines the Color3 object where to store the result
  78817. */
  78818. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78819. /**
  78820. * Returns a Color3 value containing a red color
  78821. * @returns a new Color3 object
  78822. */
  78823. static Red(): Color3;
  78824. /**
  78825. * Returns a Color3 value containing a green color
  78826. * @returns a new Color3 object
  78827. */
  78828. static Green(): Color3;
  78829. /**
  78830. * Returns a Color3 value containing a blue color
  78831. * @returns a new Color3 object
  78832. */
  78833. static Blue(): Color3;
  78834. /**
  78835. * Returns a Color3 value containing a black color
  78836. * @returns a new Color3 object
  78837. */
  78838. static Black(): Color3;
  78839. /**
  78840. * Gets a Color3 value containing a black color that must not be updated
  78841. */
  78842. static get BlackReadOnly(): DeepImmutable<Color3>;
  78843. /**
  78844. * Returns a Color3 value containing a white color
  78845. * @returns a new Color3 object
  78846. */
  78847. static White(): Color3;
  78848. /**
  78849. * Returns a Color3 value containing a purple color
  78850. * @returns a new Color3 object
  78851. */
  78852. static Purple(): Color3;
  78853. /**
  78854. * Returns a Color3 value containing a magenta color
  78855. * @returns a new Color3 object
  78856. */
  78857. static Magenta(): Color3;
  78858. /**
  78859. * Returns a Color3 value containing a yellow color
  78860. * @returns a new Color3 object
  78861. */
  78862. static Yellow(): Color3;
  78863. /**
  78864. * Returns a Color3 value containing a gray color
  78865. * @returns a new Color3 object
  78866. */
  78867. static Gray(): Color3;
  78868. /**
  78869. * Returns a Color3 value containing a teal color
  78870. * @returns a new Color3 object
  78871. */
  78872. static Teal(): Color3;
  78873. /**
  78874. * Returns a Color3 value containing a random color
  78875. * @returns a new Color3 object
  78876. */
  78877. static Random(): Color3;
  78878. }
  78879. /**
  78880. * Class used to hold a RBGA color
  78881. */
  78882. export class Color4 {
  78883. /**
  78884. * Defines the red component (between 0 and 1, default is 0)
  78885. */
  78886. r: number;
  78887. /**
  78888. * Defines the green component (between 0 and 1, default is 0)
  78889. */
  78890. g: number;
  78891. /**
  78892. * Defines the blue component (between 0 and 1, default is 0)
  78893. */
  78894. b: number;
  78895. /**
  78896. * Defines the alpha component (between 0 and 1, default is 1)
  78897. */
  78898. a: number;
  78899. /**
  78900. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78901. * @param r defines the red component (between 0 and 1, default is 0)
  78902. * @param g defines the green component (between 0 and 1, default is 0)
  78903. * @param b defines the blue component (between 0 and 1, default is 0)
  78904. * @param a defines the alpha component (between 0 and 1, default is 1)
  78905. */
  78906. constructor(
  78907. /**
  78908. * Defines the red component (between 0 and 1, default is 0)
  78909. */
  78910. r?: number,
  78911. /**
  78912. * Defines the green component (between 0 and 1, default is 0)
  78913. */
  78914. g?: number,
  78915. /**
  78916. * Defines the blue component (between 0 and 1, default is 0)
  78917. */
  78918. b?: number,
  78919. /**
  78920. * Defines the alpha component (between 0 and 1, default is 1)
  78921. */
  78922. a?: number);
  78923. /**
  78924. * Adds in place the given Color4 values to the current Color4 object
  78925. * @param right defines the second operand
  78926. * @returns the current updated Color4 object
  78927. */
  78928. addInPlace(right: DeepImmutable<Color4>): Color4;
  78929. /**
  78930. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78931. * @returns the new array
  78932. */
  78933. asArray(): number[];
  78934. /**
  78935. * Stores from the starting index in the given array the Color4 successive values
  78936. * @param array defines the array where to store the r,g,b components
  78937. * @param index defines an optional index in the target array to define where to start storing values
  78938. * @returns the current Color4 object
  78939. */
  78940. toArray(array: number[], index?: number): Color4;
  78941. /**
  78942. * Determines equality between Color4 objects
  78943. * @param otherColor defines the second operand
  78944. * @returns true if the rgba values are equal to the given ones
  78945. */
  78946. equals(otherColor: DeepImmutable<Color4>): boolean;
  78947. /**
  78948. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78949. * @param right defines the second operand
  78950. * @returns a new Color4 object
  78951. */
  78952. add(right: DeepImmutable<Color4>): Color4;
  78953. /**
  78954. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78955. * @param right defines the second operand
  78956. * @returns a new Color4 object
  78957. */
  78958. subtract(right: DeepImmutable<Color4>): Color4;
  78959. /**
  78960. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78961. * @param right defines the second operand
  78962. * @param result defines the Color4 object where to store the result
  78963. * @returns the current Color4 object
  78964. */
  78965. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78966. /**
  78967. * Creates a new Color4 with the current Color4 values multiplied by scale
  78968. * @param scale defines the scaling factor to apply
  78969. * @returns a new Color4 object
  78970. */
  78971. scale(scale: number): Color4;
  78972. /**
  78973. * Multiplies the current Color4 values by scale and stores the result in "result"
  78974. * @param scale defines the scaling factor to apply
  78975. * @param result defines the Color4 object where to store the result
  78976. * @returns the current unmodified Color4
  78977. */
  78978. scaleToRef(scale: number, result: Color4): Color4;
  78979. /**
  78980. * Scale the current Color4 values by a factor and add the result to a given Color4
  78981. * @param scale defines the scale factor
  78982. * @param result defines the Color4 object where to store the result
  78983. * @returns the unmodified current Color4
  78984. */
  78985. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78986. /**
  78987. * Clamps the rgb values by the min and max values and stores the result into "result"
  78988. * @param min defines minimum clamping value (default is 0)
  78989. * @param max defines maximum clamping value (default is 1)
  78990. * @param result defines color to store the result into.
  78991. * @returns the cuurent Color4
  78992. */
  78993. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78994. /**
  78995. * Multipy an Color4 value by another and return a new Color4 object
  78996. * @param color defines the Color4 value to multiply by
  78997. * @returns a new Color4 object
  78998. */
  78999. multiply(color: Color4): Color4;
  79000. /**
  79001. * Multipy a Color4 value by another and push the result in a reference value
  79002. * @param color defines the Color4 value to multiply by
  79003. * @param result defines the Color4 to fill the result in
  79004. * @returns the result Color4
  79005. */
  79006. multiplyToRef(color: Color4, result: Color4): Color4;
  79007. /**
  79008. * Creates a string with the Color4 current values
  79009. * @returns the string representation of the Color4 object
  79010. */
  79011. toString(): string;
  79012. /**
  79013. * Returns the string "Color4"
  79014. * @returns "Color4"
  79015. */
  79016. getClassName(): string;
  79017. /**
  79018. * Compute the Color4 hash code
  79019. * @returns an unique number that can be used to hash Color4 objects
  79020. */
  79021. getHashCode(): number;
  79022. /**
  79023. * Creates a new Color4 copied from the current one
  79024. * @returns a new Color4 object
  79025. */
  79026. clone(): Color4;
  79027. /**
  79028. * Copies the given Color4 values into the current one
  79029. * @param source defines the source Color4 object
  79030. * @returns the current updated Color4 object
  79031. */
  79032. copyFrom(source: Color4): Color4;
  79033. /**
  79034. * Copies the given float values into the current one
  79035. * @param r defines the red component to read from
  79036. * @param g defines the green component to read from
  79037. * @param b defines the blue component to read from
  79038. * @param a defines the alpha component to read from
  79039. * @returns the current updated Color4 object
  79040. */
  79041. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79042. /**
  79043. * Copies the given float values into the current one
  79044. * @param r defines the red component to read from
  79045. * @param g defines the green component to read from
  79046. * @param b defines the blue component to read from
  79047. * @param a defines the alpha component to read from
  79048. * @returns the current updated Color4 object
  79049. */
  79050. set(r: number, g: number, b: number, a: number): Color4;
  79051. /**
  79052. * Compute the Color4 hexadecimal code as a string
  79053. * @returns a string containing the hexadecimal representation of the Color4 object
  79054. */
  79055. toHexString(): string;
  79056. /**
  79057. * Computes a new Color4 converted from the current one to linear space
  79058. * @returns a new Color4 object
  79059. */
  79060. toLinearSpace(): Color4;
  79061. /**
  79062. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79063. * @param convertedColor defines the Color4 object where to store the linear space version
  79064. * @returns the unmodified Color4
  79065. */
  79066. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79067. /**
  79068. * Computes a new Color4 converted from the current one to gamma space
  79069. * @returns a new Color4 object
  79070. */
  79071. toGammaSpace(): Color4;
  79072. /**
  79073. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79074. * @param convertedColor defines the Color4 object where to store the gamma space version
  79075. * @returns the unmodified Color4
  79076. */
  79077. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79078. /**
  79079. * Creates a new Color4 from the string containing valid hexadecimal values
  79080. * @param hex defines a string containing valid hexadecimal values
  79081. * @returns a new Color4 object
  79082. */
  79083. static FromHexString(hex: string): Color4;
  79084. /**
  79085. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79086. * @param left defines the start value
  79087. * @param right defines the end value
  79088. * @param amount defines the gradient factor
  79089. * @returns a new Color4 object
  79090. */
  79091. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79092. /**
  79093. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79094. * @param left defines the start value
  79095. * @param right defines the end value
  79096. * @param amount defines the gradient factor
  79097. * @param result defines the Color4 object where to store data
  79098. */
  79099. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79100. /**
  79101. * Creates a new Color4 from a Color3 and an alpha value
  79102. * @param color3 defines the source Color3 to read from
  79103. * @param alpha defines the alpha component (1.0 by default)
  79104. * @returns a new Color4 object
  79105. */
  79106. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79107. /**
  79108. * Creates a new Color4 from the starting index element of the given array
  79109. * @param array defines the source array to read from
  79110. * @param offset defines the offset in the source array
  79111. * @returns a new Color4 object
  79112. */
  79113. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79114. /**
  79115. * Creates a new Color3 from integer values (< 256)
  79116. * @param r defines the red component to read from (value between 0 and 255)
  79117. * @param g defines the green component to read from (value between 0 and 255)
  79118. * @param b defines the blue component to read from (value between 0 and 255)
  79119. * @param a defines the alpha component to read from (value between 0 and 255)
  79120. * @returns a new Color3 object
  79121. */
  79122. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79123. /**
  79124. * Check the content of a given array and convert it to an array containing RGBA data
  79125. * If the original array was already containing count * 4 values then it is returned directly
  79126. * @param colors defines the array to check
  79127. * @param count defines the number of RGBA data to expect
  79128. * @returns an array containing count * 4 values (RGBA)
  79129. */
  79130. static CheckColors4(colors: number[], count: number): number[];
  79131. }
  79132. /**
  79133. * @hidden
  79134. */
  79135. export class TmpColors {
  79136. static Color3: Color3[];
  79137. static Color4: Color4[];
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /**
  79142. * Defines an interface which represents an animation key frame
  79143. */
  79144. export interface IAnimationKey {
  79145. /**
  79146. * Frame of the key frame
  79147. */
  79148. frame: number;
  79149. /**
  79150. * Value at the specifies key frame
  79151. */
  79152. value: any;
  79153. /**
  79154. * The input tangent for the cubic hermite spline
  79155. */
  79156. inTangent?: any;
  79157. /**
  79158. * The output tangent for the cubic hermite spline
  79159. */
  79160. outTangent?: any;
  79161. /**
  79162. * The animation interpolation type
  79163. */
  79164. interpolation?: AnimationKeyInterpolation;
  79165. }
  79166. /**
  79167. * Enum for the animation key frame interpolation type
  79168. */
  79169. export enum AnimationKeyInterpolation {
  79170. /**
  79171. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79172. */
  79173. STEP = 1
  79174. }
  79175. }
  79176. declare module BABYLON {
  79177. /**
  79178. * Represents the range of an animation
  79179. */
  79180. export class AnimationRange {
  79181. /**The name of the animation range**/
  79182. name: string;
  79183. /**The starting frame of the animation */
  79184. from: number;
  79185. /**The ending frame of the animation*/
  79186. to: number;
  79187. /**
  79188. * Initializes the range of an animation
  79189. * @param name The name of the animation range
  79190. * @param from The starting frame of the animation
  79191. * @param to The ending frame of the animation
  79192. */
  79193. constructor(
  79194. /**The name of the animation range**/
  79195. name: string,
  79196. /**The starting frame of the animation */
  79197. from: number,
  79198. /**The ending frame of the animation*/
  79199. to: number);
  79200. /**
  79201. * Makes a copy of the animation range
  79202. * @returns A copy of the animation range
  79203. */
  79204. clone(): AnimationRange;
  79205. }
  79206. }
  79207. declare module BABYLON {
  79208. /**
  79209. * Composed of a frame, and an action function
  79210. */
  79211. export class AnimationEvent {
  79212. /** The frame for which the event is triggered **/
  79213. frame: number;
  79214. /** The event to perform when triggered **/
  79215. action: (currentFrame: number) => void;
  79216. /** Specifies if the event should be triggered only once**/
  79217. onlyOnce?: boolean | undefined;
  79218. /**
  79219. * Specifies if the animation event is done
  79220. */
  79221. isDone: boolean;
  79222. /**
  79223. * Initializes the animation event
  79224. * @param frame The frame for which the event is triggered
  79225. * @param action The event to perform when triggered
  79226. * @param onlyOnce Specifies if the event should be triggered only once
  79227. */
  79228. constructor(
  79229. /** The frame for which the event is triggered **/
  79230. frame: number,
  79231. /** The event to perform when triggered **/
  79232. action: (currentFrame: number) => void,
  79233. /** Specifies if the event should be triggered only once**/
  79234. onlyOnce?: boolean | undefined);
  79235. /** @hidden */
  79236. _clone(): AnimationEvent;
  79237. }
  79238. }
  79239. declare module BABYLON {
  79240. /**
  79241. * Interface used to define a behavior
  79242. */
  79243. export interface Behavior<T> {
  79244. /** gets or sets behavior's name */
  79245. name: string;
  79246. /**
  79247. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79248. */
  79249. init(): void;
  79250. /**
  79251. * Called when the behavior is attached to a target
  79252. * @param target defines the target where the behavior is attached to
  79253. */
  79254. attach(target: T): void;
  79255. /**
  79256. * Called when the behavior is detached from its target
  79257. */
  79258. detach(): void;
  79259. }
  79260. /**
  79261. * Interface implemented by classes supporting behaviors
  79262. */
  79263. export interface IBehaviorAware<T> {
  79264. /**
  79265. * Attach a behavior
  79266. * @param behavior defines the behavior to attach
  79267. * @returns the current host
  79268. */
  79269. addBehavior(behavior: Behavior<T>): T;
  79270. /**
  79271. * Remove a behavior from the current object
  79272. * @param behavior defines the behavior to detach
  79273. * @returns the current host
  79274. */
  79275. removeBehavior(behavior: Behavior<T>): T;
  79276. /**
  79277. * Gets a behavior using its name to search
  79278. * @param name defines the name to search
  79279. * @returns the behavior or null if not found
  79280. */
  79281. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79282. }
  79283. }
  79284. declare module BABYLON {
  79285. /**
  79286. * Defines an array and its length.
  79287. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79288. */
  79289. export interface ISmartArrayLike<T> {
  79290. /**
  79291. * The data of the array.
  79292. */
  79293. data: Array<T>;
  79294. /**
  79295. * The active length of the array.
  79296. */
  79297. length: number;
  79298. }
  79299. /**
  79300. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79301. */
  79302. export class SmartArray<T> implements ISmartArrayLike<T> {
  79303. /**
  79304. * The full set of data from the array.
  79305. */
  79306. data: Array<T>;
  79307. /**
  79308. * The active length of the array.
  79309. */
  79310. length: number;
  79311. protected _id: number;
  79312. /**
  79313. * Instantiates a Smart Array.
  79314. * @param capacity defines the default capacity of the array.
  79315. */
  79316. constructor(capacity: number);
  79317. /**
  79318. * Pushes a value at the end of the active data.
  79319. * @param value defines the object to push in the array.
  79320. */
  79321. push(value: T): void;
  79322. /**
  79323. * Iterates over the active data and apply the lambda to them.
  79324. * @param func defines the action to apply on each value.
  79325. */
  79326. forEach(func: (content: T) => void): void;
  79327. /**
  79328. * Sorts the full sets of data.
  79329. * @param compareFn defines the comparison function to apply.
  79330. */
  79331. sort(compareFn: (a: T, b: T) => number): void;
  79332. /**
  79333. * Resets the active data to an empty array.
  79334. */
  79335. reset(): void;
  79336. /**
  79337. * Releases all the data from the array as well as the array.
  79338. */
  79339. dispose(): void;
  79340. /**
  79341. * Concats the active data with a given array.
  79342. * @param array defines the data to concatenate with.
  79343. */
  79344. concat(array: any): void;
  79345. /**
  79346. * Returns the position of a value in the active data.
  79347. * @param value defines the value to find the index for
  79348. * @returns the index if found in the active data otherwise -1
  79349. */
  79350. indexOf(value: T): number;
  79351. /**
  79352. * Returns whether an element is part of the active data.
  79353. * @param value defines the value to look for
  79354. * @returns true if found in the active data otherwise false
  79355. */
  79356. contains(value: T): boolean;
  79357. private static _GlobalId;
  79358. }
  79359. /**
  79360. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79361. * The data in this array can only be present once
  79362. */
  79363. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79364. private _duplicateId;
  79365. /**
  79366. * Pushes a value at the end of the active data.
  79367. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79368. * @param value defines the object to push in the array.
  79369. */
  79370. push(value: T): void;
  79371. /**
  79372. * Pushes a value at the end of the active data.
  79373. * If the data is already present, it won t be added again
  79374. * @param value defines the object to push in the array.
  79375. * @returns true if added false if it was already present
  79376. */
  79377. pushNoDuplicate(value: T): boolean;
  79378. /**
  79379. * Resets the active data to an empty array.
  79380. */
  79381. reset(): void;
  79382. /**
  79383. * Concats the active data with a given array.
  79384. * This ensures no dupplicate will be present in the result.
  79385. * @param array defines the data to concatenate with.
  79386. */
  79387. concatWithNoDuplicate(array: any): void;
  79388. }
  79389. }
  79390. declare module BABYLON {
  79391. /**
  79392. * @ignore
  79393. * This is a list of all the different input types that are available in the application.
  79394. * Fo instance: ArcRotateCameraGamepadInput...
  79395. */
  79396. export var CameraInputTypes: {};
  79397. /**
  79398. * This is the contract to implement in order to create a new input class.
  79399. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79400. */
  79401. export interface ICameraInput<TCamera extends Camera> {
  79402. /**
  79403. * Defines the camera the input is attached to.
  79404. */
  79405. camera: Nullable<TCamera>;
  79406. /**
  79407. * Gets the class name of the current intput.
  79408. * @returns the class name
  79409. */
  79410. getClassName(): string;
  79411. /**
  79412. * Get the friendly name associated with the input class.
  79413. * @returns the input friendly name
  79414. */
  79415. getSimpleName(): string;
  79416. /**
  79417. * Attach the input controls to a specific dom element to get the input from.
  79418. * @param element Defines the element the controls should be listened from
  79419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79420. */
  79421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79422. /**
  79423. * Detach the current controls from the specified dom element.
  79424. * @param element Defines the element to stop listening the inputs from
  79425. */
  79426. detachControl(element: Nullable<HTMLElement>): void;
  79427. /**
  79428. * Update the current camera state depending on the inputs that have been used this frame.
  79429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79430. */
  79431. checkInputs?: () => void;
  79432. }
  79433. /**
  79434. * Represents a map of input types to input instance or input index to input instance.
  79435. */
  79436. export interface CameraInputsMap<TCamera extends Camera> {
  79437. /**
  79438. * Accessor to the input by input type.
  79439. */
  79440. [name: string]: ICameraInput<TCamera>;
  79441. /**
  79442. * Accessor to the input by input index.
  79443. */
  79444. [idx: number]: ICameraInput<TCamera>;
  79445. }
  79446. /**
  79447. * This represents the input manager used within a camera.
  79448. * It helps dealing with all the different kind of input attached to a camera.
  79449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79450. */
  79451. export class CameraInputsManager<TCamera extends Camera> {
  79452. /**
  79453. * Defines the list of inputs attahed to the camera.
  79454. */
  79455. attached: CameraInputsMap<TCamera>;
  79456. /**
  79457. * Defines the dom element the camera is collecting inputs from.
  79458. * This is null if the controls have not been attached.
  79459. */
  79460. attachedElement: Nullable<HTMLElement>;
  79461. /**
  79462. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79463. */
  79464. noPreventDefault: boolean;
  79465. /**
  79466. * Defined the camera the input manager belongs to.
  79467. */
  79468. camera: TCamera;
  79469. /**
  79470. * Update the current camera state depending on the inputs that have been used this frame.
  79471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79472. */
  79473. checkInputs: () => void;
  79474. /**
  79475. * Instantiate a new Camera Input Manager.
  79476. * @param camera Defines the camera the input manager blongs to
  79477. */
  79478. constructor(camera: TCamera);
  79479. /**
  79480. * Add an input method to a camera
  79481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79482. * @param input camera input method
  79483. */
  79484. add(input: ICameraInput<TCamera>): void;
  79485. /**
  79486. * Remove a specific input method from a camera
  79487. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79488. * @param inputToRemove camera input method
  79489. */
  79490. remove(inputToRemove: ICameraInput<TCamera>): void;
  79491. /**
  79492. * Remove a specific input type from a camera
  79493. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79494. * @param inputType the type of the input to remove
  79495. */
  79496. removeByType(inputType: string): void;
  79497. private _addCheckInputs;
  79498. /**
  79499. * Attach the input controls to the currently attached dom element to listen the events from.
  79500. * @param input Defines the input to attach
  79501. */
  79502. attachInput(input: ICameraInput<TCamera>): void;
  79503. /**
  79504. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79505. * @param element Defines the dom element to collect the events from
  79506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79507. */
  79508. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79509. /**
  79510. * Detach the current manager inputs controls from a specific dom element.
  79511. * @param element Defines the dom element to collect the events from
  79512. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79513. */
  79514. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79515. /**
  79516. * Rebuild the dynamic inputCheck function from the current list of
  79517. * defined inputs in the manager.
  79518. */
  79519. rebuildInputCheck(): void;
  79520. /**
  79521. * Remove all attached input methods from a camera
  79522. */
  79523. clear(): void;
  79524. /**
  79525. * Serialize the current input manager attached to a camera.
  79526. * This ensures than once parsed,
  79527. * the input associated to the camera will be identical to the current ones
  79528. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79529. */
  79530. serialize(serializedCamera: any): void;
  79531. /**
  79532. * Parses an input manager serialized JSON to restore the previous list of inputs
  79533. * and states associated to a camera.
  79534. * @param parsedCamera Defines the JSON to parse
  79535. */
  79536. parse(parsedCamera: any): void;
  79537. }
  79538. }
  79539. declare module BABYLON {
  79540. /**
  79541. * Class used to store data that will be store in GPU memory
  79542. */
  79543. export class Buffer {
  79544. private _engine;
  79545. private _buffer;
  79546. /** @hidden */
  79547. _data: Nullable<DataArray>;
  79548. private _updatable;
  79549. private _instanced;
  79550. private _divisor;
  79551. /**
  79552. * Gets the byte stride.
  79553. */
  79554. readonly byteStride: number;
  79555. /**
  79556. * Constructor
  79557. * @param engine the engine
  79558. * @param data the data to use for this buffer
  79559. * @param updatable whether the data is updatable
  79560. * @param stride the stride (optional)
  79561. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79562. * @param instanced whether the buffer is instanced (optional)
  79563. * @param useBytes set to true if the stride in in bytes (optional)
  79564. * @param divisor sets an optional divisor for instances (1 by default)
  79565. */
  79566. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79567. /**
  79568. * Create a new VertexBuffer based on the current buffer
  79569. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79570. * @param offset defines offset in the buffer (0 by default)
  79571. * @param size defines the size in floats of attributes (position is 3 for instance)
  79572. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79573. * @param instanced defines if the vertex buffer contains indexed data
  79574. * @param useBytes defines if the offset and stride are in bytes *
  79575. * @param divisor sets an optional divisor for instances (1 by default)
  79576. * @returns the new vertex buffer
  79577. */
  79578. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79579. /**
  79580. * Gets a boolean indicating if the Buffer is updatable?
  79581. * @returns true if the buffer is updatable
  79582. */
  79583. isUpdatable(): boolean;
  79584. /**
  79585. * Gets current buffer's data
  79586. * @returns a DataArray or null
  79587. */
  79588. getData(): Nullable<DataArray>;
  79589. /**
  79590. * Gets underlying native buffer
  79591. * @returns underlying native buffer
  79592. */
  79593. getBuffer(): Nullable<DataBuffer>;
  79594. /**
  79595. * Gets the stride in float32 units (i.e. byte stride / 4).
  79596. * May not be an integer if the byte stride is not divisible by 4.
  79597. * @returns the stride in float32 units
  79598. * @deprecated Please use byteStride instead.
  79599. */
  79600. getStrideSize(): number;
  79601. /**
  79602. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79603. * @param data defines the data to store
  79604. */
  79605. create(data?: Nullable<DataArray>): void;
  79606. /** @hidden */
  79607. _rebuild(): void;
  79608. /**
  79609. * Update current buffer data
  79610. * @param data defines the data to store
  79611. */
  79612. update(data: DataArray): void;
  79613. /**
  79614. * Updates the data directly.
  79615. * @param data the new data
  79616. * @param offset the new offset
  79617. * @param vertexCount the vertex count (optional)
  79618. * @param useBytes set to true if the offset is in bytes
  79619. */
  79620. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79621. /**
  79622. * Release all resources
  79623. */
  79624. dispose(): void;
  79625. }
  79626. /**
  79627. * Specialized buffer used to store vertex data
  79628. */
  79629. export class VertexBuffer {
  79630. /** @hidden */
  79631. _buffer: Buffer;
  79632. private _kind;
  79633. private _size;
  79634. private _ownsBuffer;
  79635. private _instanced;
  79636. private _instanceDivisor;
  79637. /**
  79638. * The byte type.
  79639. */
  79640. static readonly BYTE: number;
  79641. /**
  79642. * The unsigned byte type.
  79643. */
  79644. static readonly UNSIGNED_BYTE: number;
  79645. /**
  79646. * The short type.
  79647. */
  79648. static readonly SHORT: number;
  79649. /**
  79650. * The unsigned short type.
  79651. */
  79652. static readonly UNSIGNED_SHORT: number;
  79653. /**
  79654. * The integer type.
  79655. */
  79656. static readonly INT: number;
  79657. /**
  79658. * The unsigned integer type.
  79659. */
  79660. static readonly UNSIGNED_INT: number;
  79661. /**
  79662. * The float type.
  79663. */
  79664. static readonly FLOAT: number;
  79665. /**
  79666. * Gets or sets the instance divisor when in instanced mode
  79667. */
  79668. get instanceDivisor(): number;
  79669. set instanceDivisor(value: number);
  79670. /**
  79671. * Gets the byte stride.
  79672. */
  79673. readonly byteStride: number;
  79674. /**
  79675. * Gets the byte offset.
  79676. */
  79677. readonly byteOffset: number;
  79678. /**
  79679. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79680. */
  79681. readonly normalized: boolean;
  79682. /**
  79683. * Gets the data type of each component in the array.
  79684. */
  79685. readonly type: number;
  79686. /**
  79687. * Constructor
  79688. * @param engine the engine
  79689. * @param data the data to use for this vertex buffer
  79690. * @param kind the vertex buffer kind
  79691. * @param updatable whether the data is updatable
  79692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79693. * @param stride the stride (optional)
  79694. * @param instanced whether the buffer is instanced (optional)
  79695. * @param offset the offset of the data (optional)
  79696. * @param size the number of components (optional)
  79697. * @param type the type of the component (optional)
  79698. * @param normalized whether the data contains normalized data (optional)
  79699. * @param useBytes set to true if stride and offset are in bytes (optional)
  79700. * @param divisor defines the instance divisor to use (1 by default)
  79701. */
  79702. 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);
  79703. /** @hidden */
  79704. _rebuild(): void;
  79705. /**
  79706. * Returns the kind of the VertexBuffer (string)
  79707. * @returns a string
  79708. */
  79709. getKind(): string;
  79710. /**
  79711. * Gets a boolean indicating if the VertexBuffer is updatable?
  79712. * @returns true if the buffer is updatable
  79713. */
  79714. isUpdatable(): boolean;
  79715. /**
  79716. * Gets current buffer's data
  79717. * @returns a DataArray or null
  79718. */
  79719. getData(): Nullable<DataArray>;
  79720. /**
  79721. * Gets underlying native buffer
  79722. * @returns underlying native buffer
  79723. */
  79724. getBuffer(): Nullable<DataBuffer>;
  79725. /**
  79726. * Gets the stride in float32 units (i.e. byte stride / 4).
  79727. * May not be an integer if the byte stride is not divisible by 4.
  79728. * @returns the stride in float32 units
  79729. * @deprecated Please use byteStride instead.
  79730. */
  79731. getStrideSize(): number;
  79732. /**
  79733. * Returns the offset as a multiple of the type byte length.
  79734. * @returns the offset in bytes
  79735. * @deprecated Please use byteOffset instead.
  79736. */
  79737. getOffset(): number;
  79738. /**
  79739. * Returns the number of components per vertex attribute (integer)
  79740. * @returns the size in float
  79741. */
  79742. getSize(): number;
  79743. /**
  79744. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79745. * @returns true if this buffer is instanced
  79746. */
  79747. getIsInstanced(): boolean;
  79748. /**
  79749. * Returns the instancing divisor, zero for non-instanced (integer).
  79750. * @returns a number
  79751. */
  79752. getInstanceDivisor(): number;
  79753. /**
  79754. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79755. * @param data defines the data to store
  79756. */
  79757. create(data?: DataArray): void;
  79758. /**
  79759. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79760. * This function will create a new buffer if the current one is not updatable
  79761. * @param data defines the data to store
  79762. */
  79763. update(data: DataArray): void;
  79764. /**
  79765. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79766. * Returns the directly updated WebGLBuffer.
  79767. * @param data the new data
  79768. * @param offset the new offset
  79769. * @param useBytes set to true if the offset is in bytes
  79770. */
  79771. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79772. /**
  79773. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79774. */
  79775. dispose(): void;
  79776. /**
  79777. * Enumerates each value of this vertex buffer as numbers.
  79778. * @param count the number of values to enumerate
  79779. * @param callback the callback function called for each value
  79780. */
  79781. forEach(count: number, callback: (value: number, index: number) => void): void;
  79782. /**
  79783. * Positions
  79784. */
  79785. static readonly PositionKind: string;
  79786. /**
  79787. * Normals
  79788. */
  79789. static readonly NormalKind: string;
  79790. /**
  79791. * Tangents
  79792. */
  79793. static readonly TangentKind: string;
  79794. /**
  79795. * Texture coordinates
  79796. */
  79797. static readonly UVKind: string;
  79798. /**
  79799. * Texture coordinates 2
  79800. */
  79801. static readonly UV2Kind: string;
  79802. /**
  79803. * Texture coordinates 3
  79804. */
  79805. static readonly UV3Kind: string;
  79806. /**
  79807. * Texture coordinates 4
  79808. */
  79809. static readonly UV4Kind: string;
  79810. /**
  79811. * Texture coordinates 5
  79812. */
  79813. static readonly UV5Kind: string;
  79814. /**
  79815. * Texture coordinates 6
  79816. */
  79817. static readonly UV6Kind: string;
  79818. /**
  79819. * Colors
  79820. */
  79821. static readonly ColorKind: string;
  79822. /**
  79823. * Matrix indices (for bones)
  79824. */
  79825. static readonly MatricesIndicesKind: string;
  79826. /**
  79827. * Matrix weights (for bones)
  79828. */
  79829. static readonly MatricesWeightsKind: string;
  79830. /**
  79831. * Additional matrix indices (for bones)
  79832. */
  79833. static readonly MatricesIndicesExtraKind: string;
  79834. /**
  79835. * Additional matrix weights (for bones)
  79836. */
  79837. static readonly MatricesWeightsExtraKind: string;
  79838. /**
  79839. * Deduces the stride given a kind.
  79840. * @param kind The kind string to deduce
  79841. * @returns The deduced stride
  79842. */
  79843. static DeduceStride(kind: string): number;
  79844. /**
  79845. * Gets the byte length of the given type.
  79846. * @param type the type
  79847. * @returns the number of bytes
  79848. */
  79849. static GetTypeByteLength(type: number): number;
  79850. /**
  79851. * Enumerates each value of the given parameters as numbers.
  79852. * @param data the data to enumerate
  79853. * @param byteOffset the byte offset of the data
  79854. * @param byteStride the byte stride of the data
  79855. * @param componentCount the number of components per element
  79856. * @param componentType the type of the component
  79857. * @param count the number of values to enumerate
  79858. * @param normalized whether the data is normalized
  79859. * @param callback the callback function called for each value
  79860. */
  79861. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79862. private static _GetFloatValue;
  79863. }
  79864. }
  79865. declare module BABYLON {
  79866. /**
  79867. * @hidden
  79868. */
  79869. export class IntersectionInfo {
  79870. bu: Nullable<number>;
  79871. bv: Nullable<number>;
  79872. distance: number;
  79873. faceId: number;
  79874. subMeshId: number;
  79875. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79876. }
  79877. }
  79878. declare module BABYLON {
  79879. /**
  79880. * Represens a plane by the equation ax + by + cz + d = 0
  79881. */
  79882. export class Plane {
  79883. private static _TmpMatrix;
  79884. /**
  79885. * Normal of the plane (a,b,c)
  79886. */
  79887. normal: Vector3;
  79888. /**
  79889. * d component of the plane
  79890. */
  79891. d: number;
  79892. /**
  79893. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79894. * @param a a component of the plane
  79895. * @param b b component of the plane
  79896. * @param c c component of the plane
  79897. * @param d d component of the plane
  79898. */
  79899. constructor(a: number, b: number, c: number, d: number);
  79900. /**
  79901. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79902. */
  79903. asArray(): number[];
  79904. /**
  79905. * @returns a new plane copied from the current Plane.
  79906. */
  79907. clone(): Plane;
  79908. /**
  79909. * @returns the string "Plane".
  79910. */
  79911. getClassName(): string;
  79912. /**
  79913. * @returns the Plane hash code.
  79914. */
  79915. getHashCode(): number;
  79916. /**
  79917. * Normalize the current Plane in place.
  79918. * @returns the updated Plane.
  79919. */
  79920. normalize(): Plane;
  79921. /**
  79922. * Applies a transformation the plane and returns the result
  79923. * @param transformation the transformation matrix to be applied to the plane
  79924. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79925. */
  79926. transform(transformation: DeepImmutable<Matrix>): Plane;
  79927. /**
  79928. * Calcualtte the dot product between the point and the plane normal
  79929. * @param point point to calculate the dot product with
  79930. * @returns the dot product (float) of the point coordinates and the plane normal.
  79931. */
  79932. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79933. /**
  79934. * Updates the current Plane from the plane defined by the three given points.
  79935. * @param point1 one of the points used to contruct the plane
  79936. * @param point2 one of the points used to contruct the plane
  79937. * @param point3 one of the points used to contruct the plane
  79938. * @returns the updated Plane.
  79939. */
  79940. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79941. /**
  79942. * Checks if the plane is facing a given direction
  79943. * @param direction the direction to check if the plane is facing
  79944. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79945. * @returns True is the vector "direction" is the same side than the plane normal.
  79946. */
  79947. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79948. /**
  79949. * Calculates the distance to a point
  79950. * @param point point to calculate distance to
  79951. * @returns the signed distance (float) from the given point to the Plane.
  79952. */
  79953. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79954. /**
  79955. * Creates a plane from an array
  79956. * @param array the array to create a plane from
  79957. * @returns a new Plane from the given array.
  79958. */
  79959. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79960. /**
  79961. * Creates a plane from three points
  79962. * @param point1 point used to create the plane
  79963. * @param point2 point used to create the plane
  79964. * @param point3 point used to create the plane
  79965. * @returns a new Plane defined by the three given points.
  79966. */
  79967. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79968. /**
  79969. * Creates a plane from an origin point and a normal
  79970. * @param origin origin of the plane to be constructed
  79971. * @param normal normal of the plane to be constructed
  79972. * @returns a new Plane the normal vector to this plane at the given origin point.
  79973. * Note : the vector "normal" is updated because normalized.
  79974. */
  79975. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79976. /**
  79977. * Calculates the distance from a plane and a point
  79978. * @param origin origin of the plane to be constructed
  79979. * @param normal normal of the plane to be constructed
  79980. * @param point point to calculate distance to
  79981. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79982. */
  79983. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79984. }
  79985. }
  79986. declare module BABYLON {
  79987. /**
  79988. * Class used to store bounding sphere information
  79989. */
  79990. export class BoundingSphere {
  79991. /**
  79992. * Gets the center of the bounding sphere in local space
  79993. */
  79994. readonly center: Vector3;
  79995. /**
  79996. * Radius of the bounding sphere in local space
  79997. */
  79998. radius: number;
  79999. /**
  80000. * Gets the center of the bounding sphere in world space
  80001. */
  80002. readonly centerWorld: Vector3;
  80003. /**
  80004. * Radius of the bounding sphere in world space
  80005. */
  80006. radiusWorld: number;
  80007. /**
  80008. * Gets the minimum vector in local space
  80009. */
  80010. readonly minimum: Vector3;
  80011. /**
  80012. * Gets the maximum vector in local space
  80013. */
  80014. readonly maximum: Vector3;
  80015. private _worldMatrix;
  80016. private static readonly TmpVector3;
  80017. /**
  80018. * Creates a new bounding sphere
  80019. * @param min defines the minimum vector (in local space)
  80020. * @param max defines the maximum vector (in local space)
  80021. * @param worldMatrix defines the new world matrix
  80022. */
  80023. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80024. /**
  80025. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80026. * @param min defines the new minimum vector (in local space)
  80027. * @param max defines the new maximum vector (in local space)
  80028. * @param worldMatrix defines the new world matrix
  80029. */
  80030. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80031. /**
  80032. * Scale the current bounding sphere by applying a scale factor
  80033. * @param factor defines the scale factor to apply
  80034. * @returns the current bounding box
  80035. */
  80036. scale(factor: number): BoundingSphere;
  80037. /**
  80038. * Gets the world matrix of the bounding box
  80039. * @returns a matrix
  80040. */
  80041. getWorldMatrix(): DeepImmutable<Matrix>;
  80042. /** @hidden */
  80043. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80044. /**
  80045. * Tests if the bounding sphere is intersecting the frustum planes
  80046. * @param frustumPlanes defines the frustum planes to test
  80047. * @returns true if there is an intersection
  80048. */
  80049. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80050. /**
  80051. * Tests if the bounding sphere center is in between the frustum planes.
  80052. * Used for optimistic fast inclusion.
  80053. * @param frustumPlanes defines the frustum planes to test
  80054. * @returns true if the sphere center is in between the frustum planes
  80055. */
  80056. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80057. /**
  80058. * Tests if a point is inside the bounding sphere
  80059. * @param point defines the point to test
  80060. * @returns true if the point is inside the bounding sphere
  80061. */
  80062. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80063. /**
  80064. * Checks if two sphere intersct
  80065. * @param sphere0 sphere 0
  80066. * @param sphere1 sphere 1
  80067. * @returns true if the speres intersect
  80068. */
  80069. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80070. }
  80071. }
  80072. declare module BABYLON {
  80073. /**
  80074. * Class used to store bounding box information
  80075. */
  80076. export class BoundingBox implements ICullable {
  80077. /**
  80078. * Gets the 8 vectors representing the bounding box in local space
  80079. */
  80080. readonly vectors: Vector3[];
  80081. /**
  80082. * Gets the center of the bounding box in local space
  80083. */
  80084. readonly center: Vector3;
  80085. /**
  80086. * Gets the center of the bounding box in world space
  80087. */
  80088. readonly centerWorld: Vector3;
  80089. /**
  80090. * Gets the extend size in local space
  80091. */
  80092. readonly extendSize: Vector3;
  80093. /**
  80094. * Gets the extend size in world space
  80095. */
  80096. readonly extendSizeWorld: Vector3;
  80097. /**
  80098. * Gets the OBB (object bounding box) directions
  80099. */
  80100. readonly directions: Vector3[];
  80101. /**
  80102. * Gets the 8 vectors representing the bounding box in world space
  80103. */
  80104. readonly vectorsWorld: Vector3[];
  80105. /**
  80106. * Gets the minimum vector in world space
  80107. */
  80108. readonly minimumWorld: Vector3;
  80109. /**
  80110. * Gets the maximum vector in world space
  80111. */
  80112. readonly maximumWorld: Vector3;
  80113. /**
  80114. * Gets the minimum vector in local space
  80115. */
  80116. readonly minimum: Vector3;
  80117. /**
  80118. * Gets the maximum vector in local space
  80119. */
  80120. readonly maximum: Vector3;
  80121. private _worldMatrix;
  80122. private static readonly TmpVector3;
  80123. /**
  80124. * @hidden
  80125. */
  80126. _tag: number;
  80127. /**
  80128. * Creates a new bounding box
  80129. * @param min defines the minimum vector (in local space)
  80130. * @param max defines the maximum vector (in local space)
  80131. * @param worldMatrix defines the new world matrix
  80132. */
  80133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80134. /**
  80135. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80136. * @param min defines the new minimum vector (in local space)
  80137. * @param max defines the new maximum vector (in local space)
  80138. * @param worldMatrix defines the new world matrix
  80139. */
  80140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80141. /**
  80142. * Scale the current bounding box by applying a scale factor
  80143. * @param factor defines the scale factor to apply
  80144. * @returns the current bounding box
  80145. */
  80146. scale(factor: number): BoundingBox;
  80147. /**
  80148. * Gets the world matrix of the bounding box
  80149. * @returns a matrix
  80150. */
  80151. getWorldMatrix(): DeepImmutable<Matrix>;
  80152. /** @hidden */
  80153. _update(world: DeepImmutable<Matrix>): void;
  80154. /**
  80155. * Tests if the bounding box is intersecting the frustum planes
  80156. * @param frustumPlanes defines the frustum planes to test
  80157. * @returns true if there is an intersection
  80158. */
  80159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80160. /**
  80161. * Tests if the bounding box is entirely inside the frustum planes
  80162. * @param frustumPlanes defines the frustum planes to test
  80163. * @returns true if there is an inclusion
  80164. */
  80165. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80166. /**
  80167. * Tests if a point is inside the bounding box
  80168. * @param point defines the point to test
  80169. * @returns true if the point is inside the bounding box
  80170. */
  80171. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80172. /**
  80173. * Tests if the bounding box intersects with a bounding sphere
  80174. * @param sphere defines the sphere to test
  80175. * @returns true if there is an intersection
  80176. */
  80177. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80178. /**
  80179. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80180. * @param min defines the min vector to use
  80181. * @param max defines the max vector to use
  80182. * @returns true if there is an intersection
  80183. */
  80184. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80185. /**
  80186. * Tests if two bounding boxes are intersections
  80187. * @param box0 defines the first box to test
  80188. * @param box1 defines the second box to test
  80189. * @returns true if there is an intersection
  80190. */
  80191. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80192. /**
  80193. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80194. * @param minPoint defines the minimum vector of the bounding box
  80195. * @param maxPoint defines the maximum vector of the bounding box
  80196. * @param sphereCenter defines the sphere center
  80197. * @param sphereRadius defines the sphere radius
  80198. * @returns true if there is an intersection
  80199. */
  80200. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80201. /**
  80202. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80203. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80204. * @param frustumPlanes defines the frustum planes to test
  80205. * @return true if there is an inclusion
  80206. */
  80207. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80208. /**
  80209. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80210. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80211. * @param frustumPlanes defines the frustum planes to test
  80212. * @return true if there is an intersection
  80213. */
  80214. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80215. }
  80216. }
  80217. declare module BABYLON {
  80218. /** @hidden */
  80219. export class Collider {
  80220. /** Define if a collision was found */
  80221. collisionFound: boolean;
  80222. /**
  80223. * Define last intersection point in local space
  80224. */
  80225. intersectionPoint: Vector3;
  80226. /**
  80227. * Define last collided mesh
  80228. */
  80229. collidedMesh: Nullable<AbstractMesh>;
  80230. private _collisionPoint;
  80231. private _planeIntersectionPoint;
  80232. private _tempVector;
  80233. private _tempVector2;
  80234. private _tempVector3;
  80235. private _tempVector4;
  80236. private _edge;
  80237. private _baseToVertex;
  80238. private _destinationPoint;
  80239. private _slidePlaneNormal;
  80240. private _displacementVector;
  80241. /** @hidden */
  80242. _radius: Vector3;
  80243. /** @hidden */
  80244. _retry: number;
  80245. private _velocity;
  80246. private _basePoint;
  80247. private _epsilon;
  80248. /** @hidden */
  80249. _velocityWorldLength: number;
  80250. /** @hidden */
  80251. _basePointWorld: Vector3;
  80252. private _velocityWorld;
  80253. private _normalizedVelocity;
  80254. /** @hidden */
  80255. _initialVelocity: Vector3;
  80256. /** @hidden */
  80257. _initialPosition: Vector3;
  80258. private _nearestDistance;
  80259. private _collisionMask;
  80260. get collisionMask(): number;
  80261. set collisionMask(mask: number);
  80262. /**
  80263. * Gets the plane normal used to compute the sliding response (in local space)
  80264. */
  80265. get slidePlaneNormal(): Vector3;
  80266. /** @hidden */
  80267. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80268. /** @hidden */
  80269. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80270. /** @hidden */
  80271. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80272. /** @hidden */
  80273. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80274. /** @hidden */
  80275. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80276. /** @hidden */
  80277. _getResponse(pos: Vector3, vel: Vector3): void;
  80278. }
  80279. }
  80280. declare module BABYLON {
  80281. /**
  80282. * Interface for cullable objects
  80283. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80284. */
  80285. export interface ICullable {
  80286. /**
  80287. * Checks if the object or part of the object is in the frustum
  80288. * @param frustumPlanes Camera near/planes
  80289. * @returns true if the object is in frustum otherwise false
  80290. */
  80291. isInFrustum(frustumPlanes: Plane[]): boolean;
  80292. /**
  80293. * Checks if a cullable object (mesh...) is in the camera frustum
  80294. * Unlike isInFrustum this cheks the full bounding box
  80295. * @param frustumPlanes Camera near/planes
  80296. * @returns true if the object is in frustum otherwise false
  80297. */
  80298. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80299. }
  80300. /**
  80301. * Info for a bounding data of a mesh
  80302. */
  80303. export class BoundingInfo implements ICullable {
  80304. /**
  80305. * Bounding box for the mesh
  80306. */
  80307. readonly boundingBox: BoundingBox;
  80308. /**
  80309. * Bounding sphere for the mesh
  80310. */
  80311. readonly boundingSphere: BoundingSphere;
  80312. private _isLocked;
  80313. private static readonly TmpVector3;
  80314. /**
  80315. * Constructs bounding info
  80316. * @param minimum min vector of the bounding box/sphere
  80317. * @param maximum max vector of the bounding box/sphere
  80318. * @param worldMatrix defines the new world matrix
  80319. */
  80320. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80321. /**
  80322. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80323. * @param min defines the new minimum vector (in local space)
  80324. * @param max defines the new maximum vector (in local space)
  80325. * @param worldMatrix defines the new world matrix
  80326. */
  80327. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80328. /**
  80329. * min vector of the bounding box/sphere
  80330. */
  80331. get minimum(): Vector3;
  80332. /**
  80333. * max vector of the bounding box/sphere
  80334. */
  80335. get maximum(): Vector3;
  80336. /**
  80337. * If the info is locked and won't be updated to avoid perf overhead
  80338. */
  80339. get isLocked(): boolean;
  80340. set isLocked(value: boolean);
  80341. /**
  80342. * Updates the bounding sphere and box
  80343. * @param world world matrix to be used to update
  80344. */
  80345. update(world: DeepImmutable<Matrix>): void;
  80346. /**
  80347. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80348. * @param center New center of the bounding info
  80349. * @param extend New extend of the bounding info
  80350. * @returns the current bounding info
  80351. */
  80352. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80353. /**
  80354. * Scale the current bounding info by applying a scale factor
  80355. * @param factor defines the scale factor to apply
  80356. * @returns the current bounding info
  80357. */
  80358. scale(factor: number): BoundingInfo;
  80359. /**
  80360. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80361. * @param frustumPlanes defines the frustum to test
  80362. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80363. * @returns true if the bounding info is in the frustum planes
  80364. */
  80365. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80366. /**
  80367. * Gets the world distance between the min and max points of the bounding box
  80368. */
  80369. get diagonalLength(): number;
  80370. /**
  80371. * Checks if a cullable object (mesh...) is in the camera frustum
  80372. * Unlike isInFrustum this cheks the full bounding box
  80373. * @param frustumPlanes Camera near/planes
  80374. * @returns true if the object is in frustum otherwise false
  80375. */
  80376. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80377. /** @hidden */
  80378. _checkCollision(collider: Collider): boolean;
  80379. /**
  80380. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80381. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80382. * @param point the point to check intersection with
  80383. * @returns if the point intersects
  80384. */
  80385. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80386. /**
  80387. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80388. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80389. * @param boundingInfo the bounding info to check intersection with
  80390. * @param precise if the intersection should be done using OBB
  80391. * @returns if the bounding info intersects
  80392. */
  80393. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80394. }
  80395. }
  80396. declare module BABYLON {
  80397. /**
  80398. * Extracts minimum and maximum values from a list of indexed positions
  80399. * @param positions defines the positions to use
  80400. * @param indices defines the indices to the positions
  80401. * @param indexStart defines the start index
  80402. * @param indexCount defines the end index
  80403. * @param bias defines bias value to add to the result
  80404. * @return minimum and maximum values
  80405. */
  80406. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80407. minimum: Vector3;
  80408. maximum: Vector3;
  80409. };
  80410. /**
  80411. * Extracts minimum and maximum values from a list of positions
  80412. * @param positions defines the positions to use
  80413. * @param start defines the start index in the positions array
  80414. * @param count defines the number of positions to handle
  80415. * @param bias defines bias value to add to the result
  80416. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80417. * @return minimum and maximum values
  80418. */
  80419. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80420. minimum: Vector3;
  80421. maximum: Vector3;
  80422. };
  80423. }
  80424. declare module BABYLON {
  80425. /** @hidden */
  80426. export class WebGLDataBuffer extends DataBuffer {
  80427. private _buffer;
  80428. constructor(resource: WebGLBuffer);
  80429. get underlyingResource(): any;
  80430. }
  80431. }
  80432. declare module BABYLON {
  80433. /** @hidden */
  80434. export class WebGLPipelineContext implements IPipelineContext {
  80435. engine: ThinEngine;
  80436. program: Nullable<WebGLProgram>;
  80437. context?: WebGLRenderingContext;
  80438. vertexShader?: WebGLShader;
  80439. fragmentShader?: WebGLShader;
  80440. isParallelCompiled: boolean;
  80441. onCompiled?: () => void;
  80442. transformFeedback?: WebGLTransformFeedback | null;
  80443. vertexCompilationError: Nullable<string>;
  80444. fragmentCompilationError: Nullable<string>;
  80445. programLinkError: Nullable<string>;
  80446. programValidationError: Nullable<string>;
  80447. get isAsync(): boolean;
  80448. get isReady(): boolean;
  80449. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80450. }
  80451. }
  80452. declare module BABYLON {
  80453. interface ThinEngine {
  80454. /**
  80455. * Create an uniform buffer
  80456. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80457. * @param elements defines the content of the uniform buffer
  80458. * @returns the webGL uniform buffer
  80459. */
  80460. createUniformBuffer(elements: FloatArray): DataBuffer;
  80461. /**
  80462. * Create a dynamic uniform buffer
  80463. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80464. * @param elements defines the content of the uniform buffer
  80465. * @returns the webGL uniform buffer
  80466. */
  80467. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80468. /**
  80469. * Update an existing uniform buffer
  80470. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80471. * @param uniformBuffer defines the target uniform buffer
  80472. * @param elements defines the content to update
  80473. * @param offset defines the offset in the uniform buffer where update should start
  80474. * @param count defines the size of the data to update
  80475. */
  80476. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80477. /**
  80478. * Bind an uniform buffer to the current webGL context
  80479. * @param buffer defines the buffer to bind
  80480. */
  80481. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80482. /**
  80483. * Bind a buffer to the current webGL context at a given location
  80484. * @param buffer defines the buffer to bind
  80485. * @param location defines the index where to bind the buffer
  80486. */
  80487. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80488. /**
  80489. * Bind a specific block at a given index in a specific shader program
  80490. * @param pipelineContext defines the pipeline context to use
  80491. * @param blockName defines the block name
  80492. * @param index defines the index where to bind the block
  80493. */
  80494. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80495. }
  80496. }
  80497. declare module BABYLON {
  80498. /**
  80499. * Uniform buffer objects.
  80500. *
  80501. * Handles blocks of uniform on the GPU.
  80502. *
  80503. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80504. *
  80505. * For more information, please refer to :
  80506. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80507. */
  80508. export class UniformBuffer {
  80509. private _engine;
  80510. private _buffer;
  80511. private _data;
  80512. private _bufferData;
  80513. private _dynamic?;
  80514. private _uniformLocations;
  80515. private _uniformSizes;
  80516. private _uniformLocationPointer;
  80517. private _needSync;
  80518. private _noUBO;
  80519. private _currentEffect;
  80520. /** @hidden */
  80521. _alreadyBound: boolean;
  80522. private static _MAX_UNIFORM_SIZE;
  80523. private static _tempBuffer;
  80524. /**
  80525. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80526. * This is dynamic to allow compat with webgl 1 and 2.
  80527. * You will need to pass the name of the uniform as well as the value.
  80528. */
  80529. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80530. /**
  80531. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80532. * This is dynamic to allow compat with webgl 1 and 2.
  80533. * You will need to pass the name of the uniform as well as the value.
  80534. */
  80535. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80536. /**
  80537. * Lambda to Update a single float in a uniform buffer.
  80538. * This is dynamic to allow compat with webgl 1 and 2.
  80539. * You will need to pass the name of the uniform as well as the value.
  80540. */
  80541. updateFloat: (name: string, x: number) => void;
  80542. /**
  80543. * Lambda to Update a vec2 of float in a uniform buffer.
  80544. * This is dynamic to allow compat with webgl 1 and 2.
  80545. * You will need to pass the name of the uniform as well as the value.
  80546. */
  80547. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80548. /**
  80549. * Lambda to Update a vec3 of float in a uniform buffer.
  80550. * This is dynamic to allow compat with webgl 1 and 2.
  80551. * You will need to pass the name of the uniform as well as the value.
  80552. */
  80553. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80554. /**
  80555. * Lambda to Update a vec4 of float in a uniform buffer.
  80556. * This is dynamic to allow compat with webgl 1 and 2.
  80557. * You will need to pass the name of the uniform as well as the value.
  80558. */
  80559. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80560. /**
  80561. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80562. * This is dynamic to allow compat with webgl 1 and 2.
  80563. * You will need to pass the name of the uniform as well as the value.
  80564. */
  80565. updateMatrix: (name: string, mat: Matrix) => void;
  80566. /**
  80567. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80568. * This is dynamic to allow compat with webgl 1 and 2.
  80569. * You will need to pass the name of the uniform as well as the value.
  80570. */
  80571. updateVector3: (name: string, vector: Vector3) => void;
  80572. /**
  80573. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80574. * This is dynamic to allow compat with webgl 1 and 2.
  80575. * You will need to pass the name of the uniform as well as the value.
  80576. */
  80577. updateVector4: (name: string, vector: Vector4) => void;
  80578. /**
  80579. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80580. * This is dynamic to allow compat with webgl 1 and 2.
  80581. * You will need to pass the name of the uniform as well as the value.
  80582. */
  80583. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80584. /**
  80585. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80586. * This is dynamic to allow compat with webgl 1 and 2.
  80587. * You will need to pass the name of the uniform as well as the value.
  80588. */
  80589. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80590. /**
  80591. * Instantiates a new Uniform buffer objects.
  80592. *
  80593. * Handles blocks of uniform on the GPU.
  80594. *
  80595. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80596. *
  80597. * For more information, please refer to :
  80598. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80599. * @param engine Define the engine the buffer is associated with
  80600. * @param data Define the data contained in the buffer
  80601. * @param dynamic Define if the buffer is updatable
  80602. */
  80603. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80604. /**
  80605. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80606. * or just falling back on setUniformXXX calls.
  80607. */
  80608. get useUbo(): boolean;
  80609. /**
  80610. * Indicates if the WebGL underlying uniform buffer is in sync
  80611. * with the javascript cache data.
  80612. */
  80613. get isSync(): boolean;
  80614. /**
  80615. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80616. * Also, a dynamic UniformBuffer will disable cache verification and always
  80617. * update the underlying WebGL uniform buffer to the GPU.
  80618. * @returns if Dynamic, otherwise false
  80619. */
  80620. isDynamic(): boolean;
  80621. /**
  80622. * The data cache on JS side.
  80623. * @returns the underlying data as a float array
  80624. */
  80625. getData(): Float32Array;
  80626. /**
  80627. * The underlying WebGL Uniform buffer.
  80628. * @returns the webgl buffer
  80629. */
  80630. getBuffer(): Nullable<DataBuffer>;
  80631. /**
  80632. * std140 layout specifies how to align data within an UBO structure.
  80633. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80634. * for specs.
  80635. */
  80636. private _fillAlignment;
  80637. /**
  80638. * Adds an uniform in the buffer.
  80639. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80640. * for the layout to be correct !
  80641. * @param name Name of the uniform, as used in the uniform block in the shader.
  80642. * @param size Data size, or data directly.
  80643. */
  80644. addUniform(name: string, size: number | number[]): void;
  80645. /**
  80646. * Adds a Matrix 4x4 to the uniform buffer.
  80647. * @param name Name of the uniform, as used in the uniform block in the shader.
  80648. * @param mat A 4x4 matrix.
  80649. */
  80650. addMatrix(name: string, mat: Matrix): void;
  80651. /**
  80652. * Adds a vec2 to the uniform buffer.
  80653. * @param name Name of the uniform, as used in the uniform block in the shader.
  80654. * @param x Define the x component value of the vec2
  80655. * @param y Define the y component value of the vec2
  80656. */
  80657. addFloat2(name: string, x: number, y: number): void;
  80658. /**
  80659. * Adds a vec3 to the uniform buffer.
  80660. * @param name Name of the uniform, as used in the uniform block in the shader.
  80661. * @param x Define the x component value of the vec3
  80662. * @param y Define the y component value of the vec3
  80663. * @param z Define the z component value of the vec3
  80664. */
  80665. addFloat3(name: string, x: number, y: number, z: number): void;
  80666. /**
  80667. * Adds a vec3 to the uniform buffer.
  80668. * @param name Name of the uniform, as used in the uniform block in the shader.
  80669. * @param color Define the vec3 from a Color
  80670. */
  80671. addColor3(name: string, color: Color3): void;
  80672. /**
  80673. * Adds a vec4 to the uniform buffer.
  80674. * @param name Name of the uniform, as used in the uniform block in the shader.
  80675. * @param color Define the rgb components from a Color
  80676. * @param alpha Define the a component of the vec4
  80677. */
  80678. addColor4(name: string, color: Color3, alpha: number): void;
  80679. /**
  80680. * Adds a vec3 to the uniform buffer.
  80681. * @param name Name of the uniform, as used in the uniform block in the shader.
  80682. * @param vector Define the vec3 components from a Vector
  80683. */
  80684. addVector3(name: string, vector: Vector3): void;
  80685. /**
  80686. * Adds a Matrix 3x3 to the uniform buffer.
  80687. * @param name Name of the uniform, as used in the uniform block in the shader.
  80688. */
  80689. addMatrix3x3(name: string): void;
  80690. /**
  80691. * Adds a Matrix 2x2 to the uniform buffer.
  80692. * @param name Name of the uniform, as used in the uniform block in the shader.
  80693. */
  80694. addMatrix2x2(name: string): void;
  80695. /**
  80696. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80697. */
  80698. create(): void;
  80699. /** @hidden */
  80700. _rebuild(): void;
  80701. /**
  80702. * Updates the WebGL Uniform Buffer on the GPU.
  80703. * If the `dynamic` flag is set to true, no cache comparison is done.
  80704. * Otherwise, the buffer will be updated only if the cache differs.
  80705. */
  80706. update(): void;
  80707. /**
  80708. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80709. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80710. * @param data Define the flattened data
  80711. * @param size Define the size of the data.
  80712. */
  80713. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80714. private _valueCache;
  80715. private _cacheMatrix;
  80716. private _updateMatrix3x3ForUniform;
  80717. private _updateMatrix3x3ForEffect;
  80718. private _updateMatrix2x2ForEffect;
  80719. private _updateMatrix2x2ForUniform;
  80720. private _updateFloatForEffect;
  80721. private _updateFloatForUniform;
  80722. private _updateFloat2ForEffect;
  80723. private _updateFloat2ForUniform;
  80724. private _updateFloat3ForEffect;
  80725. private _updateFloat3ForUniform;
  80726. private _updateFloat4ForEffect;
  80727. private _updateFloat4ForUniform;
  80728. private _updateMatrixForEffect;
  80729. private _updateMatrixForUniform;
  80730. private _updateVector3ForEffect;
  80731. private _updateVector3ForUniform;
  80732. private _updateVector4ForEffect;
  80733. private _updateVector4ForUniform;
  80734. private _updateColor3ForEffect;
  80735. private _updateColor3ForUniform;
  80736. private _updateColor4ForEffect;
  80737. private _updateColor4ForUniform;
  80738. /**
  80739. * Sets a sampler uniform on the effect.
  80740. * @param name Define the name of the sampler.
  80741. * @param texture Define the texture to set in the sampler
  80742. */
  80743. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80744. /**
  80745. * Directly updates the value of the uniform in the cache AND on the GPU.
  80746. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80747. * @param data Define the flattened data
  80748. */
  80749. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80750. /**
  80751. * Binds this uniform buffer to an effect.
  80752. * @param effect Define the effect to bind the buffer to
  80753. * @param name Name of the uniform block in the shader.
  80754. */
  80755. bindToEffect(effect: Effect, name: string): void;
  80756. /**
  80757. * Disposes the uniform buffer.
  80758. */
  80759. dispose(): void;
  80760. }
  80761. }
  80762. declare module BABYLON {
  80763. /**
  80764. * Enum that determines the text-wrapping mode to use.
  80765. */
  80766. export enum InspectableType {
  80767. /**
  80768. * Checkbox for booleans
  80769. */
  80770. Checkbox = 0,
  80771. /**
  80772. * Sliders for numbers
  80773. */
  80774. Slider = 1,
  80775. /**
  80776. * Vector3
  80777. */
  80778. Vector3 = 2,
  80779. /**
  80780. * Quaternions
  80781. */
  80782. Quaternion = 3,
  80783. /**
  80784. * Color3
  80785. */
  80786. Color3 = 4,
  80787. /**
  80788. * String
  80789. */
  80790. String = 5
  80791. }
  80792. /**
  80793. * Interface used to define custom inspectable properties.
  80794. * This interface is used by the inspector to display custom property grids
  80795. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80796. */
  80797. export interface IInspectable {
  80798. /**
  80799. * Gets the label to display
  80800. */
  80801. label: string;
  80802. /**
  80803. * Gets the name of the property to edit
  80804. */
  80805. propertyName: string;
  80806. /**
  80807. * Gets the type of the editor to use
  80808. */
  80809. type: InspectableType;
  80810. /**
  80811. * Gets the minimum value of the property when using in "slider" mode
  80812. */
  80813. min?: number;
  80814. /**
  80815. * Gets the maximum value of the property when using in "slider" mode
  80816. */
  80817. max?: number;
  80818. /**
  80819. * Gets the setp to use when using in "slider" mode
  80820. */
  80821. step?: number;
  80822. }
  80823. }
  80824. declare module BABYLON {
  80825. /**
  80826. * Class used to provide helper for timing
  80827. */
  80828. export class TimingTools {
  80829. /**
  80830. * Polyfill for setImmediate
  80831. * @param action defines the action to execute after the current execution block
  80832. */
  80833. static SetImmediate(action: () => void): void;
  80834. }
  80835. }
  80836. declare module BABYLON {
  80837. /**
  80838. * Class used to enable instatition of objects by class name
  80839. */
  80840. export class InstantiationTools {
  80841. /**
  80842. * Use this object to register external classes like custom textures or material
  80843. * to allow the laoders to instantiate them
  80844. */
  80845. static RegisteredExternalClasses: {
  80846. [key: string]: Object;
  80847. };
  80848. /**
  80849. * Tries to instantiate a new object from a given class name
  80850. * @param className defines the class name to instantiate
  80851. * @returns the new object or null if the system was not able to do the instantiation
  80852. */
  80853. static Instantiate(className: string): any;
  80854. }
  80855. }
  80856. declare module BABYLON {
  80857. /**
  80858. * Define options used to create a depth texture
  80859. */
  80860. export class DepthTextureCreationOptions {
  80861. /** Specifies whether or not a stencil should be allocated in the texture */
  80862. generateStencil?: boolean;
  80863. /** Specifies whether or not bilinear filtering is enable on the texture */
  80864. bilinearFiltering?: boolean;
  80865. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80866. comparisonFunction?: number;
  80867. /** Specifies if the created texture is a cube texture */
  80868. isCube?: boolean;
  80869. }
  80870. }
  80871. declare module BABYLON {
  80872. interface ThinEngine {
  80873. /**
  80874. * Creates a depth stencil cube texture.
  80875. * This is only available in WebGL 2.
  80876. * @param size The size of face edge in the cube texture.
  80877. * @param options The options defining the cube texture.
  80878. * @returns The cube texture
  80879. */
  80880. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80881. /**
  80882. * Creates a cube texture
  80883. * @param rootUrl defines the url where the files to load is located
  80884. * @param scene defines the current scene
  80885. * @param files defines the list of files to load (1 per face)
  80886. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80887. * @param onLoad defines an optional callback raised when the texture is loaded
  80888. * @param onError defines an optional callback raised if there is an issue to load the texture
  80889. * @param format defines the format of the data
  80890. * @param forcedExtension defines the extension to use to pick the right loader
  80891. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80892. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80893. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80894. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80895. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80896. * @returns the cube texture as an InternalTexture
  80897. */
  80898. 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;
  80899. /**
  80900. * Creates a cube texture
  80901. * @param rootUrl defines the url where the files to load is located
  80902. * @param scene defines the current scene
  80903. * @param files defines the list of files to load (1 per face)
  80904. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80905. * @param onLoad defines an optional callback raised when the texture is loaded
  80906. * @param onError defines an optional callback raised if there is an issue to load the texture
  80907. * @param format defines the format of the data
  80908. * @param forcedExtension defines the extension to use to pick the right loader
  80909. * @returns the cube texture as an InternalTexture
  80910. */
  80911. 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;
  80912. /**
  80913. * Creates a cube texture
  80914. * @param rootUrl defines the url where the files to load is located
  80915. * @param scene defines the current scene
  80916. * @param files defines the list of files to load (1 per face)
  80917. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80918. * @param onLoad defines an optional callback raised when the texture is loaded
  80919. * @param onError defines an optional callback raised if there is an issue to load the texture
  80920. * @param format defines the format of the data
  80921. * @param forcedExtension defines the extension to use to pick the right loader
  80922. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80923. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80924. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80925. * @returns the cube texture as an InternalTexture
  80926. */
  80927. 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;
  80928. /** @hidden */
  80929. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80930. /** @hidden */
  80931. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80932. /** @hidden */
  80933. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80934. /** @hidden */
  80935. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80936. /**
  80937. * @hidden
  80938. */
  80939. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80940. }
  80941. }
  80942. declare module BABYLON {
  80943. /**
  80944. * Class for creating a cube texture
  80945. */
  80946. export class CubeTexture extends BaseTexture {
  80947. private _delayedOnLoad;
  80948. /**
  80949. * Observable triggered once the texture has been loaded.
  80950. */
  80951. onLoadObservable: Observable<CubeTexture>;
  80952. /**
  80953. * The url of the texture
  80954. */
  80955. url: string;
  80956. /**
  80957. * Gets or sets the center of the bounding box associated with the cube texture.
  80958. * It must define where the camera used to render the texture was set
  80959. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80960. */
  80961. boundingBoxPosition: Vector3;
  80962. private _boundingBoxSize;
  80963. /**
  80964. * Gets or sets the size of the bounding box associated with the cube texture
  80965. * When defined, the cubemap will switch to local mode
  80966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80967. * @example https://www.babylonjs-playground.com/#RNASML
  80968. */
  80969. set boundingBoxSize(value: Vector3);
  80970. /**
  80971. * Returns the bounding box size
  80972. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80973. */
  80974. get boundingBoxSize(): Vector3;
  80975. protected _rotationY: number;
  80976. /**
  80977. * Sets texture matrix rotation angle around Y axis in radians.
  80978. */
  80979. set rotationY(value: number);
  80980. /**
  80981. * Gets texture matrix rotation angle around Y axis radians.
  80982. */
  80983. get rotationY(): number;
  80984. /**
  80985. * Are mip maps generated for this texture or not.
  80986. */
  80987. get noMipmap(): boolean;
  80988. private _noMipmap;
  80989. private _files;
  80990. protected _forcedExtension: Nullable<string>;
  80991. private _extensions;
  80992. private _textureMatrix;
  80993. private _format;
  80994. private _createPolynomials;
  80995. /** @hidden */
  80996. _prefiltered: boolean;
  80997. /**
  80998. * Creates a cube texture from an array of image urls
  80999. * @param files defines an array of image urls
  81000. * @param scene defines the hosting scene
  81001. * @param noMipmap specifies if mip maps are not used
  81002. * @returns a cube texture
  81003. */
  81004. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81005. /**
  81006. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81007. * @param url defines the url of the prefiltered texture
  81008. * @param scene defines the scene the texture is attached to
  81009. * @param forcedExtension defines the extension of the file if different from the url
  81010. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81011. * @return the prefiltered texture
  81012. */
  81013. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81014. /**
  81015. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81016. * as prefiltered data.
  81017. * @param rootUrl defines the url of the texture or the root name of the six images
  81018. * @param scene defines the scene the texture is attached to
  81019. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81020. * @param noMipmap defines if mipmaps should be created or not
  81021. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81022. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81023. * @param onError defines a callback triggered in case of error during load
  81024. * @param format defines the internal format to use for the texture once loaded
  81025. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81026. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81027. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81030. * @return the cube texture
  81031. */
  81032. 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);
  81033. /**
  81034. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81035. */
  81036. get isPrefiltered(): boolean;
  81037. /**
  81038. * Get the current class name of the texture useful for serialization or dynamic coding.
  81039. * @returns "CubeTexture"
  81040. */
  81041. getClassName(): string;
  81042. /**
  81043. * Update the url (and optional buffer) of this texture if url was null during construction.
  81044. * @param url the url of the texture
  81045. * @param forcedExtension defines the extension to use
  81046. * @param onLoad callback called when the texture is loaded (defaults to null)
  81047. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81048. */
  81049. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81050. /**
  81051. * Delays loading of the cube texture
  81052. * @param forcedExtension defines the extension to use
  81053. */
  81054. delayLoad(forcedExtension?: string): void;
  81055. /**
  81056. * Returns the reflection texture matrix
  81057. * @returns the reflection texture matrix
  81058. */
  81059. getReflectionTextureMatrix(): Matrix;
  81060. /**
  81061. * Sets the reflection texture matrix
  81062. * @param value Reflection texture matrix
  81063. */
  81064. setReflectionTextureMatrix(value: Matrix): void;
  81065. /**
  81066. * Parses text to create a cube texture
  81067. * @param parsedTexture define the serialized text to read from
  81068. * @param scene defines the hosting scene
  81069. * @param rootUrl defines the root url of the cube texture
  81070. * @returns a cube texture
  81071. */
  81072. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81073. /**
  81074. * Makes a clone, or deep copy, of the cube texture
  81075. * @returns a new cube texture
  81076. */
  81077. clone(): CubeTexture;
  81078. }
  81079. }
  81080. declare module BABYLON {
  81081. /**
  81082. * Manages the defines for the Material
  81083. */
  81084. export class MaterialDefines {
  81085. /** @hidden */
  81086. protected _keys: string[];
  81087. private _isDirty;
  81088. /** @hidden */
  81089. _renderId: number;
  81090. /** @hidden */
  81091. _areLightsDirty: boolean;
  81092. /** @hidden */
  81093. _areLightsDisposed: boolean;
  81094. /** @hidden */
  81095. _areAttributesDirty: boolean;
  81096. /** @hidden */
  81097. _areTexturesDirty: boolean;
  81098. /** @hidden */
  81099. _areFresnelDirty: boolean;
  81100. /** @hidden */
  81101. _areMiscDirty: boolean;
  81102. /** @hidden */
  81103. _areImageProcessingDirty: boolean;
  81104. /** @hidden */
  81105. _normals: boolean;
  81106. /** @hidden */
  81107. _uvs: boolean;
  81108. /** @hidden */
  81109. _needNormals: boolean;
  81110. /** @hidden */
  81111. _needUVs: boolean;
  81112. [id: string]: any;
  81113. /**
  81114. * Specifies if the material needs to be re-calculated
  81115. */
  81116. get isDirty(): boolean;
  81117. /**
  81118. * Marks the material to indicate that it has been re-calculated
  81119. */
  81120. markAsProcessed(): void;
  81121. /**
  81122. * Marks the material to indicate that it needs to be re-calculated
  81123. */
  81124. markAsUnprocessed(): void;
  81125. /**
  81126. * Marks the material to indicate all of its defines need to be re-calculated
  81127. */
  81128. markAllAsDirty(): void;
  81129. /**
  81130. * Marks the material to indicate that image processing needs to be re-calculated
  81131. */
  81132. markAsImageProcessingDirty(): void;
  81133. /**
  81134. * Marks the material to indicate the lights need to be re-calculated
  81135. * @param disposed Defines whether the light is dirty due to dispose or not
  81136. */
  81137. markAsLightDirty(disposed?: boolean): void;
  81138. /**
  81139. * Marks the attribute state as changed
  81140. */
  81141. markAsAttributesDirty(): void;
  81142. /**
  81143. * Marks the texture state as changed
  81144. */
  81145. markAsTexturesDirty(): void;
  81146. /**
  81147. * Marks the fresnel state as changed
  81148. */
  81149. markAsFresnelDirty(): void;
  81150. /**
  81151. * Marks the misc state as changed
  81152. */
  81153. markAsMiscDirty(): void;
  81154. /**
  81155. * Rebuilds the material defines
  81156. */
  81157. rebuild(): void;
  81158. /**
  81159. * Specifies if two material defines are equal
  81160. * @param other - A material define instance to compare to
  81161. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81162. */
  81163. isEqual(other: MaterialDefines): boolean;
  81164. /**
  81165. * Clones this instance's defines to another instance
  81166. * @param other - material defines to clone values to
  81167. */
  81168. cloneTo(other: MaterialDefines): void;
  81169. /**
  81170. * Resets the material define values
  81171. */
  81172. reset(): void;
  81173. /**
  81174. * Converts the material define values to a string
  81175. * @returns - String of material define information
  81176. */
  81177. toString(): string;
  81178. }
  81179. }
  81180. declare module BABYLON {
  81181. /**
  81182. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81183. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81184. * 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;
  81185. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81186. */
  81187. export class ColorCurves {
  81188. private _dirty;
  81189. private _tempColor;
  81190. private _globalCurve;
  81191. private _highlightsCurve;
  81192. private _midtonesCurve;
  81193. private _shadowsCurve;
  81194. private _positiveCurve;
  81195. private _negativeCurve;
  81196. private _globalHue;
  81197. private _globalDensity;
  81198. private _globalSaturation;
  81199. private _globalExposure;
  81200. /**
  81201. * Gets the global Hue value.
  81202. * 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).
  81203. */
  81204. get globalHue(): number;
  81205. /**
  81206. * Sets the global Hue value.
  81207. * 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).
  81208. */
  81209. set globalHue(value: number);
  81210. /**
  81211. * Gets the global Density value.
  81212. * 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.
  81213. * Values less than zero provide a filter of opposite hue.
  81214. */
  81215. get globalDensity(): number;
  81216. /**
  81217. * Sets the global Density value.
  81218. * 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.
  81219. * Values less than zero provide a filter of opposite hue.
  81220. */
  81221. set globalDensity(value: number);
  81222. /**
  81223. * Gets the global Saturation value.
  81224. * 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.
  81225. */
  81226. get globalSaturation(): number;
  81227. /**
  81228. * Sets the global Saturation value.
  81229. * 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.
  81230. */
  81231. set globalSaturation(value: number);
  81232. /**
  81233. * Gets the global Exposure value.
  81234. * 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.
  81235. */
  81236. get globalExposure(): number;
  81237. /**
  81238. * Sets the global Exposure value.
  81239. * 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.
  81240. */
  81241. set globalExposure(value: number);
  81242. private _highlightsHue;
  81243. private _highlightsDensity;
  81244. private _highlightsSaturation;
  81245. private _highlightsExposure;
  81246. /**
  81247. * Gets the highlights Hue value.
  81248. * 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).
  81249. */
  81250. get highlightsHue(): number;
  81251. /**
  81252. * Sets the highlights Hue value.
  81253. * 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).
  81254. */
  81255. set highlightsHue(value: number);
  81256. /**
  81257. * Gets the highlights Density value.
  81258. * 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.
  81259. * Values less than zero provide a filter of opposite hue.
  81260. */
  81261. get highlightsDensity(): number;
  81262. /**
  81263. * Sets the highlights Density value.
  81264. * 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.
  81265. * Values less than zero provide a filter of opposite hue.
  81266. */
  81267. set highlightsDensity(value: number);
  81268. /**
  81269. * Gets the highlights Saturation value.
  81270. * 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.
  81271. */
  81272. get highlightsSaturation(): number;
  81273. /**
  81274. * Sets the highlights Saturation value.
  81275. * 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.
  81276. */
  81277. set highlightsSaturation(value: number);
  81278. /**
  81279. * Gets the highlights Exposure value.
  81280. * 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.
  81281. */
  81282. get highlightsExposure(): number;
  81283. /**
  81284. * Sets the highlights Exposure value.
  81285. * 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.
  81286. */
  81287. set highlightsExposure(value: number);
  81288. private _midtonesHue;
  81289. private _midtonesDensity;
  81290. private _midtonesSaturation;
  81291. private _midtonesExposure;
  81292. /**
  81293. * Gets the midtones Hue value.
  81294. * 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).
  81295. */
  81296. get midtonesHue(): number;
  81297. /**
  81298. * Sets the midtones Hue value.
  81299. * 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).
  81300. */
  81301. set midtonesHue(value: number);
  81302. /**
  81303. * Gets the midtones Density value.
  81304. * 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.
  81305. * Values less than zero provide a filter of opposite hue.
  81306. */
  81307. get midtonesDensity(): number;
  81308. /**
  81309. * Sets the midtones Density value.
  81310. * 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.
  81311. * Values less than zero provide a filter of opposite hue.
  81312. */
  81313. set midtonesDensity(value: number);
  81314. /**
  81315. * Gets the midtones Saturation value.
  81316. * 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.
  81317. */
  81318. get midtonesSaturation(): number;
  81319. /**
  81320. * Sets the midtones Saturation value.
  81321. * 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.
  81322. */
  81323. set midtonesSaturation(value: number);
  81324. /**
  81325. * Gets the midtones Exposure value.
  81326. * 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.
  81327. */
  81328. get midtonesExposure(): number;
  81329. /**
  81330. * Sets the midtones Exposure value.
  81331. * 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.
  81332. */
  81333. set midtonesExposure(value: number);
  81334. private _shadowsHue;
  81335. private _shadowsDensity;
  81336. private _shadowsSaturation;
  81337. private _shadowsExposure;
  81338. /**
  81339. * Gets the shadows Hue value.
  81340. * 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).
  81341. */
  81342. get shadowsHue(): number;
  81343. /**
  81344. * Sets the shadows Hue value.
  81345. * 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).
  81346. */
  81347. set shadowsHue(value: number);
  81348. /**
  81349. * Gets the shadows Density value.
  81350. * 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.
  81351. * Values less than zero provide a filter of opposite hue.
  81352. */
  81353. get shadowsDensity(): number;
  81354. /**
  81355. * Sets the shadows Density value.
  81356. * 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.
  81357. * Values less than zero provide a filter of opposite hue.
  81358. */
  81359. set shadowsDensity(value: number);
  81360. /**
  81361. * Gets the shadows Saturation value.
  81362. * 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.
  81363. */
  81364. get shadowsSaturation(): number;
  81365. /**
  81366. * Sets the shadows Saturation value.
  81367. * 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.
  81368. */
  81369. set shadowsSaturation(value: number);
  81370. /**
  81371. * Gets the shadows Exposure value.
  81372. * 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.
  81373. */
  81374. get shadowsExposure(): number;
  81375. /**
  81376. * Sets the shadows Exposure value.
  81377. * 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.
  81378. */
  81379. set shadowsExposure(value: number);
  81380. /**
  81381. * Returns the class name
  81382. * @returns The class name
  81383. */
  81384. getClassName(): string;
  81385. /**
  81386. * Binds the color curves to the shader.
  81387. * @param colorCurves The color curve to bind
  81388. * @param effect The effect to bind to
  81389. * @param positiveUniform The positive uniform shader parameter
  81390. * @param neutralUniform The neutral uniform shader parameter
  81391. * @param negativeUniform The negative uniform shader parameter
  81392. */
  81393. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81394. /**
  81395. * Prepare the list of uniforms associated with the ColorCurves effects.
  81396. * @param uniformsList The list of uniforms used in the effect
  81397. */
  81398. static PrepareUniforms(uniformsList: string[]): void;
  81399. /**
  81400. * Returns color grading data based on a hue, density, saturation and exposure value.
  81401. * @param filterHue The hue of the color filter.
  81402. * @param filterDensity The density of the color filter.
  81403. * @param saturation The saturation.
  81404. * @param exposure The exposure.
  81405. * @param result The result data container.
  81406. */
  81407. private getColorGradingDataToRef;
  81408. /**
  81409. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81410. * @param value The input slider value in range [-100,100].
  81411. * @returns Adjusted value.
  81412. */
  81413. private static applyColorGradingSliderNonlinear;
  81414. /**
  81415. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81416. * @param hue The hue (H) input.
  81417. * @param saturation The saturation (S) input.
  81418. * @param brightness The brightness (B) input.
  81419. * @result An RGBA color represented as Vector4.
  81420. */
  81421. private static fromHSBToRef;
  81422. /**
  81423. * Returns a value clamped between min and max
  81424. * @param value The value to clamp
  81425. * @param min The minimum of value
  81426. * @param max The maximum of value
  81427. * @returns The clamped value.
  81428. */
  81429. private static clamp;
  81430. /**
  81431. * Clones the current color curve instance.
  81432. * @return The cloned curves
  81433. */
  81434. clone(): ColorCurves;
  81435. /**
  81436. * Serializes the current color curve instance to a json representation.
  81437. * @return a JSON representation
  81438. */
  81439. serialize(): any;
  81440. /**
  81441. * Parses the color curve from a json representation.
  81442. * @param source the JSON source to parse
  81443. * @return The parsed curves
  81444. */
  81445. static Parse(source: any): ColorCurves;
  81446. }
  81447. }
  81448. declare module BABYLON {
  81449. /**
  81450. * Interface to follow in your material defines to integrate easily the
  81451. * Image proccessing functions.
  81452. * @hidden
  81453. */
  81454. export interface IImageProcessingConfigurationDefines {
  81455. IMAGEPROCESSING: boolean;
  81456. VIGNETTE: boolean;
  81457. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81458. VIGNETTEBLENDMODEOPAQUE: boolean;
  81459. TONEMAPPING: boolean;
  81460. TONEMAPPING_ACES: boolean;
  81461. CONTRAST: boolean;
  81462. EXPOSURE: boolean;
  81463. COLORCURVES: boolean;
  81464. COLORGRADING: boolean;
  81465. COLORGRADING3D: boolean;
  81466. SAMPLER3DGREENDEPTH: boolean;
  81467. SAMPLER3DBGRMAP: boolean;
  81468. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81469. }
  81470. /**
  81471. * @hidden
  81472. */
  81473. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81474. IMAGEPROCESSING: boolean;
  81475. VIGNETTE: boolean;
  81476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81477. VIGNETTEBLENDMODEOPAQUE: boolean;
  81478. TONEMAPPING: boolean;
  81479. TONEMAPPING_ACES: boolean;
  81480. CONTRAST: boolean;
  81481. COLORCURVES: boolean;
  81482. COLORGRADING: boolean;
  81483. COLORGRADING3D: boolean;
  81484. SAMPLER3DGREENDEPTH: boolean;
  81485. SAMPLER3DBGRMAP: boolean;
  81486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81487. EXPOSURE: boolean;
  81488. constructor();
  81489. }
  81490. /**
  81491. * This groups together the common properties used for image processing either in direct forward pass
  81492. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81493. * or not.
  81494. */
  81495. export class ImageProcessingConfiguration {
  81496. /**
  81497. * Default tone mapping applied in BabylonJS.
  81498. */
  81499. static readonly TONEMAPPING_STANDARD: number;
  81500. /**
  81501. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81502. * to other engines rendering to increase portability.
  81503. */
  81504. static readonly TONEMAPPING_ACES: number;
  81505. /**
  81506. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81507. */
  81508. colorCurves: Nullable<ColorCurves>;
  81509. private _colorCurvesEnabled;
  81510. /**
  81511. * Gets wether the color curves effect is enabled.
  81512. */
  81513. get colorCurvesEnabled(): boolean;
  81514. /**
  81515. * Sets wether the color curves effect is enabled.
  81516. */
  81517. set colorCurvesEnabled(value: boolean);
  81518. private _colorGradingTexture;
  81519. /**
  81520. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81521. */
  81522. get colorGradingTexture(): Nullable<BaseTexture>;
  81523. /**
  81524. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81525. */
  81526. set colorGradingTexture(value: Nullable<BaseTexture>);
  81527. private _colorGradingEnabled;
  81528. /**
  81529. * Gets wether the color grading effect is enabled.
  81530. */
  81531. get colorGradingEnabled(): boolean;
  81532. /**
  81533. * Sets wether the color grading effect is enabled.
  81534. */
  81535. set colorGradingEnabled(value: boolean);
  81536. private _colorGradingWithGreenDepth;
  81537. /**
  81538. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81539. */
  81540. get colorGradingWithGreenDepth(): boolean;
  81541. /**
  81542. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81543. */
  81544. set colorGradingWithGreenDepth(value: boolean);
  81545. private _colorGradingBGR;
  81546. /**
  81547. * Gets wether the color grading texture contains BGR values.
  81548. */
  81549. get colorGradingBGR(): boolean;
  81550. /**
  81551. * Sets wether the color grading texture contains BGR values.
  81552. */
  81553. set colorGradingBGR(value: boolean);
  81554. /** @hidden */
  81555. _exposure: number;
  81556. /**
  81557. * Gets the Exposure used in the effect.
  81558. */
  81559. get exposure(): number;
  81560. /**
  81561. * Sets the Exposure used in the effect.
  81562. */
  81563. set exposure(value: number);
  81564. private _toneMappingEnabled;
  81565. /**
  81566. * Gets wether the tone mapping effect is enabled.
  81567. */
  81568. get toneMappingEnabled(): boolean;
  81569. /**
  81570. * Sets wether the tone mapping effect is enabled.
  81571. */
  81572. set toneMappingEnabled(value: boolean);
  81573. private _toneMappingType;
  81574. /**
  81575. * Gets the type of tone mapping effect.
  81576. */
  81577. get toneMappingType(): number;
  81578. /**
  81579. * Sets the type of tone mapping effect used in BabylonJS.
  81580. */
  81581. set toneMappingType(value: number);
  81582. protected _contrast: number;
  81583. /**
  81584. * Gets the contrast used in the effect.
  81585. */
  81586. get contrast(): number;
  81587. /**
  81588. * Sets the contrast used in the effect.
  81589. */
  81590. set contrast(value: number);
  81591. /**
  81592. * Vignette stretch size.
  81593. */
  81594. vignetteStretch: number;
  81595. /**
  81596. * Vignette centre X Offset.
  81597. */
  81598. vignetteCentreX: number;
  81599. /**
  81600. * Vignette centre Y Offset.
  81601. */
  81602. vignetteCentreY: number;
  81603. /**
  81604. * Vignette weight or intensity of the vignette effect.
  81605. */
  81606. vignetteWeight: number;
  81607. /**
  81608. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81609. * if vignetteEnabled is set to true.
  81610. */
  81611. vignetteColor: Color4;
  81612. /**
  81613. * Camera field of view used by the Vignette effect.
  81614. */
  81615. vignetteCameraFov: number;
  81616. private _vignetteBlendMode;
  81617. /**
  81618. * Gets the vignette blend mode allowing different kind of effect.
  81619. */
  81620. get vignetteBlendMode(): number;
  81621. /**
  81622. * Sets the vignette blend mode allowing different kind of effect.
  81623. */
  81624. set vignetteBlendMode(value: number);
  81625. private _vignetteEnabled;
  81626. /**
  81627. * Gets wether the vignette effect is enabled.
  81628. */
  81629. get vignetteEnabled(): boolean;
  81630. /**
  81631. * Sets wether the vignette effect is enabled.
  81632. */
  81633. set vignetteEnabled(value: boolean);
  81634. private _applyByPostProcess;
  81635. /**
  81636. * Gets wether the image processing is applied through a post process or not.
  81637. */
  81638. get applyByPostProcess(): boolean;
  81639. /**
  81640. * Sets wether the image processing is applied through a post process or not.
  81641. */
  81642. set applyByPostProcess(value: boolean);
  81643. private _isEnabled;
  81644. /**
  81645. * Gets wether the image processing is enabled or not.
  81646. */
  81647. get isEnabled(): boolean;
  81648. /**
  81649. * Sets wether the image processing is enabled or not.
  81650. */
  81651. set isEnabled(value: boolean);
  81652. /**
  81653. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81654. */
  81655. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81656. /**
  81657. * Method called each time the image processing information changes requires to recompile the effect.
  81658. */
  81659. protected _updateParameters(): void;
  81660. /**
  81661. * Gets the current class name.
  81662. * @return "ImageProcessingConfiguration"
  81663. */
  81664. getClassName(): string;
  81665. /**
  81666. * Prepare the list of uniforms associated with the Image Processing effects.
  81667. * @param uniforms The list of uniforms used in the effect
  81668. * @param defines the list of defines currently in use
  81669. */
  81670. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81671. /**
  81672. * Prepare the list of samplers associated with the Image Processing effects.
  81673. * @param samplersList The list of uniforms used in the effect
  81674. * @param defines the list of defines currently in use
  81675. */
  81676. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81677. /**
  81678. * Prepare the list of defines associated to the shader.
  81679. * @param defines the list of defines to complete
  81680. * @param forPostProcess Define if we are currently in post process mode or not
  81681. */
  81682. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81683. /**
  81684. * Returns true if all the image processing information are ready.
  81685. * @returns True if ready, otherwise, false
  81686. */
  81687. isReady(): boolean;
  81688. /**
  81689. * Binds the image processing to the shader.
  81690. * @param effect The effect to bind to
  81691. * @param overrideAspectRatio Override the aspect ratio of the effect
  81692. */
  81693. bind(effect: Effect, overrideAspectRatio?: number): void;
  81694. /**
  81695. * Clones the current image processing instance.
  81696. * @return The cloned image processing
  81697. */
  81698. clone(): ImageProcessingConfiguration;
  81699. /**
  81700. * Serializes the current image processing instance to a json representation.
  81701. * @return a JSON representation
  81702. */
  81703. serialize(): any;
  81704. /**
  81705. * Parses the image processing from a json representation.
  81706. * @param source the JSON source to parse
  81707. * @return The parsed image processing
  81708. */
  81709. static Parse(source: any): ImageProcessingConfiguration;
  81710. private static _VIGNETTEMODE_MULTIPLY;
  81711. private static _VIGNETTEMODE_OPAQUE;
  81712. /**
  81713. * Used to apply the vignette as a mix with the pixel color.
  81714. */
  81715. static get VIGNETTEMODE_MULTIPLY(): number;
  81716. /**
  81717. * Used to apply the vignette as a replacement of the pixel color.
  81718. */
  81719. static get VIGNETTEMODE_OPAQUE(): number;
  81720. }
  81721. }
  81722. declare module BABYLON {
  81723. /** @hidden */
  81724. export var postprocessVertexShader: {
  81725. name: string;
  81726. shader: string;
  81727. };
  81728. }
  81729. declare module BABYLON {
  81730. interface ThinEngine {
  81731. /**
  81732. * Creates a new render target texture
  81733. * @param size defines the size of the texture
  81734. * @param options defines the options used to create the texture
  81735. * @returns a new render target texture stored in an InternalTexture
  81736. */
  81737. createRenderTargetTexture(size: number | {
  81738. width: number;
  81739. height: number;
  81740. layers?: number;
  81741. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81742. /**
  81743. * Creates a depth stencil texture.
  81744. * This is only available in WebGL 2 or with the depth texture extension available.
  81745. * @param size The size of face edge in the texture.
  81746. * @param options The options defining the texture.
  81747. * @returns The texture
  81748. */
  81749. createDepthStencilTexture(size: number | {
  81750. width: number;
  81751. height: number;
  81752. layers?: number;
  81753. }, options: DepthTextureCreationOptions): InternalTexture;
  81754. /** @hidden */
  81755. _createDepthStencilTexture(size: number | {
  81756. width: number;
  81757. height: number;
  81758. layers?: number;
  81759. }, options: DepthTextureCreationOptions): InternalTexture;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /** Defines supported spaces */
  81764. export enum Space {
  81765. /** Local (object) space */
  81766. LOCAL = 0,
  81767. /** World space */
  81768. WORLD = 1,
  81769. /** Bone space */
  81770. BONE = 2
  81771. }
  81772. /** Defines the 3 main axes */
  81773. export class Axis {
  81774. /** X axis */
  81775. static X: Vector3;
  81776. /** Y axis */
  81777. static Y: Vector3;
  81778. /** Z axis */
  81779. static Z: Vector3;
  81780. }
  81781. }
  81782. declare module BABYLON {
  81783. /**
  81784. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81785. * This is the base of the follow, arc rotate cameras and Free camera
  81786. * @see http://doc.babylonjs.com/features/cameras
  81787. */
  81788. export class TargetCamera extends Camera {
  81789. private static _RigCamTransformMatrix;
  81790. private static _TargetTransformMatrix;
  81791. private static _TargetFocalPoint;
  81792. /**
  81793. * Define the current direction the camera is moving to
  81794. */
  81795. cameraDirection: Vector3;
  81796. /**
  81797. * Define the current rotation the camera is rotating to
  81798. */
  81799. cameraRotation: Vector2;
  81800. /**
  81801. * When set, the up vector of the camera will be updated by the rotation of the camera
  81802. */
  81803. updateUpVectorFromRotation: boolean;
  81804. private _tmpQuaternion;
  81805. /**
  81806. * Define the current rotation of the camera
  81807. */
  81808. rotation: Vector3;
  81809. /**
  81810. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81811. */
  81812. rotationQuaternion: Quaternion;
  81813. /**
  81814. * Define the current speed of the camera
  81815. */
  81816. speed: number;
  81817. /**
  81818. * Add constraint to the camera to prevent it to move freely in all directions and
  81819. * around all axis.
  81820. */
  81821. noRotationConstraint: boolean;
  81822. /**
  81823. * Define the current target of the camera as an object or a position.
  81824. */
  81825. lockedTarget: any;
  81826. /** @hidden */
  81827. _currentTarget: Vector3;
  81828. /** @hidden */
  81829. _initialFocalDistance: number;
  81830. /** @hidden */
  81831. _viewMatrix: Matrix;
  81832. /** @hidden */
  81833. _camMatrix: Matrix;
  81834. /** @hidden */
  81835. _cameraTransformMatrix: Matrix;
  81836. /** @hidden */
  81837. _cameraRotationMatrix: Matrix;
  81838. /** @hidden */
  81839. _referencePoint: Vector3;
  81840. /** @hidden */
  81841. _transformedReferencePoint: Vector3;
  81842. protected _globalCurrentTarget: Vector3;
  81843. protected _globalCurrentUpVector: Vector3;
  81844. /** @hidden */
  81845. _reset: () => void;
  81846. private _defaultUp;
  81847. /**
  81848. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81849. * This is the base of the follow, arc rotate cameras and Free camera
  81850. * @see http://doc.babylonjs.com/features/cameras
  81851. * @param name Defines the name of the camera in the scene
  81852. * @param position Defines the start position of the camera in the scene
  81853. * @param scene Defines the scene the camera belongs to
  81854. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81855. */
  81856. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81857. /**
  81858. * Gets the position in front of the camera at a given distance.
  81859. * @param distance The distance from the camera we want the position to be
  81860. * @returns the position
  81861. */
  81862. getFrontPosition(distance: number): Vector3;
  81863. /** @hidden */
  81864. _getLockedTargetPosition(): Nullable<Vector3>;
  81865. private _storedPosition;
  81866. private _storedRotation;
  81867. private _storedRotationQuaternion;
  81868. /**
  81869. * Store current camera state of the camera (fov, position, rotation, etc..)
  81870. * @returns the camera
  81871. */
  81872. storeState(): Camera;
  81873. /**
  81874. * Restored camera state. You must call storeState() first
  81875. * @returns whether it was successful or not
  81876. * @hidden
  81877. */
  81878. _restoreStateValues(): boolean;
  81879. /** @hidden */
  81880. _initCache(): void;
  81881. /** @hidden */
  81882. _updateCache(ignoreParentClass?: boolean): void;
  81883. /** @hidden */
  81884. _isSynchronizedViewMatrix(): boolean;
  81885. /** @hidden */
  81886. _computeLocalCameraSpeed(): number;
  81887. /**
  81888. * Defines the target the camera should look at.
  81889. * @param target Defines the new target as a Vector or a mesh
  81890. */
  81891. setTarget(target: Vector3): void;
  81892. /**
  81893. * Return the current target position of the camera. This value is expressed in local space.
  81894. * @returns the target position
  81895. */
  81896. getTarget(): Vector3;
  81897. /** @hidden */
  81898. _decideIfNeedsToMove(): boolean;
  81899. /** @hidden */
  81900. _updatePosition(): void;
  81901. /** @hidden */
  81902. _checkInputs(): void;
  81903. protected _updateCameraRotationMatrix(): void;
  81904. /**
  81905. * 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)
  81906. * @returns the current camera
  81907. */
  81908. private _rotateUpVectorWithCameraRotationMatrix;
  81909. private _cachedRotationZ;
  81910. private _cachedQuaternionRotationZ;
  81911. /** @hidden */
  81912. _getViewMatrix(): Matrix;
  81913. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81914. /**
  81915. * @hidden
  81916. */
  81917. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81918. /**
  81919. * @hidden
  81920. */
  81921. _updateRigCameras(): void;
  81922. private _getRigCamPositionAndTarget;
  81923. /**
  81924. * Gets the current object class name.
  81925. * @return the class name
  81926. */
  81927. getClassName(): string;
  81928. }
  81929. }
  81930. declare module BABYLON {
  81931. /**
  81932. * Gather the list of keyboard event types as constants.
  81933. */
  81934. export class KeyboardEventTypes {
  81935. /**
  81936. * The keydown event is fired when a key becomes active (pressed).
  81937. */
  81938. static readonly KEYDOWN: number;
  81939. /**
  81940. * The keyup event is fired when a key has been released.
  81941. */
  81942. static readonly KEYUP: number;
  81943. }
  81944. /**
  81945. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81946. */
  81947. export class KeyboardInfo {
  81948. /**
  81949. * Defines the type of event (KeyboardEventTypes)
  81950. */
  81951. type: number;
  81952. /**
  81953. * Defines the related dom event
  81954. */
  81955. event: KeyboardEvent;
  81956. /**
  81957. * Instantiates a new keyboard info.
  81958. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81959. * @param type Defines the type of event (KeyboardEventTypes)
  81960. * @param event Defines the related dom event
  81961. */
  81962. constructor(
  81963. /**
  81964. * Defines the type of event (KeyboardEventTypes)
  81965. */
  81966. type: number,
  81967. /**
  81968. * Defines the related dom event
  81969. */
  81970. event: KeyboardEvent);
  81971. }
  81972. /**
  81973. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81974. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81975. */
  81976. export class KeyboardInfoPre extends KeyboardInfo {
  81977. /**
  81978. * Defines the type of event (KeyboardEventTypes)
  81979. */
  81980. type: number;
  81981. /**
  81982. * Defines the related dom event
  81983. */
  81984. event: KeyboardEvent;
  81985. /**
  81986. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81987. */
  81988. skipOnPointerObservable: boolean;
  81989. /**
  81990. * Instantiates a new keyboard pre info.
  81991. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81992. * @param type Defines the type of event (KeyboardEventTypes)
  81993. * @param event Defines the related dom event
  81994. */
  81995. constructor(
  81996. /**
  81997. * Defines the type of event (KeyboardEventTypes)
  81998. */
  81999. type: number,
  82000. /**
  82001. * Defines the related dom event
  82002. */
  82003. event: KeyboardEvent);
  82004. }
  82005. }
  82006. declare module BABYLON {
  82007. /**
  82008. * Manage the keyboard inputs to control the movement of a free camera.
  82009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82010. */
  82011. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82012. /**
  82013. * Defines the camera the input is attached to.
  82014. */
  82015. camera: FreeCamera;
  82016. /**
  82017. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82018. */
  82019. keysUp: number[];
  82020. /**
  82021. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82022. */
  82023. keysDown: number[];
  82024. /**
  82025. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82026. */
  82027. keysLeft: number[];
  82028. /**
  82029. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82030. */
  82031. keysRight: number[];
  82032. private _keys;
  82033. private _onCanvasBlurObserver;
  82034. private _onKeyboardObserver;
  82035. private _engine;
  82036. private _scene;
  82037. /**
  82038. * Attach the input controls to a specific dom element to get the input from.
  82039. * @param element Defines the element the controls should be listened from
  82040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82041. */
  82042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82043. /**
  82044. * Detach the current controls from the specified dom element.
  82045. * @param element Defines the element to stop listening the inputs from
  82046. */
  82047. detachControl(element: Nullable<HTMLElement>): void;
  82048. /**
  82049. * Update the current camera state depending on the inputs that have been used this frame.
  82050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82051. */
  82052. checkInputs(): void;
  82053. /**
  82054. * Gets the class name of the current intput.
  82055. * @returns the class name
  82056. */
  82057. getClassName(): string;
  82058. /** @hidden */
  82059. _onLostFocus(): void;
  82060. /**
  82061. * Get the friendly name associated with the input class.
  82062. * @returns the input friendly name
  82063. */
  82064. getSimpleName(): string;
  82065. }
  82066. }
  82067. declare module BABYLON {
  82068. /**
  82069. * Interface describing all the common properties and methods a shadow light needs to implement.
  82070. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82071. * as well as binding the different shadow properties to the effects.
  82072. */
  82073. export interface IShadowLight extends Light {
  82074. /**
  82075. * The light id in the scene (used in scene.findLighById for instance)
  82076. */
  82077. id: string;
  82078. /**
  82079. * The position the shdow will be casted from.
  82080. */
  82081. position: Vector3;
  82082. /**
  82083. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82084. */
  82085. direction: Vector3;
  82086. /**
  82087. * The transformed position. Position of the light in world space taking parenting in account.
  82088. */
  82089. transformedPosition: Vector3;
  82090. /**
  82091. * The transformed direction. Direction of the light in world space taking parenting in account.
  82092. */
  82093. transformedDirection: Vector3;
  82094. /**
  82095. * The friendly name of the light in the scene.
  82096. */
  82097. name: string;
  82098. /**
  82099. * Defines the shadow projection clipping minimum z value.
  82100. */
  82101. shadowMinZ: number;
  82102. /**
  82103. * Defines the shadow projection clipping maximum z value.
  82104. */
  82105. shadowMaxZ: number;
  82106. /**
  82107. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82108. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82109. */
  82110. computeTransformedInformation(): boolean;
  82111. /**
  82112. * Gets the scene the light belongs to.
  82113. * @returns The scene
  82114. */
  82115. getScene(): Scene;
  82116. /**
  82117. * Callback defining a custom Projection Matrix Builder.
  82118. * This can be used to override the default projection matrix computation.
  82119. */
  82120. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82121. /**
  82122. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82123. * @param matrix The materix to updated with the projection information
  82124. * @param viewMatrix The transform matrix of the light
  82125. * @param renderList The list of mesh to render in the map
  82126. * @returns The current light
  82127. */
  82128. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82129. /**
  82130. * Gets the current depth scale used in ESM.
  82131. * @returns The scale
  82132. */
  82133. getDepthScale(): number;
  82134. /**
  82135. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82136. * @returns true if a cube texture needs to be use
  82137. */
  82138. needCube(): boolean;
  82139. /**
  82140. * Detects if the projection matrix requires to be recomputed this frame.
  82141. * @returns true if it requires to be recomputed otherwise, false.
  82142. */
  82143. needProjectionMatrixCompute(): boolean;
  82144. /**
  82145. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82146. */
  82147. forceProjectionMatrixCompute(): void;
  82148. /**
  82149. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82150. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82151. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82152. */
  82153. getShadowDirection(faceIndex?: number): Vector3;
  82154. /**
  82155. * Gets the minZ used for shadow according to both the scene and the light.
  82156. * @param activeCamera The camera we are returning the min for
  82157. * @returns the depth min z
  82158. */
  82159. getDepthMinZ(activeCamera: Camera): number;
  82160. /**
  82161. * Gets the maxZ used for shadow according to both the scene and the light.
  82162. * @param activeCamera The camera we are returning the max for
  82163. * @returns the depth max z
  82164. */
  82165. getDepthMaxZ(activeCamera: Camera): number;
  82166. }
  82167. /**
  82168. * Base implementation IShadowLight
  82169. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82170. */
  82171. export abstract class ShadowLight extends Light implements IShadowLight {
  82172. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82173. protected _position: Vector3;
  82174. protected _setPosition(value: Vector3): void;
  82175. /**
  82176. * Sets the position the shadow will be casted from. Also use as the light position for both
  82177. * point and spot lights.
  82178. */
  82179. get position(): Vector3;
  82180. /**
  82181. * Sets the position the shadow will be casted from. Also use as the light position for both
  82182. * point and spot lights.
  82183. */
  82184. set position(value: Vector3);
  82185. protected _direction: Vector3;
  82186. protected _setDirection(value: Vector3): void;
  82187. /**
  82188. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82189. * Also use as the light direction on spot and directional lights.
  82190. */
  82191. get direction(): Vector3;
  82192. /**
  82193. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82194. * Also use as the light direction on spot and directional lights.
  82195. */
  82196. set direction(value: Vector3);
  82197. protected _shadowMinZ: number;
  82198. /**
  82199. * Gets the shadow projection clipping minimum z value.
  82200. */
  82201. get shadowMinZ(): number;
  82202. /**
  82203. * Sets the shadow projection clipping minimum z value.
  82204. */
  82205. set shadowMinZ(value: number);
  82206. protected _shadowMaxZ: number;
  82207. /**
  82208. * Sets the shadow projection clipping maximum z value.
  82209. */
  82210. get shadowMaxZ(): number;
  82211. /**
  82212. * Gets the shadow projection clipping maximum z value.
  82213. */
  82214. set shadowMaxZ(value: number);
  82215. /**
  82216. * Callback defining a custom Projection Matrix Builder.
  82217. * This can be used to override the default projection matrix computation.
  82218. */
  82219. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82220. /**
  82221. * The transformed position. Position of the light in world space taking parenting in account.
  82222. */
  82223. transformedPosition: Vector3;
  82224. /**
  82225. * The transformed direction. Direction of the light in world space taking parenting in account.
  82226. */
  82227. transformedDirection: Vector3;
  82228. private _needProjectionMatrixCompute;
  82229. /**
  82230. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82231. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82232. */
  82233. computeTransformedInformation(): boolean;
  82234. /**
  82235. * Return the depth scale used for the shadow map.
  82236. * @returns the depth scale.
  82237. */
  82238. getDepthScale(): number;
  82239. /**
  82240. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82241. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82242. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82243. */
  82244. getShadowDirection(faceIndex?: number): Vector3;
  82245. /**
  82246. * Returns the ShadowLight absolute position in the World.
  82247. * @returns the position vector in world space
  82248. */
  82249. getAbsolutePosition(): Vector3;
  82250. /**
  82251. * Sets the ShadowLight direction toward the passed target.
  82252. * @param target The point to target in local space
  82253. * @returns the updated ShadowLight direction
  82254. */
  82255. setDirectionToTarget(target: Vector3): Vector3;
  82256. /**
  82257. * Returns the light rotation in euler definition.
  82258. * @returns the x y z rotation in local space.
  82259. */
  82260. getRotation(): Vector3;
  82261. /**
  82262. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82263. * @returns true if a cube texture needs to be use
  82264. */
  82265. needCube(): boolean;
  82266. /**
  82267. * Detects if the projection matrix requires to be recomputed this frame.
  82268. * @returns true if it requires to be recomputed otherwise, false.
  82269. */
  82270. needProjectionMatrixCompute(): boolean;
  82271. /**
  82272. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82273. */
  82274. forceProjectionMatrixCompute(): void;
  82275. /** @hidden */
  82276. _initCache(): void;
  82277. /** @hidden */
  82278. _isSynchronized(): boolean;
  82279. /**
  82280. * Computes the world matrix of the node
  82281. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82282. * @returns the world matrix
  82283. */
  82284. computeWorldMatrix(force?: boolean): Matrix;
  82285. /**
  82286. * Gets the minZ used for shadow according to both the scene and the light.
  82287. * @param activeCamera The camera we are returning the min for
  82288. * @returns the depth min z
  82289. */
  82290. getDepthMinZ(activeCamera: Camera): number;
  82291. /**
  82292. * Gets the maxZ used for shadow according to both the scene and the light.
  82293. * @param activeCamera The camera we are returning the max for
  82294. * @returns the depth max z
  82295. */
  82296. getDepthMaxZ(activeCamera: Camera): number;
  82297. /**
  82298. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82299. * @param matrix The materix to updated with the projection information
  82300. * @param viewMatrix The transform matrix of the light
  82301. * @param renderList The list of mesh to render in the map
  82302. * @returns The current light
  82303. */
  82304. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82305. }
  82306. }
  82307. declare module BABYLON {
  82308. /**
  82309. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82310. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82311. */
  82312. export class EffectFallbacks implements IEffectFallbacks {
  82313. private _defines;
  82314. private _currentRank;
  82315. private _maxRank;
  82316. private _mesh;
  82317. /**
  82318. * Removes the fallback from the bound mesh.
  82319. */
  82320. unBindMesh(): void;
  82321. /**
  82322. * Adds a fallback on the specified property.
  82323. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82324. * @param define The name of the define in the shader
  82325. */
  82326. addFallback(rank: number, define: string): void;
  82327. /**
  82328. * Sets the mesh to use CPU skinning when needing to fallback.
  82329. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82330. * @param mesh The mesh to use the fallbacks.
  82331. */
  82332. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82333. /**
  82334. * Checks to see if more fallbacks are still availible.
  82335. */
  82336. get hasMoreFallbacks(): boolean;
  82337. /**
  82338. * Removes the defines that should be removed when falling back.
  82339. * @param currentDefines defines the current define statements for the shader.
  82340. * @param effect defines the current effect we try to compile
  82341. * @returns The resulting defines with defines of the current rank removed.
  82342. */
  82343. reduce(currentDefines: string, effect: Effect): string;
  82344. }
  82345. }
  82346. declare module BABYLON {
  82347. /**
  82348. * "Static Class" containing the most commonly used helper while dealing with material for
  82349. * rendering purpose.
  82350. *
  82351. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82352. *
  82353. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82354. */
  82355. export class MaterialHelper {
  82356. /**
  82357. * Bind the current view position to an effect.
  82358. * @param effect The effect to be bound
  82359. * @param scene The scene the eyes position is used from
  82360. */
  82361. static BindEyePosition(effect: Effect, scene: Scene): void;
  82362. /**
  82363. * Helps preparing the defines values about the UVs in used in the effect.
  82364. * UVs are shared as much as we can accross channels in the shaders.
  82365. * @param texture The texture we are preparing the UVs for
  82366. * @param defines The defines to update
  82367. * @param key The channel key "diffuse", "specular"... used in the shader
  82368. */
  82369. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82370. /**
  82371. * Binds a texture matrix value to its corrsponding uniform
  82372. * @param texture The texture to bind the matrix for
  82373. * @param uniformBuffer The uniform buffer receivin the data
  82374. * @param key The channel key "diffuse", "specular"... used in the shader
  82375. */
  82376. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82377. /**
  82378. * Gets the current status of the fog (should it be enabled?)
  82379. * @param mesh defines the mesh to evaluate for fog support
  82380. * @param scene defines the hosting scene
  82381. * @returns true if fog must be enabled
  82382. */
  82383. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82384. /**
  82385. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82386. * @param mesh defines the current mesh
  82387. * @param scene defines the current scene
  82388. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82389. * @param pointsCloud defines if point cloud rendering has to be turned on
  82390. * @param fogEnabled defines if fog has to be turned on
  82391. * @param alphaTest defines if alpha testing has to be turned on
  82392. * @param defines defines the current list of defines
  82393. */
  82394. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82395. /**
  82396. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82397. * @param scene defines the current scene
  82398. * @param engine defines the current engine
  82399. * @param defines specifies the list of active defines
  82400. * @param useInstances defines if instances have to be turned on
  82401. * @param useClipPlane defines if clip plane have to be turned on
  82402. */
  82403. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82404. /**
  82405. * Prepares the defines for bones
  82406. * @param mesh The mesh containing the geometry data we will draw
  82407. * @param defines The defines to update
  82408. */
  82409. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82410. /**
  82411. * Prepares the defines for morph targets
  82412. * @param mesh The mesh containing the geometry data we will draw
  82413. * @param defines The defines to update
  82414. */
  82415. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82416. /**
  82417. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82418. * @param mesh The mesh containing the geometry data we will draw
  82419. * @param defines The defines to update
  82420. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82421. * @param useBones Precise whether bones should be used or not (override mesh info)
  82422. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82423. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82424. * @returns false if defines are considered not dirty and have not been checked
  82425. */
  82426. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82427. /**
  82428. * Prepares the defines related to multiview
  82429. * @param scene The scene we are intending to draw
  82430. * @param defines The defines to update
  82431. */
  82432. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82433. /**
  82434. * Prepares the defines related to the light information passed in parameter
  82435. * @param scene The scene we are intending to draw
  82436. * @param mesh The mesh the effect is compiling for
  82437. * @param light The light the effect is compiling for
  82438. * @param lightIndex The index of the light
  82439. * @param defines The defines to update
  82440. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82441. * @param state Defines the current state regarding what is needed (normals, etc...)
  82442. */
  82443. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82444. needNormals: boolean;
  82445. needRebuild: boolean;
  82446. shadowEnabled: boolean;
  82447. specularEnabled: boolean;
  82448. lightmapMode: boolean;
  82449. }): void;
  82450. /**
  82451. * Prepares the defines related to the light information passed in parameter
  82452. * @param scene The scene we are intending to draw
  82453. * @param mesh The mesh the effect is compiling for
  82454. * @param defines The defines to update
  82455. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82456. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82457. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82458. * @returns true if normals will be required for the rest of the effect
  82459. */
  82460. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82461. /**
  82462. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82463. * @param lightIndex defines the light index
  82464. * @param uniformsList The uniform list
  82465. * @param samplersList The sampler list
  82466. * @param projectedLightTexture defines if projected texture must be used
  82467. * @param uniformBuffersList defines an optional list of uniform buffers
  82468. */
  82469. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82470. /**
  82471. * Prepares the uniforms and samplers list to be used in the effect
  82472. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82473. * @param samplersList The sampler list
  82474. * @param defines The defines helping in the list generation
  82475. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82476. */
  82477. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82478. /**
  82479. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82480. * @param defines The defines to update while falling back
  82481. * @param fallbacks The authorized effect fallbacks
  82482. * @param maxSimultaneousLights The maximum number of lights allowed
  82483. * @param rank the current rank of the Effect
  82484. * @returns The newly affected rank
  82485. */
  82486. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82487. private static _TmpMorphInfluencers;
  82488. /**
  82489. * Prepares the list of attributes required for morph targets according to the effect defines.
  82490. * @param attribs The current list of supported attribs
  82491. * @param mesh The mesh to prepare the morph targets attributes for
  82492. * @param influencers The number of influencers
  82493. */
  82494. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82495. /**
  82496. * Prepares the list of attributes required for morph targets according to the effect defines.
  82497. * @param attribs The current list of supported attribs
  82498. * @param mesh The mesh to prepare the morph targets attributes for
  82499. * @param defines The current Defines of the effect
  82500. */
  82501. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82502. /**
  82503. * Prepares the list of attributes required for bones according to the effect defines.
  82504. * @param attribs The current list of supported attribs
  82505. * @param mesh The mesh to prepare the bones attributes for
  82506. * @param defines The current Defines of the effect
  82507. * @param fallbacks The current efffect fallback strategy
  82508. */
  82509. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82510. /**
  82511. * Check and prepare the list of attributes required for instances according to the effect defines.
  82512. * @param attribs The current list of supported attribs
  82513. * @param defines The current MaterialDefines of the effect
  82514. */
  82515. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82516. /**
  82517. * Add the list of attributes required for instances to the attribs array.
  82518. * @param attribs The current list of supported attribs
  82519. */
  82520. static PushAttributesForInstances(attribs: string[]): void;
  82521. /**
  82522. * Binds the light information to the effect.
  82523. * @param light The light containing the generator
  82524. * @param effect The effect we are binding the data to
  82525. * @param lightIndex The light index in the effect used to render
  82526. */
  82527. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82528. /**
  82529. * Binds the lights information from the scene to the effect for the given mesh.
  82530. * @param light Light to bind
  82531. * @param lightIndex Light index
  82532. * @param scene The scene where the light belongs to
  82533. * @param effect The effect we are binding the data to
  82534. * @param useSpecular Defines if specular is supported
  82535. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82536. */
  82537. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82538. /**
  82539. * Binds the lights information from the scene to the effect for the given mesh.
  82540. * @param scene The scene the lights belongs to
  82541. * @param mesh The mesh we are binding the information to render
  82542. * @param effect The effect we are binding the data to
  82543. * @param defines The generated defines for the effect
  82544. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82545. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82546. */
  82547. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82548. private static _tempFogColor;
  82549. /**
  82550. * Binds the fog information from the scene to the effect for the given mesh.
  82551. * @param scene The scene the lights belongs to
  82552. * @param mesh The mesh we are binding the information to render
  82553. * @param effect The effect we are binding the data to
  82554. * @param linearSpace Defines if the fog effect is applied in linear space
  82555. */
  82556. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82557. /**
  82558. * Binds the bones information from the mesh to the effect.
  82559. * @param mesh The mesh we are binding the information to render
  82560. * @param effect The effect we are binding the data to
  82561. */
  82562. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82563. /**
  82564. * Binds the morph targets information from the mesh to the effect.
  82565. * @param abstractMesh The mesh we are binding the information to render
  82566. * @param effect The effect we are binding the data to
  82567. */
  82568. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82569. /**
  82570. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82571. * @param defines The generated defines used in the effect
  82572. * @param effect The effect we are binding the data to
  82573. * @param scene The scene we are willing to render with logarithmic scale for
  82574. */
  82575. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82576. /**
  82577. * Binds the clip plane information from the scene to the effect.
  82578. * @param scene The scene the clip plane information are extracted from
  82579. * @param effect The effect we are binding the data to
  82580. */
  82581. static BindClipPlane(effect: Effect, scene: Scene): void;
  82582. }
  82583. }
  82584. declare module BABYLON {
  82585. /** @hidden */
  82586. export var packingFunctions: {
  82587. name: string;
  82588. shader: string;
  82589. };
  82590. }
  82591. declare module BABYLON {
  82592. /** @hidden */
  82593. export var clipPlaneFragmentDeclaration: {
  82594. name: string;
  82595. shader: string;
  82596. };
  82597. }
  82598. declare module BABYLON {
  82599. /** @hidden */
  82600. export var clipPlaneFragment: {
  82601. name: string;
  82602. shader: string;
  82603. };
  82604. }
  82605. declare module BABYLON {
  82606. /** @hidden */
  82607. export var shadowMapPixelShader: {
  82608. name: string;
  82609. shader: string;
  82610. };
  82611. }
  82612. declare module BABYLON {
  82613. /** @hidden */
  82614. export var bonesDeclaration: {
  82615. name: string;
  82616. shader: string;
  82617. };
  82618. }
  82619. declare module BABYLON {
  82620. /** @hidden */
  82621. export var morphTargetsVertexGlobalDeclaration: {
  82622. name: string;
  82623. shader: string;
  82624. };
  82625. }
  82626. declare module BABYLON {
  82627. /** @hidden */
  82628. export var morphTargetsVertexDeclaration: {
  82629. name: string;
  82630. shader: string;
  82631. };
  82632. }
  82633. declare module BABYLON {
  82634. /** @hidden */
  82635. export var instancesDeclaration: {
  82636. name: string;
  82637. shader: string;
  82638. };
  82639. }
  82640. declare module BABYLON {
  82641. /** @hidden */
  82642. export var helperFunctions: {
  82643. name: string;
  82644. shader: string;
  82645. };
  82646. }
  82647. declare module BABYLON {
  82648. /** @hidden */
  82649. export var clipPlaneVertexDeclaration: {
  82650. name: string;
  82651. shader: string;
  82652. };
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var morphTargetsVertex: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. /** @hidden */
  82663. export var instancesVertex: {
  82664. name: string;
  82665. shader: string;
  82666. };
  82667. }
  82668. declare module BABYLON {
  82669. /** @hidden */
  82670. export var bonesVertex: {
  82671. name: string;
  82672. shader: string;
  82673. };
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export var clipPlaneVertex: {
  82678. name: string;
  82679. shader: string;
  82680. };
  82681. }
  82682. declare module BABYLON {
  82683. /** @hidden */
  82684. export var shadowMapVertexShader: {
  82685. name: string;
  82686. shader: string;
  82687. };
  82688. }
  82689. declare module BABYLON {
  82690. /** @hidden */
  82691. export var depthBoxBlurPixelShader: {
  82692. name: string;
  82693. shader: string;
  82694. };
  82695. }
  82696. declare module BABYLON {
  82697. /**
  82698. * Class representing a ray with position and direction
  82699. */
  82700. export class Ray {
  82701. /** origin point */
  82702. origin: Vector3;
  82703. /** direction */
  82704. direction: Vector3;
  82705. /** length of the ray */
  82706. length: number;
  82707. private static readonly TmpVector3;
  82708. private _tmpRay;
  82709. /**
  82710. * Creates a new ray
  82711. * @param origin origin point
  82712. * @param direction direction
  82713. * @param length length of the ray
  82714. */
  82715. constructor(
  82716. /** origin point */
  82717. origin: Vector3,
  82718. /** direction */
  82719. direction: Vector3,
  82720. /** length of the ray */
  82721. length?: number);
  82722. /**
  82723. * Checks if the ray intersects a box
  82724. * @param minimum bound of the box
  82725. * @param maximum bound of the box
  82726. * @param intersectionTreshold extra extend to be added to the box in all direction
  82727. * @returns if the box was hit
  82728. */
  82729. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82730. /**
  82731. * Checks if the ray intersects a box
  82732. * @param box the bounding box to check
  82733. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82734. * @returns if the box was hit
  82735. */
  82736. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82737. /**
  82738. * If the ray hits a sphere
  82739. * @param sphere the bounding sphere to check
  82740. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82741. * @returns true if it hits the sphere
  82742. */
  82743. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82744. /**
  82745. * If the ray hits a triange
  82746. * @param vertex0 triangle vertex
  82747. * @param vertex1 triangle vertex
  82748. * @param vertex2 triangle vertex
  82749. * @returns intersection information if hit
  82750. */
  82751. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82752. /**
  82753. * Checks if ray intersects a plane
  82754. * @param plane the plane to check
  82755. * @returns the distance away it was hit
  82756. */
  82757. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82758. /**
  82759. * Calculate the intercept of a ray on a given axis
  82760. * @param axis to check 'x' | 'y' | 'z'
  82761. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82762. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82763. */
  82764. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82765. /**
  82766. * Checks if ray intersects a mesh
  82767. * @param mesh the mesh to check
  82768. * @param fastCheck if only the bounding box should checked
  82769. * @returns picking info of the intersecton
  82770. */
  82771. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82772. /**
  82773. * Checks if ray intersects a mesh
  82774. * @param meshes the meshes to check
  82775. * @param fastCheck if only the bounding box should checked
  82776. * @param results array to store result in
  82777. * @returns Array of picking infos
  82778. */
  82779. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82780. private _comparePickingInfo;
  82781. private static smallnum;
  82782. private static rayl;
  82783. /**
  82784. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82785. * @param sega the first point of the segment to test the intersection against
  82786. * @param segb the second point of the segment to test the intersection against
  82787. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82788. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82789. */
  82790. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82791. /**
  82792. * Update the ray from viewport position
  82793. * @param x position
  82794. * @param y y position
  82795. * @param viewportWidth viewport width
  82796. * @param viewportHeight viewport height
  82797. * @param world world matrix
  82798. * @param view view matrix
  82799. * @param projection projection matrix
  82800. * @returns this ray updated
  82801. */
  82802. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82803. /**
  82804. * Creates a ray with origin and direction of 0,0,0
  82805. * @returns the new ray
  82806. */
  82807. static Zero(): Ray;
  82808. /**
  82809. * Creates a new ray from screen space and viewport
  82810. * @param x position
  82811. * @param y y position
  82812. * @param viewportWidth viewport width
  82813. * @param viewportHeight viewport height
  82814. * @param world world matrix
  82815. * @param view view matrix
  82816. * @param projection projection matrix
  82817. * @returns new ray
  82818. */
  82819. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82820. /**
  82821. * 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
  82822. * transformed to the given world matrix.
  82823. * @param origin The origin point
  82824. * @param end The end point
  82825. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82826. * @returns the new ray
  82827. */
  82828. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82829. /**
  82830. * Transforms a ray by a matrix
  82831. * @param ray ray to transform
  82832. * @param matrix matrix to apply
  82833. * @returns the resulting new ray
  82834. */
  82835. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82836. /**
  82837. * Transforms a ray by a matrix
  82838. * @param ray ray to transform
  82839. * @param matrix matrix to apply
  82840. * @param result ray to store result in
  82841. */
  82842. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82843. /**
  82844. * Unproject a ray from screen space to object space
  82845. * @param sourceX defines the screen space x coordinate to use
  82846. * @param sourceY defines the screen space y coordinate to use
  82847. * @param viewportWidth defines the current width of the viewport
  82848. * @param viewportHeight defines the current height of the viewport
  82849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82850. * @param view defines the view matrix to use
  82851. * @param projection defines the projection matrix to use
  82852. */
  82853. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82854. }
  82855. /**
  82856. * Type used to define predicate used to select faces when a mesh intersection is detected
  82857. */
  82858. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82859. interface Scene {
  82860. /** @hidden */
  82861. _tempPickingRay: Nullable<Ray>;
  82862. /** @hidden */
  82863. _cachedRayForTransform: Ray;
  82864. /** @hidden */
  82865. _pickWithRayInverseMatrix: Matrix;
  82866. /** @hidden */
  82867. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82868. /** @hidden */
  82869. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82870. }
  82871. }
  82872. declare module BABYLON {
  82873. /**
  82874. * Groups all the scene component constants in one place to ease maintenance.
  82875. * @hidden
  82876. */
  82877. export class SceneComponentConstants {
  82878. static readonly NAME_EFFECTLAYER: string;
  82879. static readonly NAME_LAYER: string;
  82880. static readonly NAME_LENSFLARESYSTEM: string;
  82881. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82882. static readonly NAME_PARTICLESYSTEM: string;
  82883. static readonly NAME_GAMEPAD: string;
  82884. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82885. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82886. static readonly NAME_DEPTHRENDERER: string;
  82887. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82888. static readonly NAME_SPRITE: string;
  82889. static readonly NAME_OUTLINERENDERER: string;
  82890. static readonly NAME_PROCEDURALTEXTURE: string;
  82891. static readonly NAME_SHADOWGENERATOR: string;
  82892. static readonly NAME_OCTREE: string;
  82893. static readonly NAME_PHYSICSENGINE: string;
  82894. static readonly NAME_AUDIO: string;
  82895. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82896. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82897. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82898. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82899. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82900. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82901. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82902. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82903. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82904. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82905. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82906. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82907. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82908. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82909. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82910. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82911. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82912. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82913. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82914. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82915. static readonly STEP_AFTERRENDER_AUDIO: number;
  82916. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82917. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82918. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82919. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82920. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82921. static readonly STEP_POINTERMOVE_SPRITE: number;
  82922. static readonly STEP_POINTERDOWN_SPRITE: number;
  82923. static readonly STEP_POINTERUP_SPRITE: number;
  82924. }
  82925. /**
  82926. * This represents a scene component.
  82927. *
  82928. * This is used to decouple the dependency the scene is having on the different workloads like
  82929. * layers, post processes...
  82930. */
  82931. export interface ISceneComponent {
  82932. /**
  82933. * The name of the component. Each component must have a unique name.
  82934. */
  82935. name: string;
  82936. /**
  82937. * The scene the component belongs to.
  82938. */
  82939. scene: Scene;
  82940. /**
  82941. * Register the component to one instance of a scene.
  82942. */
  82943. register(): void;
  82944. /**
  82945. * Rebuilds the elements related to this component in case of
  82946. * context lost for instance.
  82947. */
  82948. rebuild(): void;
  82949. /**
  82950. * Disposes the component and the associated ressources.
  82951. */
  82952. dispose(): void;
  82953. }
  82954. /**
  82955. * This represents a SERIALIZABLE scene component.
  82956. *
  82957. * This extends Scene Component to add Serialization methods on top.
  82958. */
  82959. export interface ISceneSerializableComponent extends ISceneComponent {
  82960. /**
  82961. * Adds all the elements from the container to the scene
  82962. * @param container the container holding the elements
  82963. */
  82964. addFromContainer(container: AbstractScene): void;
  82965. /**
  82966. * Removes all the elements in the container from the scene
  82967. * @param container contains the elements to remove
  82968. * @param dispose if the removed element should be disposed (default: false)
  82969. */
  82970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82971. /**
  82972. * Serializes the component data to the specified json object
  82973. * @param serializationObject The object to serialize to
  82974. */
  82975. serialize(serializationObject: any): void;
  82976. }
  82977. /**
  82978. * Strong typing of a Mesh related stage step action
  82979. */
  82980. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82981. /**
  82982. * Strong typing of a Evaluate Sub Mesh related stage step action
  82983. */
  82984. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82985. /**
  82986. * Strong typing of a Active Mesh related stage step action
  82987. */
  82988. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82989. /**
  82990. * Strong typing of a Camera related stage step action
  82991. */
  82992. export type CameraStageAction = (camera: Camera) => void;
  82993. /**
  82994. * Strong typing of a Camera Frame buffer related stage step action
  82995. */
  82996. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82997. /**
  82998. * Strong typing of a Render Target related stage step action
  82999. */
  83000. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83001. /**
  83002. * Strong typing of a RenderingGroup related stage step action
  83003. */
  83004. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83005. /**
  83006. * Strong typing of a Mesh Render related stage step action
  83007. */
  83008. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83009. /**
  83010. * Strong typing of a simple stage step action
  83011. */
  83012. export type SimpleStageAction = () => void;
  83013. /**
  83014. * Strong typing of a render target action.
  83015. */
  83016. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83017. /**
  83018. * Strong typing of a pointer move action.
  83019. */
  83020. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83021. /**
  83022. * Strong typing of a pointer up/down action.
  83023. */
  83024. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83025. /**
  83026. * Representation of a stage in the scene (Basically a list of ordered steps)
  83027. * @hidden
  83028. */
  83029. export class Stage<T extends Function> extends Array<{
  83030. index: number;
  83031. component: ISceneComponent;
  83032. action: T;
  83033. }> {
  83034. /**
  83035. * Hide ctor from the rest of the world.
  83036. * @param items The items to add.
  83037. */
  83038. private constructor();
  83039. /**
  83040. * Creates a new Stage.
  83041. * @returns A new instance of a Stage
  83042. */
  83043. static Create<T extends Function>(): Stage<T>;
  83044. /**
  83045. * Registers a step in an ordered way in the targeted stage.
  83046. * @param index Defines the position to register the step in
  83047. * @param component Defines the component attached to the step
  83048. * @param action Defines the action to launch during the step
  83049. */
  83050. registerStep(index: number, component: ISceneComponent, action: T): void;
  83051. /**
  83052. * Clears all the steps from the stage.
  83053. */
  83054. clear(): void;
  83055. }
  83056. }
  83057. declare module BABYLON {
  83058. interface Scene {
  83059. /** @hidden */
  83060. _pointerOverSprite: Nullable<Sprite>;
  83061. /** @hidden */
  83062. _pickedDownSprite: Nullable<Sprite>;
  83063. /** @hidden */
  83064. _tempSpritePickingRay: Nullable<Ray>;
  83065. /**
  83066. * All of the sprite managers added to this scene
  83067. * @see http://doc.babylonjs.com/babylon101/sprites
  83068. */
  83069. spriteManagers: Array<ISpriteManager>;
  83070. /**
  83071. * An event triggered when sprites rendering is about to start
  83072. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83073. */
  83074. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83075. /**
  83076. * An event triggered when sprites rendering is done
  83077. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83078. */
  83079. onAfterSpritesRenderingObservable: Observable<Scene>;
  83080. /** @hidden */
  83081. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83082. /** Launch a ray to try to pick a sprite in the scene
  83083. * @param x position on screen
  83084. * @param y position on screen
  83085. * @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
  83086. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83087. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83088. * @returns a PickingInfo
  83089. */
  83090. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83091. /** Use the given ray to pick a sprite in the scene
  83092. * @param ray The ray (in world space) to use to pick meshes
  83093. * @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
  83094. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83095. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83096. * @returns a PickingInfo
  83097. */
  83098. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83099. /** @hidden */
  83100. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83101. /** Launch a ray to try to pick sprites in the scene
  83102. * @param x position on screen
  83103. * @param y position on screen
  83104. * @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
  83105. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83106. * @returns a PickingInfo array
  83107. */
  83108. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83109. /** Use the given ray to pick sprites in the scene
  83110. * @param ray The ray (in world space) to use to pick meshes
  83111. * @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
  83112. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83113. * @returns a PickingInfo array
  83114. */
  83115. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83116. /**
  83117. * Force the sprite under the pointer
  83118. * @param sprite defines the sprite to use
  83119. */
  83120. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83121. /**
  83122. * Gets the sprite under the pointer
  83123. * @returns a Sprite or null if no sprite is under the pointer
  83124. */
  83125. getPointerOverSprite(): Nullable<Sprite>;
  83126. }
  83127. /**
  83128. * Defines the sprite scene component responsible to manage sprites
  83129. * in a given scene.
  83130. */
  83131. export class SpriteSceneComponent implements ISceneComponent {
  83132. /**
  83133. * The component name helpfull to identify the component in the list of scene components.
  83134. */
  83135. readonly name: string;
  83136. /**
  83137. * The scene the component belongs to.
  83138. */
  83139. scene: Scene;
  83140. /** @hidden */
  83141. private _spritePredicate;
  83142. /**
  83143. * Creates a new instance of the component for the given scene
  83144. * @param scene Defines the scene to register the component in
  83145. */
  83146. constructor(scene: Scene);
  83147. /**
  83148. * Registers the component in a given scene
  83149. */
  83150. register(): void;
  83151. /**
  83152. * Rebuilds the elements related to this component in case of
  83153. * context lost for instance.
  83154. */
  83155. rebuild(): void;
  83156. /**
  83157. * Disposes the component and the associated ressources.
  83158. */
  83159. dispose(): void;
  83160. private _pickSpriteButKeepRay;
  83161. private _pointerMove;
  83162. private _pointerDown;
  83163. private _pointerUp;
  83164. }
  83165. }
  83166. declare module BABYLON {
  83167. /** @hidden */
  83168. export var fogFragmentDeclaration: {
  83169. name: string;
  83170. shader: string;
  83171. };
  83172. }
  83173. declare module BABYLON {
  83174. /** @hidden */
  83175. export var fogFragment: {
  83176. name: string;
  83177. shader: string;
  83178. };
  83179. }
  83180. declare module BABYLON {
  83181. /** @hidden */
  83182. export var spritesPixelShader: {
  83183. name: string;
  83184. shader: string;
  83185. };
  83186. }
  83187. declare module BABYLON {
  83188. /** @hidden */
  83189. export var fogVertexDeclaration: {
  83190. name: string;
  83191. shader: string;
  83192. };
  83193. }
  83194. declare module BABYLON {
  83195. /** @hidden */
  83196. export var spritesVertexShader: {
  83197. name: string;
  83198. shader: string;
  83199. };
  83200. }
  83201. declare module BABYLON {
  83202. /**
  83203. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83204. */
  83205. export interface ISpriteManager extends IDisposable {
  83206. /**
  83207. * Restricts the camera to viewing objects with the same layerMask.
  83208. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83209. */
  83210. layerMask: number;
  83211. /**
  83212. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83213. */
  83214. isPickable: boolean;
  83215. /**
  83216. * Specifies the rendering group id for this mesh (0 by default)
  83217. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83218. */
  83219. renderingGroupId: number;
  83220. /**
  83221. * Defines the list of sprites managed by the manager.
  83222. */
  83223. sprites: Array<Sprite>;
  83224. /**
  83225. * Tests the intersection of a sprite with a specific ray.
  83226. * @param ray The ray we are sending to test the collision
  83227. * @param camera The camera space we are sending rays in
  83228. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83229. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83230. * @returns picking info or null.
  83231. */
  83232. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83233. /**
  83234. * Intersects the sprites with a ray
  83235. * @param ray defines the ray to intersect with
  83236. * @param camera defines the current active camera
  83237. * @param predicate defines a predicate used to select candidate sprites
  83238. * @returns null if no hit or a PickingInfo array
  83239. */
  83240. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83241. /**
  83242. * Renders the list of sprites on screen.
  83243. */
  83244. render(): void;
  83245. }
  83246. /**
  83247. * Class used to manage multiple sprites on the same spritesheet
  83248. * @see http://doc.babylonjs.com/babylon101/sprites
  83249. */
  83250. export class SpriteManager implements ISpriteManager {
  83251. /** defines the manager's name */
  83252. name: string;
  83253. /** Gets the list of sprites */
  83254. sprites: Sprite[];
  83255. /** Gets or sets the rendering group id (0 by default) */
  83256. renderingGroupId: number;
  83257. /** Gets or sets camera layer mask */
  83258. layerMask: number;
  83259. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83260. fogEnabled: boolean;
  83261. /** Gets or sets a boolean indicating if the sprites are pickable */
  83262. isPickable: boolean;
  83263. /** Defines the default width of a cell in the spritesheet */
  83264. cellWidth: number;
  83265. /** Defines the default height of a cell in the spritesheet */
  83266. cellHeight: number;
  83267. /** Associative array from JSON sprite data file */
  83268. private _cellData;
  83269. /** Array of sprite names from JSON sprite data file */
  83270. private _spriteMap;
  83271. /** True when packed cell data from JSON file is ready*/
  83272. private _packedAndReady;
  83273. /**
  83274. * An event triggered when the manager is disposed.
  83275. */
  83276. onDisposeObservable: Observable<SpriteManager>;
  83277. private _onDisposeObserver;
  83278. /**
  83279. * Callback called when the manager is disposed
  83280. */
  83281. set onDispose(callback: () => void);
  83282. private _capacity;
  83283. private _fromPacked;
  83284. private _spriteTexture;
  83285. private _epsilon;
  83286. private _scene;
  83287. private _vertexData;
  83288. private _buffer;
  83289. private _vertexBuffers;
  83290. private _indexBuffer;
  83291. private _effectBase;
  83292. private _effectFog;
  83293. /**
  83294. * Gets or sets the spritesheet texture
  83295. */
  83296. get texture(): Texture;
  83297. set texture(value: Texture);
  83298. /**
  83299. * Creates a new sprite manager
  83300. * @param name defines the manager's name
  83301. * @param imgUrl defines the sprite sheet url
  83302. * @param capacity defines the maximum allowed number of sprites
  83303. * @param cellSize defines the size of a sprite cell
  83304. * @param scene defines the hosting scene
  83305. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83306. * @param samplingMode defines the smapling mode to use with spritesheet
  83307. * @param fromPacked set to false; do not alter
  83308. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83309. */
  83310. constructor(
  83311. /** defines the manager's name */
  83312. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83313. private _makePacked;
  83314. private _appendSpriteVertex;
  83315. /**
  83316. * Intersects the sprites with a ray
  83317. * @param ray defines the ray to intersect with
  83318. * @param camera defines the current active camera
  83319. * @param predicate defines a predicate used to select candidate sprites
  83320. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83321. * @returns null if no hit or a PickingInfo
  83322. */
  83323. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83324. /**
  83325. * Intersects the sprites with a ray
  83326. * @param ray defines the ray to intersect with
  83327. * @param camera defines the current active camera
  83328. * @param predicate defines a predicate used to select candidate sprites
  83329. * @returns null if no hit or a PickingInfo array
  83330. */
  83331. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83332. /**
  83333. * Render all child sprites
  83334. */
  83335. render(): void;
  83336. /**
  83337. * Release associated resources
  83338. */
  83339. dispose(): void;
  83340. }
  83341. }
  83342. declare module BABYLON {
  83343. /** Interface used by value gradients (color, factor, ...) */
  83344. export interface IValueGradient {
  83345. /**
  83346. * Gets or sets the gradient value (between 0 and 1)
  83347. */
  83348. gradient: number;
  83349. }
  83350. /** Class used to store color4 gradient */
  83351. export class ColorGradient implements IValueGradient {
  83352. /**
  83353. * Gets or sets the gradient value (between 0 and 1)
  83354. */
  83355. gradient: number;
  83356. /**
  83357. * Gets or sets first associated color
  83358. */
  83359. color1: Color4;
  83360. /**
  83361. * Gets or sets second associated color
  83362. */
  83363. color2?: Color4;
  83364. /**
  83365. * Will get a color picked randomly between color1 and color2.
  83366. * If color2 is undefined then color1 will be used
  83367. * @param result defines the target Color4 to store the result in
  83368. */
  83369. getColorToRef(result: Color4): void;
  83370. }
  83371. /** Class used to store color 3 gradient */
  83372. export class Color3Gradient implements IValueGradient {
  83373. /**
  83374. * Gets or sets the gradient value (between 0 and 1)
  83375. */
  83376. gradient: number;
  83377. /**
  83378. * Gets or sets the associated color
  83379. */
  83380. color: Color3;
  83381. }
  83382. /** Class used to store factor gradient */
  83383. export class FactorGradient implements IValueGradient {
  83384. /**
  83385. * Gets or sets the gradient value (between 0 and 1)
  83386. */
  83387. gradient: number;
  83388. /**
  83389. * Gets or sets first associated factor
  83390. */
  83391. factor1: number;
  83392. /**
  83393. * Gets or sets second associated factor
  83394. */
  83395. factor2?: number;
  83396. /**
  83397. * Will get a number picked randomly between factor1 and factor2.
  83398. * If factor2 is undefined then factor1 will be used
  83399. * @returns the picked number
  83400. */
  83401. getFactor(): number;
  83402. }
  83403. /**
  83404. * Helper used to simplify some generic gradient tasks
  83405. */
  83406. export class GradientHelper {
  83407. /**
  83408. * Gets the current gradient from an array of IValueGradient
  83409. * @param ratio defines the current ratio to get
  83410. * @param gradients defines the array of IValueGradient
  83411. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83412. */
  83413. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83414. }
  83415. }
  83416. declare module BABYLON {
  83417. /**
  83418. * Interface for the size containing width and height
  83419. */
  83420. export interface ISize {
  83421. /**
  83422. * Width
  83423. */
  83424. width: number;
  83425. /**
  83426. * Heighht
  83427. */
  83428. height: number;
  83429. }
  83430. /**
  83431. * Size containing widht and height
  83432. */
  83433. export class Size implements ISize {
  83434. /**
  83435. * Width
  83436. */
  83437. width: number;
  83438. /**
  83439. * Height
  83440. */
  83441. height: number;
  83442. /**
  83443. * Creates a Size object from the given width and height (floats).
  83444. * @param width width of the new size
  83445. * @param height height of the new size
  83446. */
  83447. constructor(width: number, height: number);
  83448. /**
  83449. * Returns a string with the Size width and height
  83450. * @returns a string with the Size width and height
  83451. */
  83452. toString(): string;
  83453. /**
  83454. * "Size"
  83455. * @returns the string "Size"
  83456. */
  83457. getClassName(): string;
  83458. /**
  83459. * Returns the Size hash code.
  83460. * @returns a hash code for a unique width and height
  83461. */
  83462. getHashCode(): number;
  83463. /**
  83464. * Updates the current size from the given one.
  83465. * @param src the given size
  83466. */
  83467. copyFrom(src: Size): void;
  83468. /**
  83469. * Updates in place the current Size from the given floats.
  83470. * @param width width of the new size
  83471. * @param height height of the new size
  83472. * @returns the updated Size.
  83473. */
  83474. copyFromFloats(width: number, height: number): Size;
  83475. /**
  83476. * Updates in place the current Size from the given floats.
  83477. * @param width width to set
  83478. * @param height height to set
  83479. * @returns the updated Size.
  83480. */
  83481. set(width: number, height: number): Size;
  83482. /**
  83483. * Multiplies the width and height by numbers
  83484. * @param w factor to multiple the width by
  83485. * @param h factor to multiple the height by
  83486. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83487. */
  83488. multiplyByFloats(w: number, h: number): Size;
  83489. /**
  83490. * Clones the size
  83491. * @returns a new Size copied from the given one.
  83492. */
  83493. clone(): Size;
  83494. /**
  83495. * True if the current Size and the given one width and height are strictly equal.
  83496. * @param other the other size to compare against
  83497. * @returns True if the current Size and the given one width and height are strictly equal.
  83498. */
  83499. equals(other: Size): boolean;
  83500. /**
  83501. * The surface of the Size : width * height (float).
  83502. */
  83503. get surface(): number;
  83504. /**
  83505. * Create a new size of zero
  83506. * @returns a new Size set to (0.0, 0.0)
  83507. */
  83508. static Zero(): Size;
  83509. /**
  83510. * Sums the width and height of two sizes
  83511. * @param otherSize size to add to this size
  83512. * @returns a new Size set as the addition result of the current Size and the given one.
  83513. */
  83514. add(otherSize: Size): Size;
  83515. /**
  83516. * Subtracts the width and height of two
  83517. * @param otherSize size to subtract to this size
  83518. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83519. */
  83520. subtract(otherSize: Size): Size;
  83521. /**
  83522. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83523. * @param start starting size to lerp between
  83524. * @param end end size to lerp between
  83525. * @param amount amount to lerp between the start and end values
  83526. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83527. */
  83528. static Lerp(start: Size, end: Size, amount: number): Size;
  83529. }
  83530. }
  83531. declare module BABYLON {
  83532. interface ThinEngine {
  83533. /**
  83534. * Creates a dynamic texture
  83535. * @param width defines the width of the texture
  83536. * @param height defines the height of the texture
  83537. * @param generateMipMaps defines if the engine should generate the mip levels
  83538. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83539. * @returns the dynamic texture inside an InternalTexture
  83540. */
  83541. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83542. /**
  83543. * Update the content of a dynamic texture
  83544. * @param texture defines the texture to update
  83545. * @param canvas defines the canvas containing the source
  83546. * @param invertY defines if data must be stored with Y axis inverted
  83547. * @param premulAlpha defines if alpha is stored as premultiplied
  83548. * @param format defines the format of the data
  83549. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83550. */
  83551. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83552. }
  83553. }
  83554. declare module BABYLON {
  83555. /**
  83556. * Helper class used to generate a canvas to manipulate images
  83557. */
  83558. export class CanvasGenerator {
  83559. /**
  83560. * Create a new canvas (or offscreen canvas depending on the context)
  83561. * @param width defines the expected width
  83562. * @param height defines the expected height
  83563. * @return a new canvas or offscreen canvas
  83564. */
  83565. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * A class extending Texture allowing drawing on a texture
  83571. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83572. */
  83573. export class DynamicTexture extends Texture {
  83574. private _generateMipMaps;
  83575. private _canvas;
  83576. private _context;
  83577. private _engine;
  83578. /**
  83579. * Creates a DynamicTexture
  83580. * @param name defines the name of the texture
  83581. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  83582. * @param scene defines the scene where you want the texture
  83583. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83584. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83585. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83586. */
  83587. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83588. /**
  83589. * Get the current class name of the texture useful for serialization or dynamic coding.
  83590. * @returns "DynamicTexture"
  83591. */
  83592. getClassName(): string;
  83593. /**
  83594. * Gets the current state of canRescale
  83595. */
  83596. get canRescale(): boolean;
  83597. private _recreate;
  83598. /**
  83599. * Scales the texture
  83600. * @param ratio the scale factor to apply to both width and height
  83601. */
  83602. scale(ratio: number): void;
  83603. /**
  83604. * Resizes the texture
  83605. * @param width the new width
  83606. * @param height the new height
  83607. */
  83608. scaleTo(width: number, height: number): void;
  83609. /**
  83610. * Gets the context of the canvas used by the texture
  83611. * @returns the canvas context of the dynamic texture
  83612. */
  83613. getContext(): CanvasRenderingContext2D;
  83614. /**
  83615. * Clears the texture
  83616. */
  83617. clear(): void;
  83618. /**
  83619. * Updates the texture
  83620. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83621. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83622. */
  83623. update(invertY?: boolean, premulAlpha?: boolean): void;
  83624. /**
  83625. * Draws text onto the texture
  83626. * @param text defines the text to be drawn
  83627. * @param x defines the placement of the text from the left
  83628. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83629. * @param font defines the font to be used with font-style, font-size, font-name
  83630. * @param color defines the color used for the text
  83631. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83633. * @param update defines whether texture is immediately update (default is true)
  83634. */
  83635. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83636. /**
  83637. * Clones the texture
  83638. * @returns the clone of the texture.
  83639. */
  83640. clone(): DynamicTexture;
  83641. /**
  83642. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83643. * @returns a serialized dynamic texture object
  83644. */
  83645. serialize(): any;
  83646. /** @hidden */
  83647. _rebuild(): void;
  83648. }
  83649. }
  83650. declare module BABYLON {
  83651. interface Engine {
  83652. /**
  83653. * Creates a raw texture
  83654. * @param data defines the data to store in the texture
  83655. * @param width defines the width of the texture
  83656. * @param height defines the height of the texture
  83657. * @param format defines the format of the data
  83658. * @param generateMipMaps defines if the engine should generate the mip levels
  83659. * @param invertY defines if data must be stored with Y axis inverted
  83660. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83661. * @param compression defines the compression used (null by default)
  83662. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83663. * @returns the raw texture inside an InternalTexture
  83664. */
  83665. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83666. /**
  83667. * Update a raw texture
  83668. * @param texture defines the texture to update
  83669. * @param data defines the data to store in the texture
  83670. * @param format defines the format of the data
  83671. * @param invertY defines if data must be stored with Y axis inverted
  83672. */
  83673. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83674. /**
  83675. * Update a raw texture
  83676. * @param texture defines the texture to update
  83677. * @param data defines the data to store in the texture
  83678. * @param format defines the format of the data
  83679. * @param invertY defines if data must be stored with Y axis inverted
  83680. * @param compression defines the compression used (null by default)
  83681. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83682. */
  83683. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83684. /**
  83685. * Creates a new raw cube texture
  83686. * @param data defines the array of data to use to create each face
  83687. * @param size defines the size of the textures
  83688. * @param format defines the format of the data
  83689. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83690. * @param generateMipMaps defines if the engine should generate the mip levels
  83691. * @param invertY defines if data must be stored with Y axis inverted
  83692. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83693. * @param compression defines the compression used (null by default)
  83694. * @returns the cube texture as an InternalTexture
  83695. */
  83696. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83697. /**
  83698. * Update a raw cube texture
  83699. * @param texture defines the texture to udpdate
  83700. * @param data defines the data to store
  83701. * @param format defines the data format
  83702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83703. * @param invertY defines if data must be stored with Y axis inverted
  83704. */
  83705. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83706. /**
  83707. * Update a raw cube texture
  83708. * @param texture defines the texture to udpdate
  83709. * @param data defines the data to store
  83710. * @param format defines the data format
  83711. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83712. * @param invertY defines if data must be stored with Y axis inverted
  83713. * @param compression defines the compression used (null by default)
  83714. */
  83715. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83716. /**
  83717. * Update a raw cube texture
  83718. * @param texture defines the texture to udpdate
  83719. * @param data defines the data to store
  83720. * @param format defines the data format
  83721. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83722. * @param invertY defines if data must be stored with Y axis inverted
  83723. * @param compression defines the compression used (null by default)
  83724. * @param level defines which level of the texture to update
  83725. */
  83726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83727. /**
  83728. * Creates a new raw cube texture from a specified url
  83729. * @param url defines the url where the data is located
  83730. * @param scene defines the current scene
  83731. * @param size defines the size of the textures
  83732. * @param format defines the format of the data
  83733. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83734. * @param noMipmap defines if the engine should avoid generating the mip levels
  83735. * @param callback defines a callback used to extract texture data from loaded data
  83736. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83737. * @param onLoad defines a callback called when texture is loaded
  83738. * @param onError defines a callback called if there is an error
  83739. * @returns the cube texture as an InternalTexture
  83740. */
  83741. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  83742. /**
  83743. * Creates a new raw cube texture from a specified url
  83744. * @param url defines the url where the data is located
  83745. * @param scene defines the current scene
  83746. * @param size defines the size of the textures
  83747. * @param format defines the format of the data
  83748. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83749. * @param noMipmap defines if the engine should avoid generating the mip levels
  83750. * @param callback defines a callback used to extract texture data from loaded data
  83751. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83752. * @param onLoad defines a callback called when texture is loaded
  83753. * @param onError defines a callback called if there is an error
  83754. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83755. * @param invertY defines if data must be stored with Y axis inverted
  83756. * @returns the cube texture as an InternalTexture
  83757. */
  83758. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  83759. /**
  83760. * Creates a new raw 3D texture
  83761. * @param data defines the data used to create the texture
  83762. * @param width defines the width of the texture
  83763. * @param height defines the height of the texture
  83764. * @param depth defines the depth of the texture
  83765. * @param format defines the format of the texture
  83766. * @param generateMipMaps defines if the engine must generate mip levels
  83767. * @param invertY defines if data must be stored with Y axis inverted
  83768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83769. * @param compression defines the compressed used (can be null)
  83770. * @param textureType defines the compressed used (can be null)
  83771. * @returns a new raw 3D texture (stored in an InternalTexture)
  83772. */
  83773. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83774. /**
  83775. * Update a raw 3D texture
  83776. * @param texture defines the texture to update
  83777. * @param data defines the data to store
  83778. * @param format defines the data format
  83779. * @param invertY defines if data must be stored with Y axis inverted
  83780. */
  83781. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83782. /**
  83783. * Update a raw 3D texture
  83784. * @param texture defines the texture to update
  83785. * @param data defines the data to store
  83786. * @param format defines the data format
  83787. * @param invertY defines if data must be stored with Y axis inverted
  83788. * @param compression defines the used compression (can be null)
  83789. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83790. */
  83791. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83792. /**
  83793. * Creates a new raw 2D array texture
  83794. * @param data defines the data used to create the texture
  83795. * @param width defines the width of the texture
  83796. * @param height defines the height of the texture
  83797. * @param depth defines the number of layers of the texture
  83798. * @param format defines the format of the texture
  83799. * @param generateMipMaps defines if the engine must generate mip levels
  83800. * @param invertY defines if data must be stored with Y axis inverted
  83801. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83802. * @param compression defines the compressed used (can be null)
  83803. * @param textureType defines the compressed used (can be null)
  83804. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83805. */
  83806. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83807. /**
  83808. * Update a raw 2D array texture
  83809. * @param texture defines the texture to update
  83810. * @param data defines the data to store
  83811. * @param format defines the data format
  83812. * @param invertY defines if data must be stored with Y axis inverted
  83813. */
  83814. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83815. /**
  83816. * Update a raw 2D array texture
  83817. * @param texture defines the texture to update
  83818. * @param data defines the data to store
  83819. * @param format defines the data format
  83820. * @param invertY defines if data must be stored with Y axis inverted
  83821. * @param compression defines the used compression (can be null)
  83822. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83823. */
  83824. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83825. }
  83826. }
  83827. declare module BABYLON {
  83828. /**
  83829. * Raw texture can help creating a texture directly from an array of data.
  83830. * This can be super useful if you either get the data from an uncompressed source or
  83831. * if you wish to create your texture pixel by pixel.
  83832. */
  83833. export class RawTexture extends Texture {
  83834. /**
  83835. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83836. */
  83837. format: number;
  83838. private _engine;
  83839. /**
  83840. * Instantiates a new RawTexture.
  83841. * Raw texture can help creating a texture directly from an array of data.
  83842. * This can be super useful if you either get the data from an uncompressed source or
  83843. * if you wish to create your texture pixel by pixel.
  83844. * @param data define the array of data to use to create the texture
  83845. * @param width define the width of the texture
  83846. * @param height define the height of the texture
  83847. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83848. * @param scene define the scene the texture belongs to
  83849. * @param generateMipMaps define whether mip maps should be generated or not
  83850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83852. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83853. */
  83854. constructor(data: ArrayBufferView, width: number, height: number,
  83855. /**
  83856. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83857. */
  83858. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83859. /**
  83860. * Updates the texture underlying data.
  83861. * @param data Define the new data of the texture
  83862. */
  83863. update(data: ArrayBufferView): void;
  83864. /**
  83865. * Creates a luminance texture from some data.
  83866. * @param data Define the texture data
  83867. * @param width Define the width of the texture
  83868. * @param height Define the height of the texture
  83869. * @param scene Define the scene the texture belongs to
  83870. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83871. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83872. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83873. * @returns the luminance texture
  83874. */
  83875. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83876. /**
  83877. * Creates a luminance alpha texture from some data.
  83878. * @param data Define the texture data
  83879. * @param width Define the width of the texture
  83880. * @param height Define the height of the texture
  83881. * @param scene Define the scene the texture belongs to
  83882. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83883. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83884. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83885. * @returns the luminance alpha texture
  83886. */
  83887. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83888. /**
  83889. * Creates an alpha texture from some data.
  83890. * @param data Define the texture data
  83891. * @param width Define the width of the texture
  83892. * @param height Define the height of the texture
  83893. * @param scene Define the scene the texture belongs to
  83894. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83895. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83896. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83897. * @returns the alpha texture
  83898. */
  83899. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83900. /**
  83901. * Creates a RGB texture from some data.
  83902. * @param data Define the texture data
  83903. * @param width Define the width of the texture
  83904. * @param height Define the height of the texture
  83905. * @param scene Define the scene the texture belongs to
  83906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83910. * @returns the RGB alpha texture
  83911. */
  83912. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83913. /**
  83914. * Creates a RGBA texture from some data.
  83915. * @param data Define the texture data
  83916. * @param width Define the width of the texture
  83917. * @param height Define the height of the texture
  83918. * @param scene Define the scene the texture belongs to
  83919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83923. * @returns the RGBA texture
  83924. */
  83925. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83926. /**
  83927. * Creates a R texture from some data.
  83928. * @param data Define the texture data
  83929. * @param width Define the width of the texture
  83930. * @param height Define the height of the texture
  83931. * @param scene Define the scene the texture belongs to
  83932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83935. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83936. * @returns the R texture
  83937. */
  83938. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83939. }
  83940. }
  83941. declare module BABYLON {
  83942. interface AbstractScene {
  83943. /**
  83944. * The list of procedural textures added to the scene
  83945. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83946. */
  83947. proceduralTextures: Array<ProceduralTexture>;
  83948. }
  83949. /**
  83950. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83951. * in a given scene.
  83952. */
  83953. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83954. /**
  83955. * The component name helpfull to identify the component in the list of scene components.
  83956. */
  83957. readonly name: string;
  83958. /**
  83959. * The scene the component belongs to.
  83960. */
  83961. scene: Scene;
  83962. /**
  83963. * Creates a new instance of the component for the given scene
  83964. * @param scene Defines the scene to register the component in
  83965. */
  83966. constructor(scene: Scene);
  83967. /**
  83968. * Registers the component in a given scene
  83969. */
  83970. register(): void;
  83971. /**
  83972. * Rebuilds the elements related to this component in case of
  83973. * context lost for instance.
  83974. */
  83975. rebuild(): void;
  83976. /**
  83977. * Disposes the component and the associated ressources.
  83978. */
  83979. dispose(): void;
  83980. private _beforeClear;
  83981. }
  83982. }
  83983. declare module BABYLON {
  83984. interface ThinEngine {
  83985. /**
  83986. * Creates a new render target cube texture
  83987. * @param size defines the size of the texture
  83988. * @param options defines the options used to create the texture
  83989. * @returns a new render target cube texture stored in an InternalTexture
  83990. */
  83991. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83992. }
  83993. }
  83994. declare module BABYLON {
  83995. /** @hidden */
  83996. export var proceduralVertexShader: {
  83997. name: string;
  83998. shader: string;
  83999. };
  84000. }
  84001. declare module BABYLON {
  84002. /**
  84003. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  84004. * This is the base class of any Procedural texture and contains most of the shareable code.
  84005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84006. */
  84007. export class ProceduralTexture extends Texture {
  84008. isCube: boolean;
  84009. /**
  84010. * Define if the texture is enabled or not (disabled texture will not render)
  84011. */
  84012. isEnabled: boolean;
  84013. /**
  84014. * Define if the texture must be cleared before rendering (default is true)
  84015. */
  84016. autoClear: boolean;
  84017. /**
  84018. * Callback called when the texture is generated
  84019. */
  84020. onGenerated: () => void;
  84021. /**
  84022. * Event raised when the texture is generated
  84023. */
  84024. onGeneratedObservable: Observable<ProceduralTexture>;
  84025. /** @hidden */
  84026. _generateMipMaps: boolean;
  84027. /** @hidden **/
  84028. _effect: Effect;
  84029. /** @hidden */
  84030. _textures: {
  84031. [key: string]: Texture;
  84032. };
  84033. private _size;
  84034. private _currentRefreshId;
  84035. private _frameId;
  84036. private _refreshRate;
  84037. private _vertexBuffers;
  84038. private _indexBuffer;
  84039. private _uniforms;
  84040. private _samplers;
  84041. private _fragment;
  84042. private _floats;
  84043. private _ints;
  84044. private _floatsArrays;
  84045. private _colors3;
  84046. private _colors4;
  84047. private _vectors2;
  84048. private _vectors3;
  84049. private _matrices;
  84050. private _fallbackTexture;
  84051. private _fallbackTextureUsed;
  84052. private _engine;
  84053. private _cachedDefines;
  84054. private _contentUpdateId;
  84055. private _contentData;
  84056. /**
  84057. * Instantiates a new procedural texture.
  84058. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  84059. * This is the base class of any Procedural texture and contains most of the shareable code.
  84060. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84061. * @param name Define the name of the texture
  84062. * @param size Define the size of the texture to create
  84063. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84064. * @param scene Define the scene the texture belongs to
  84065. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84066. * @param generateMipMaps Define if the texture should creates mip maps or not
  84067. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84068. */
  84069. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84070. /**
  84071. * The effect that is created when initializing the post process.
  84072. * @returns The created effect corresponding the the postprocess.
  84073. */
  84074. getEffect(): Effect;
  84075. /**
  84076. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84077. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84078. */
  84079. getContent(): Nullable<ArrayBufferView>;
  84080. private _createIndexBuffer;
  84081. /** @hidden */
  84082. _rebuild(): void;
  84083. /**
  84084. * Resets the texture in order to recreate its associated resources.
  84085. * This can be called in case of context loss
  84086. */
  84087. reset(): void;
  84088. protected _getDefines(): string;
  84089. /**
  84090. * Is the texture ready to be used ? (rendered at least once)
  84091. * @returns true if ready, otherwise, false.
  84092. */
  84093. isReady(): boolean;
  84094. /**
  84095. * Resets the refresh counter of the texture and start bak from scratch.
  84096. * Could be useful to regenerate the texture if it is setup to render only once.
  84097. */
  84098. resetRefreshCounter(): void;
  84099. /**
  84100. * Set the fragment shader to use in order to render the texture.
  84101. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84102. */
  84103. setFragment(fragment: any): void;
  84104. /**
  84105. * Define the refresh rate of the texture or the rendering frequency.
  84106. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84107. */
  84108. get refreshRate(): number;
  84109. set refreshRate(value: number);
  84110. /** @hidden */
  84111. _shouldRender(): boolean;
  84112. /**
  84113. * Get the size the texture is rendering at.
  84114. * @returns the size (texture is always squared)
  84115. */
  84116. getRenderSize(): number;
  84117. /**
  84118. * Resize the texture to new value.
  84119. * @param size Define the new size the texture should have
  84120. * @param generateMipMaps Define whether the new texture should create mip maps
  84121. */
  84122. resize(size: number, generateMipMaps: boolean): void;
  84123. private _checkUniform;
  84124. /**
  84125. * Set a texture in the shader program used to render.
  84126. * @param name Define the name of the uniform samplers as defined in the shader
  84127. * @param texture Define the texture to bind to this sampler
  84128. * @return the texture itself allowing "fluent" like uniform updates
  84129. */
  84130. setTexture(name: string, texture: Texture): ProceduralTexture;
  84131. /**
  84132. * Set a float in the shader.
  84133. * @param name Define the name of the uniform as defined in the shader
  84134. * @param value Define the value to give to the uniform
  84135. * @return the texture itself allowing "fluent" like uniform updates
  84136. */
  84137. setFloat(name: string, value: number): ProceduralTexture;
  84138. /**
  84139. * Set a int in the shader.
  84140. * @param name Define the name of the uniform as defined in the shader
  84141. * @param value Define the value to give to the uniform
  84142. * @return the texture itself allowing "fluent" like uniform updates
  84143. */
  84144. setInt(name: string, value: number): ProceduralTexture;
  84145. /**
  84146. * Set an array of floats in the shader.
  84147. * @param name Define the name of the uniform as defined in the shader
  84148. * @param value Define the value to give to the uniform
  84149. * @return the texture itself allowing "fluent" like uniform updates
  84150. */
  84151. setFloats(name: string, value: number[]): ProceduralTexture;
  84152. /**
  84153. * Set a vec3 in the shader from a Color3.
  84154. * @param name Define the name of the uniform as defined in the shader
  84155. * @param value Define the value to give to the uniform
  84156. * @return the texture itself allowing "fluent" like uniform updates
  84157. */
  84158. setColor3(name: string, value: Color3): ProceduralTexture;
  84159. /**
  84160. * Set a vec4 in the shader from a Color4.
  84161. * @param name Define the name of the uniform as defined in the shader
  84162. * @param value Define the value to give to the uniform
  84163. * @return the texture itself allowing "fluent" like uniform updates
  84164. */
  84165. setColor4(name: string, value: Color4): ProceduralTexture;
  84166. /**
  84167. * Set a vec2 in the shader from a Vector2.
  84168. * @param name Define the name of the uniform as defined in the shader
  84169. * @param value Define the value to give to the uniform
  84170. * @return the texture itself allowing "fluent" like uniform updates
  84171. */
  84172. setVector2(name: string, value: Vector2): ProceduralTexture;
  84173. /**
  84174. * Set a vec3 in the shader from a Vector3.
  84175. * @param name Define the name of the uniform as defined in the shader
  84176. * @param value Define the value to give to the uniform
  84177. * @return the texture itself allowing "fluent" like uniform updates
  84178. */
  84179. setVector3(name: string, value: Vector3): ProceduralTexture;
  84180. /**
  84181. * Set a mat4 in the shader from a MAtrix.
  84182. * @param name Define the name of the uniform as defined in the shader
  84183. * @param value Define the value to give to the uniform
  84184. * @return the texture itself allowing "fluent" like uniform updates
  84185. */
  84186. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84187. /**
  84188. * Render the texture to its associated render target.
  84189. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84190. */
  84191. render(useCameraPostProcess?: boolean): void;
  84192. /**
  84193. * Clone the texture.
  84194. * @returns the cloned texture
  84195. */
  84196. clone(): ProceduralTexture;
  84197. /**
  84198. * Dispose the texture and release its asoociated resources.
  84199. */
  84200. dispose(): void;
  84201. }
  84202. }
  84203. declare module BABYLON {
  84204. /**
  84205. * This represents the base class for particle system in Babylon.
  84206. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  84207. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84208. * @example https://doc.babylonjs.com/babylon101/particles
  84209. */
  84210. export class BaseParticleSystem {
  84211. /**
  84212. * Source color is added to the destination color without alpha affecting the result
  84213. */
  84214. static BLENDMODE_ONEONE: number;
  84215. /**
  84216. * Blend current color and particle color using particle’s alpha
  84217. */
  84218. static BLENDMODE_STANDARD: number;
  84219. /**
  84220. * Add current color and particle color multiplied by particle’s alpha
  84221. */
  84222. static BLENDMODE_ADD: number;
  84223. /**
  84224. * Multiply current color with particle color
  84225. */
  84226. static BLENDMODE_MULTIPLY: number;
  84227. /**
  84228. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84229. */
  84230. static BLENDMODE_MULTIPLYADD: number;
  84231. /**
  84232. * List of animations used by the particle system.
  84233. */
  84234. animations: Animation[];
  84235. /**
  84236. * The id of the Particle system.
  84237. */
  84238. id: string;
  84239. /**
  84240. * The friendly name of the Particle system.
  84241. */
  84242. name: string;
  84243. /**
  84244. * The rendering group used by the Particle system to chose when to render.
  84245. */
  84246. renderingGroupId: number;
  84247. /**
  84248. * The emitter represents the Mesh or position we are attaching the particle system to.
  84249. */
  84250. emitter: Nullable<AbstractMesh | Vector3>;
  84251. /**
  84252. * The maximum number of particles to emit per frame
  84253. */
  84254. emitRate: number;
  84255. /**
  84256. * If you want to launch only a few particles at once, that can be done, as well.
  84257. */
  84258. manualEmitCount: number;
  84259. /**
  84260. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84261. */
  84262. updateSpeed: number;
  84263. /**
  84264. * The amount of time the particle system is running (depends of the overall update speed).
  84265. */
  84266. targetStopDuration: number;
  84267. /**
  84268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84269. */
  84270. disposeOnStop: boolean;
  84271. /**
  84272. * Minimum power of emitting particles.
  84273. */
  84274. minEmitPower: number;
  84275. /**
  84276. * Maximum power of emitting particles.
  84277. */
  84278. maxEmitPower: number;
  84279. /**
  84280. * Minimum life time of emitting particles.
  84281. */
  84282. minLifeTime: number;
  84283. /**
  84284. * Maximum life time of emitting particles.
  84285. */
  84286. maxLifeTime: number;
  84287. /**
  84288. * Minimum Size of emitting particles.
  84289. */
  84290. minSize: number;
  84291. /**
  84292. * Maximum Size of emitting particles.
  84293. */
  84294. maxSize: number;
  84295. /**
  84296. * Minimum scale of emitting particles on X axis.
  84297. */
  84298. minScaleX: number;
  84299. /**
  84300. * Maximum scale of emitting particles on X axis.
  84301. */
  84302. maxScaleX: number;
  84303. /**
  84304. * Minimum scale of emitting particles on Y axis.
  84305. */
  84306. minScaleY: number;
  84307. /**
  84308. * Maximum scale of emitting particles on Y axis.
  84309. */
  84310. maxScaleY: number;
  84311. /**
  84312. * Gets or sets the minimal initial rotation in radians.
  84313. */
  84314. minInitialRotation: number;
  84315. /**
  84316. * Gets or sets the maximal initial rotation in radians.
  84317. */
  84318. maxInitialRotation: number;
  84319. /**
  84320. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84321. */
  84322. minAngularSpeed: number;
  84323. /**
  84324. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84325. */
  84326. maxAngularSpeed: number;
  84327. /**
  84328. * The texture used to render each particle. (this can be a spritesheet)
  84329. */
  84330. particleTexture: Nullable<Texture>;
  84331. /**
  84332. * The layer mask we are rendering the particles through.
  84333. */
  84334. layerMask: number;
  84335. /**
  84336. * This can help using your own shader to render the particle system.
  84337. * The according effect will be created
  84338. */
  84339. customShader: any;
  84340. /**
  84341. * By default particle system starts as soon as they are created. This prevents the
  84342. * automatic start to happen and let you decide when to start emitting particles.
  84343. */
  84344. preventAutoStart: boolean;
  84345. private _noiseTexture;
  84346. /**
  84347. * Gets or sets a texture used to add random noise to particle positions
  84348. */
  84349. get noiseTexture(): Nullable<ProceduralTexture>;
  84350. set noiseTexture(value: Nullable<ProceduralTexture>);
  84351. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84352. noiseStrength: Vector3;
  84353. /**
  84354. * Callback triggered when the particle animation is ending.
  84355. */
  84356. onAnimationEnd: Nullable<() => void>;
  84357. /**
  84358. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84359. */
  84360. blendMode: number;
  84361. /**
  84362. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84363. * to override the particles.
  84364. */
  84365. forceDepthWrite: boolean;
  84366. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  84367. preWarmCycles: number;
  84368. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84369. preWarmStepOffset: number;
  84370. /**
  84371. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  84372. */
  84373. spriteCellChangeSpeed: number;
  84374. /**
  84375. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84376. */
  84377. startSpriteCellID: number;
  84378. /**
  84379. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84380. */
  84381. endSpriteCellID: number;
  84382. /**
  84383. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84384. */
  84385. spriteCellWidth: number;
  84386. /**
  84387. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84388. */
  84389. spriteCellHeight: number;
  84390. /**
  84391. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84392. */
  84393. spriteRandomStartCell: boolean;
  84394. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84395. translationPivot: Vector2;
  84396. /** @hidden */
  84397. protected _isAnimationSheetEnabled: boolean;
  84398. /**
  84399. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84400. */
  84401. beginAnimationOnStart: boolean;
  84402. /**
  84403. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84404. */
  84405. beginAnimationFrom: number;
  84406. /**
  84407. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84408. */
  84409. beginAnimationTo: number;
  84410. /**
  84411. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84412. */
  84413. beginAnimationLoop: boolean;
  84414. /**
  84415. * Gets or sets a world offset applied to all particles
  84416. */
  84417. worldOffset: Vector3;
  84418. /**
  84419. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84420. */
  84421. get isAnimationSheetEnabled(): boolean;
  84422. set isAnimationSheetEnabled(value: boolean);
  84423. /**
  84424. * Get hosting scene
  84425. * @returns the scene
  84426. */
  84427. getScene(): Scene;
  84428. /**
  84429. * You can use gravity if you want to give an orientation to your particles.
  84430. */
  84431. gravity: Vector3;
  84432. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84433. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84434. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84435. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84436. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84437. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84438. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84439. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84440. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84441. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84442. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84443. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84444. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84445. /**
  84446. * Defines the delay in milliseconds before starting the system (0 by default)
  84447. */
  84448. startDelay: number;
  84449. /**
  84450. * Gets the current list of drag gradients.
  84451. * You must use addDragGradient and removeDragGradient to udpate this list
  84452. * @returns the list of drag gradients
  84453. */
  84454. getDragGradients(): Nullable<Array<FactorGradient>>;
  84455. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84456. limitVelocityDamping: number;
  84457. /**
  84458. * Gets the current list of limit velocity gradients.
  84459. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84460. * @returns the list of limit velocity gradients
  84461. */
  84462. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84463. /**
  84464. * Gets the current list of color gradients.
  84465. * You must use addColorGradient and removeColorGradient to udpate this list
  84466. * @returns the list of color gradients
  84467. */
  84468. getColorGradients(): Nullable<Array<ColorGradient>>;
  84469. /**
  84470. * Gets the current list of size gradients.
  84471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84472. * @returns the list of size gradients
  84473. */
  84474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84475. /**
  84476. * Gets the current list of color remap gradients.
  84477. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84478. * @returns the list of color remap gradients
  84479. */
  84480. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84481. /**
  84482. * Gets the current list of alpha remap gradients.
  84483. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84484. * @returns the list of alpha remap gradients
  84485. */
  84486. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84487. /**
  84488. * Gets the current list of life time gradients.
  84489. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84490. * @returns the list of life time gradients
  84491. */
  84492. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84493. /**
  84494. * Gets the current list of angular speed gradients.
  84495. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84496. * @returns the list of angular speed gradients
  84497. */
  84498. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84499. /**
  84500. * Gets the current list of velocity gradients.
  84501. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84502. * @returns the list of velocity gradients
  84503. */
  84504. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84505. /**
  84506. * Gets the current list of start size gradients.
  84507. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84508. * @returns the list of start size gradients
  84509. */
  84510. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84511. /**
  84512. * Gets the current list of emit rate gradients.
  84513. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84514. * @returns the list of emit rate gradients
  84515. */
  84516. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84517. /**
  84518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84520. */
  84521. get direction1(): Vector3;
  84522. set direction1(value: Vector3);
  84523. /**
  84524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84525. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84526. */
  84527. get direction2(): Vector3;
  84528. set direction2(value: Vector3);
  84529. /**
  84530. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  84531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84532. */
  84533. get minEmitBox(): Vector3;
  84534. set minEmitBox(value: Vector3);
  84535. /**
  84536. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  84537. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84538. */
  84539. get maxEmitBox(): Vector3;
  84540. set maxEmitBox(value: Vector3);
  84541. /**
  84542. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84543. */
  84544. color1: Color4;
  84545. /**
  84546. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84547. */
  84548. color2: Color4;
  84549. /**
  84550. * Color the particle will have at the end of its lifetime
  84551. */
  84552. colorDead: Color4;
  84553. /**
  84554. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84555. */
  84556. textureMask: Color4;
  84557. /**
  84558. * The particle emitter type defines the emitter used by the particle system.
  84559. * It can be for example box, sphere, or cone...
  84560. */
  84561. particleEmitterType: IParticleEmitterType;
  84562. /** @hidden */
  84563. _isSubEmitter: boolean;
  84564. /**
  84565. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84566. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84567. */
  84568. billboardMode: number;
  84569. protected _isBillboardBased: boolean;
  84570. /**
  84571. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84572. */
  84573. get isBillboardBased(): boolean;
  84574. set isBillboardBased(value: boolean);
  84575. /**
  84576. * The scene the particle system belongs to.
  84577. */
  84578. protected _scene: Scene;
  84579. /**
  84580. * Local cache of defines for image processing.
  84581. */
  84582. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84583. /**
  84584. * Default configuration related to image processing available in the standard Material.
  84585. */
  84586. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84587. /**
  84588. * Gets the image processing configuration used either in this material.
  84589. */
  84590. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84591. /**
  84592. * Sets the Default image processing configuration used either in the this material.
  84593. *
  84594. * If sets to null, the scene one is in use.
  84595. */
  84596. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84597. /**
  84598. * Attaches a new image processing configuration to the Standard Material.
  84599. * @param configuration
  84600. */
  84601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84602. /** @hidden */
  84603. protected _reset(): void;
  84604. /** @hidden */
  84605. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84606. /**
  84607. * Instantiates a particle system.
  84608. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  84609. * @param name The name of the particle system
  84610. */
  84611. constructor(name: string);
  84612. /**
  84613. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84616. * @returns the emitter
  84617. */
  84618. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84619. /**
  84620. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84621. * @param radius The radius of the hemisphere to emit from
  84622. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84623. * @returns the emitter
  84624. */
  84625. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84626. /**
  84627. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84628. * @param radius The radius of the sphere to emit from
  84629. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84630. * @returns the emitter
  84631. */
  84632. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84633. /**
  84634. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84635. * @param radius The radius of the sphere to emit from
  84636. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84637. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84638. * @returns the emitter
  84639. */
  84640. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84641. /**
  84642. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84643. * @param radius The radius of the emission cylinder
  84644. * @param height The height of the emission cylinder
  84645. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84646. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84647. * @returns the emitter
  84648. */
  84649. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84650. /**
  84651. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84652. * @param radius The radius of the cylinder to emit from
  84653. * @param height The height of the emission cylinder
  84654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84657. * @returns the emitter
  84658. */
  84659. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84660. /**
  84661. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84662. * @param radius The radius of the cone to emit from
  84663. * @param angle The base angle of the cone
  84664. * @returns the emitter
  84665. */
  84666. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84667. /**
  84668. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84671. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84672. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84673. * @returns the emitter
  84674. */
  84675. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84676. }
  84677. }
  84678. declare module BABYLON {
  84679. /**
  84680. * Type of sub emitter
  84681. */
  84682. export enum SubEmitterType {
  84683. /**
  84684. * Attached to the particle over it's lifetime
  84685. */
  84686. ATTACHED = 0,
  84687. /**
  84688. * Created when the particle dies
  84689. */
  84690. END = 1
  84691. }
  84692. /**
  84693. * Sub emitter class used to emit particles from an existing particle
  84694. */
  84695. export class SubEmitter {
  84696. /**
  84697. * the particle system to be used by the sub emitter
  84698. */
  84699. particleSystem: ParticleSystem;
  84700. /**
  84701. * Type of the submitter (Default: END)
  84702. */
  84703. type: SubEmitterType;
  84704. /**
  84705. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  84706. * Note: This only is supported when using an emitter of type Mesh
  84707. */
  84708. inheritDirection: boolean;
  84709. /**
  84710. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84711. */
  84712. inheritedVelocityAmount: number;
  84713. /**
  84714. * Creates a sub emitter
  84715. * @param particleSystem the particle system to be used by the sub emitter
  84716. */
  84717. constructor(
  84718. /**
  84719. * the particle system to be used by the sub emitter
  84720. */
  84721. particleSystem: ParticleSystem);
  84722. /**
  84723. * Clones the sub emitter
  84724. * @returns the cloned sub emitter
  84725. */
  84726. clone(): SubEmitter;
  84727. /**
  84728. * Serialize current object to a JSON object
  84729. * @returns the serialized object
  84730. */
  84731. serialize(): any;
  84732. /** @hidden */
  84733. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84734. /**
  84735. * Creates a new SubEmitter from a serialized JSON version
  84736. * @param serializationObject defines the JSON object to read from
  84737. * @param scene defines the hosting scene
  84738. * @param rootUrl defines the rootUrl for data loading
  84739. * @returns a new SubEmitter
  84740. */
  84741. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84742. /** Release associated resources */
  84743. dispose(): void;
  84744. }
  84745. }
  84746. declare module BABYLON {
  84747. /** @hidden */
  84748. export var imageProcessingDeclaration: {
  84749. name: string;
  84750. shader: string;
  84751. };
  84752. }
  84753. declare module BABYLON {
  84754. /** @hidden */
  84755. export var imageProcessingFunctions: {
  84756. name: string;
  84757. shader: string;
  84758. };
  84759. }
  84760. declare module BABYLON {
  84761. /** @hidden */
  84762. export var particlesPixelShader: {
  84763. name: string;
  84764. shader: string;
  84765. };
  84766. }
  84767. declare module BABYLON {
  84768. /** @hidden */
  84769. export var particlesVertexShader: {
  84770. name: string;
  84771. shader: string;
  84772. };
  84773. }
  84774. declare module BABYLON {
  84775. /**
  84776. * This represents a particle system in Babylon.
  84777. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  84778. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84779. * @example https://doc.babylonjs.com/babylon101/particles
  84780. */
  84781. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84782. /**
  84783. * Billboard mode will only apply to Y axis
  84784. */
  84785. static readonly BILLBOARDMODE_Y: number;
  84786. /**
  84787. * Billboard mode will apply to all axes
  84788. */
  84789. static readonly BILLBOARDMODE_ALL: number;
  84790. /**
  84791. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84792. */
  84793. static readonly BILLBOARDMODE_STRETCHED: number;
  84794. /**
  84795. * This function can be defined to provide custom update for active particles.
  84796. * This function will be called instead of regular update (age, position, color, etc.).
  84797. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84798. */
  84799. updateFunction: (particles: Particle[]) => void;
  84800. private _emitterWorldMatrix;
  84801. /**
  84802. * This function can be defined to specify initial direction for every new particle.
  84803. * It by default use the emitterType defined function
  84804. */
  84805. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84806. /**
  84807. * This function can be defined to specify initial position for every new particle.
  84808. * It by default use the emitterType defined function
  84809. */
  84810. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84811. /**
  84812. * @hidden
  84813. */
  84814. _inheritedVelocityOffset: Vector3;
  84815. /**
  84816. * An event triggered when the system is disposed
  84817. */
  84818. onDisposeObservable: Observable<ParticleSystem>;
  84819. private _onDisposeObserver;
  84820. /**
  84821. * Sets a callback that will be triggered when the system is disposed
  84822. */
  84823. set onDispose(callback: () => void);
  84824. private _particles;
  84825. private _epsilon;
  84826. private _capacity;
  84827. private _stockParticles;
  84828. private _newPartsExcess;
  84829. private _vertexData;
  84830. private _vertexBuffer;
  84831. private _vertexBuffers;
  84832. private _spriteBuffer;
  84833. private _indexBuffer;
  84834. private _effect;
  84835. private _customEffect;
  84836. private _cachedDefines;
  84837. private _scaledColorStep;
  84838. private _colorDiff;
  84839. private _scaledDirection;
  84840. private _scaledGravity;
  84841. private _currentRenderId;
  84842. private _alive;
  84843. private _useInstancing;
  84844. private _started;
  84845. private _stopped;
  84846. private _actualFrame;
  84847. private _scaledUpdateSpeed;
  84848. private _vertexBufferSize;
  84849. /** @hidden */
  84850. _currentEmitRateGradient: Nullable<FactorGradient>;
  84851. /** @hidden */
  84852. _currentEmitRate1: number;
  84853. /** @hidden */
  84854. _currentEmitRate2: number;
  84855. /** @hidden */
  84856. _currentStartSizeGradient: Nullable<FactorGradient>;
  84857. /** @hidden */
  84858. _currentStartSize1: number;
  84859. /** @hidden */
  84860. _currentStartSize2: number;
  84861. private readonly _rawTextureWidth;
  84862. private _rampGradientsTexture;
  84863. private _useRampGradients;
  84864. /** Gets or sets a boolean indicating that ramp gradients must be used
  84865. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84866. */
  84867. get useRampGradients(): boolean;
  84868. set useRampGradients(value: boolean);
  84869. /**
  84870. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  84871. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  84872. */
  84873. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84874. private _subEmitters;
  84875. /**
  84876. * @hidden
  84877. * If the particle systems emitter should be disposed when the particle system is disposed
  84878. */
  84879. _disposeEmitterOnDispose: boolean;
  84880. /**
  84881. * The current active Sub-systems, this property is used by the root particle system only.
  84882. */
  84883. activeSubSystems: Array<ParticleSystem>;
  84884. private _rootParticleSystem;
  84885. /**
  84886. * Gets the current list of active particles
  84887. */
  84888. get particles(): Particle[];
  84889. /**
  84890. * Returns the string "ParticleSystem"
  84891. * @returns a string containing the class name
  84892. */
  84893. getClassName(): string;
  84894. /**
  84895. * Instantiates a particle system.
  84896. * 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.
  84897. * @param name The name of the particle system
  84898. * @param capacity The max number of particles alive at the same time
  84899. * @param scene The scene the particle system belongs to
  84900. * @param customEffect a custom effect used to change the way particles are rendered by default
  84901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84902. * @param epsilon Offset used to render the particles
  84903. */
  84904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84905. private _addFactorGradient;
  84906. private _removeFactorGradient;
  84907. /**
  84908. * Adds a new life time gradient
  84909. * @param gradient defines the gradient to use (between 0 and 1)
  84910. * @param factor defines the life time factor to affect to the specified gradient
  84911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84912. * @returns the current particle system
  84913. */
  84914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84915. /**
  84916. * Remove a specific life time gradient
  84917. * @param gradient defines the gradient to remove
  84918. * @returns the current particle system
  84919. */
  84920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84921. /**
  84922. * Adds a new size gradient
  84923. * @param gradient defines the gradient to use (between 0 and 1)
  84924. * @param factor defines the size factor to affect to the specified gradient
  84925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84926. * @returns the current particle system
  84927. */
  84928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84929. /**
  84930. * Remove a specific size gradient
  84931. * @param gradient defines the gradient to remove
  84932. * @returns the current particle system
  84933. */
  84934. removeSizeGradient(gradient: number): IParticleSystem;
  84935. /**
  84936. * Adds a new color remap gradient
  84937. * @param gradient defines the gradient to use (between 0 and 1)
  84938. * @param min defines the color remap minimal range
  84939. * @param max defines the color remap maximal range
  84940. * @returns the current particle system
  84941. */
  84942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84943. /**
  84944. * Remove a specific color remap gradient
  84945. * @param gradient defines the gradient to remove
  84946. * @returns the current particle system
  84947. */
  84948. removeColorRemapGradient(gradient: number): IParticleSystem;
  84949. /**
  84950. * Adds a new alpha remap gradient
  84951. * @param gradient defines the gradient to use (between 0 and 1)
  84952. * @param min defines the alpha remap minimal range
  84953. * @param max defines the alpha remap maximal range
  84954. * @returns the current particle system
  84955. */
  84956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84957. /**
  84958. * Remove a specific alpha remap gradient
  84959. * @param gradient defines the gradient to remove
  84960. * @returns the current particle system
  84961. */
  84962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84963. /**
  84964. * Adds a new angular speed gradient
  84965. * @param gradient defines the gradient to use (between 0 and 1)
  84966. * @param factor defines the angular speed to affect to the specified gradient
  84967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84968. * @returns the current particle system
  84969. */
  84970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84971. /**
  84972. * Remove a specific angular speed gradient
  84973. * @param gradient defines the gradient to remove
  84974. * @returns the current particle system
  84975. */
  84976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84977. /**
  84978. * Adds a new velocity gradient
  84979. * @param gradient defines the gradient to use (between 0 and 1)
  84980. * @param factor defines the velocity to affect to the specified gradient
  84981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84982. * @returns the current particle system
  84983. */
  84984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84985. /**
  84986. * Remove a specific velocity gradient
  84987. * @param gradient defines the gradient to remove
  84988. * @returns the current particle system
  84989. */
  84990. removeVelocityGradient(gradient: number): IParticleSystem;
  84991. /**
  84992. * Adds a new limit velocity gradient
  84993. * @param gradient defines the gradient to use (between 0 and 1)
  84994. * @param factor defines the limit velocity value to affect to the specified gradient
  84995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84996. * @returns the current particle system
  84997. */
  84998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84999. /**
  85000. * Remove a specific limit velocity gradient
  85001. * @param gradient defines the gradient to remove
  85002. * @returns the current particle system
  85003. */
  85004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85005. /**
  85006. * Adds a new drag gradient
  85007. * @param gradient defines the gradient to use (between 0 and 1)
  85008. * @param factor defines the drag value to affect to the specified gradient
  85009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85010. * @returns the current particle system
  85011. */
  85012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85013. /**
  85014. * Remove a specific drag gradient
  85015. * @param gradient defines the gradient to remove
  85016. * @returns the current particle system
  85017. */
  85018. removeDragGradient(gradient: number): IParticleSystem;
  85019. /**
  85020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85021. * @param gradient defines the gradient to use (between 0 and 1)
  85022. * @param factor defines the emit rate value to affect to the specified gradient
  85023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85024. * @returns the current particle system
  85025. */
  85026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85027. /**
  85028. * Remove a specific emit rate gradient
  85029. * @param gradient defines the gradient to remove
  85030. * @returns the current particle system
  85031. */
  85032. removeEmitRateGradient(gradient: number): IParticleSystem;
  85033. /**
  85034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85035. * @param gradient defines the gradient to use (between 0 and 1)
  85036. * @param factor defines the start size value to affect to the specified gradient
  85037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85038. * @returns the current particle system
  85039. */
  85040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85041. /**
  85042. * Remove a specific start size gradient
  85043. * @param gradient defines the gradient to remove
  85044. * @returns the current particle system
  85045. */
  85046. removeStartSizeGradient(gradient: number): IParticleSystem;
  85047. private _createRampGradientTexture;
  85048. /**
  85049. * Gets the current list of ramp gradients.
  85050. * You must use addRampGradient and removeRampGradient to udpate this list
  85051. * @returns the list of ramp gradients
  85052. */
  85053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85054. /**
  85055. * Adds a new ramp gradient used to remap particle colors
  85056. * @param gradient defines the gradient to use (between 0 and 1)
  85057. * @param color defines the color to affect to the specified gradient
  85058. * @returns the current particle system
  85059. */
  85060. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85061. /**
  85062. * Remove a specific ramp gradient
  85063. * @param gradient defines the gradient to remove
  85064. * @returns the current particle system
  85065. */
  85066. removeRampGradient(gradient: number): ParticleSystem;
  85067. /**
  85068. * Adds a new color gradient
  85069. * @param gradient defines the gradient to use (between 0 and 1)
  85070. * @param color1 defines the color to affect to the specified gradient
  85071. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85072. * @returns this particle system
  85073. */
  85074. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85075. /**
  85076. * Remove a specific color gradient
  85077. * @param gradient defines the gradient to remove
  85078. * @returns this particle system
  85079. */
  85080. removeColorGradient(gradient: number): IParticleSystem;
  85081. private _fetchR;
  85082. protected _reset(): void;
  85083. private _resetEffect;
  85084. private _createVertexBuffers;
  85085. private _createIndexBuffer;
  85086. /**
  85087. * Gets the maximum number of particles active at the same time.
  85088. * @returns The max number of active particles.
  85089. */
  85090. getCapacity(): number;
  85091. /**
  85092. * Gets whether there are still active particles in the system.
  85093. * @returns True if it is alive, otherwise false.
  85094. */
  85095. isAlive(): boolean;
  85096. /**
  85097. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85098. * @returns True if it has been started, otherwise false.
  85099. */
  85100. isStarted(): boolean;
  85101. private _prepareSubEmitterInternalArray;
  85102. /**
  85103. * Starts the particle system and begins to emit
  85104. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85105. */
  85106. start(delay?: number): void;
  85107. /**
  85108. * Stops the particle system.
  85109. * @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.
  85110. */
  85111. stop(stopSubEmitters?: boolean): void;
  85112. /**
  85113. * Remove all active particles
  85114. */
  85115. reset(): void;
  85116. /**
  85117. * @hidden (for internal use only)
  85118. */
  85119. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85120. /**
  85121. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85122. * Its lifetime will start back at 0.
  85123. */
  85124. recycleParticle: (particle: Particle) => void;
  85125. private _stopSubEmitters;
  85126. private _createParticle;
  85127. private _removeFromRoot;
  85128. private _emitFromParticle;
  85129. private _update;
  85130. /** @hidden */
  85131. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85132. /** @hidden */
  85133. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85134. /** @hidden */
  85135. private _getEffect;
  85136. /**
  85137. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85138. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85139. */
  85140. animate(preWarmOnly?: boolean): void;
  85141. private _appendParticleVertices;
  85142. /**
  85143. * Rebuilds the particle system.
  85144. */
  85145. rebuild(): void;
  85146. /**
  85147. * Is this system ready to be used/rendered
  85148. * @return true if the system is ready
  85149. */
  85150. isReady(): boolean;
  85151. private _render;
  85152. /**
  85153. * Renders the particle system in its current state.
  85154. * @returns the current number of particles
  85155. */
  85156. render(): number;
  85157. /**
  85158. * Disposes the particle system and free the associated resources
  85159. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85160. */
  85161. dispose(disposeTexture?: boolean): void;
  85162. /**
  85163. * Clones the particle system.
  85164. * @param name The name of the cloned object
  85165. * @param newEmitter The new emitter to use
  85166. * @returns the cloned particle system
  85167. */
  85168. clone(name: string, newEmitter: any): ParticleSystem;
  85169. /**
  85170. * Serializes the particle system to a JSON object.
  85171. * @returns the JSON object
  85172. */
  85173. serialize(): any;
  85174. /** @hidden */
  85175. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85176. /** @hidden */
  85177. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85178. /**
  85179. * Parses a JSON object to create a particle system.
  85180. * @param parsedParticleSystem The JSON object to parse
  85181. * @param scene The scene to create the particle system in
  85182. * @param rootUrl The root url to use to load external dependencies like texture
  85183. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85184. * @returns the Parsed particle system
  85185. */
  85186. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85187. }
  85188. }
  85189. declare module BABYLON {
  85190. /**
  85191. * A particle represents one of the element emitted by a particle system.
  85192. * This is mainly define by its coordinates, direction, velocity and age.
  85193. */
  85194. export class Particle {
  85195. /**
  85196. * The particle system the particle belongs to.
  85197. */
  85198. particleSystem: ParticleSystem;
  85199. private static _Count;
  85200. /**
  85201. * Unique ID of the particle
  85202. */
  85203. id: number;
  85204. /**
  85205. * The world position of the particle in the scene.
  85206. */
  85207. position: Vector3;
  85208. /**
  85209. * The world direction of the particle in the scene.
  85210. */
  85211. direction: Vector3;
  85212. /**
  85213. * The color of the particle.
  85214. */
  85215. color: Color4;
  85216. /**
  85217. * The color change of the particle per step.
  85218. */
  85219. colorStep: Color4;
  85220. /**
  85221. * Defines how long will the life of the particle be.
  85222. */
  85223. lifeTime: number;
  85224. /**
  85225. * The current age of the particle.
  85226. */
  85227. age: number;
  85228. /**
  85229. * The current size of the particle.
  85230. */
  85231. size: number;
  85232. /**
  85233. * The current scale of the particle.
  85234. */
  85235. scale: Vector2;
  85236. /**
  85237. * The current angle of the particle.
  85238. */
  85239. angle: number;
  85240. /**
  85241. * Defines how fast is the angle changing.
  85242. */
  85243. angularSpeed: number;
  85244. /**
  85245. * Defines the cell index used by the particle to be rendered from a sprite.
  85246. */
  85247. cellIndex: number;
  85248. /**
  85249. * The information required to support color remapping
  85250. */
  85251. remapData: Vector4;
  85252. /** @hidden */
  85253. _randomCellOffset?: number;
  85254. /** @hidden */
  85255. _initialDirection: Nullable<Vector3>;
  85256. /** @hidden */
  85257. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85258. /** @hidden */
  85259. _initialStartSpriteCellID: number;
  85260. /** @hidden */
  85261. _initialEndSpriteCellID: number;
  85262. /** @hidden */
  85263. _currentColorGradient: Nullable<ColorGradient>;
  85264. /** @hidden */
  85265. _currentColor1: Color4;
  85266. /** @hidden */
  85267. _currentColor2: Color4;
  85268. /** @hidden */
  85269. _currentSizeGradient: Nullable<FactorGradient>;
  85270. /** @hidden */
  85271. _currentSize1: number;
  85272. /** @hidden */
  85273. _currentSize2: number;
  85274. /** @hidden */
  85275. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85276. /** @hidden */
  85277. _currentAngularSpeed1: number;
  85278. /** @hidden */
  85279. _currentAngularSpeed2: number;
  85280. /** @hidden */
  85281. _currentVelocityGradient: Nullable<FactorGradient>;
  85282. /** @hidden */
  85283. _currentVelocity1: number;
  85284. /** @hidden */
  85285. _currentVelocity2: number;
  85286. /** @hidden */
  85287. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85288. /** @hidden */
  85289. _currentLimitVelocity1: number;
  85290. /** @hidden */
  85291. _currentLimitVelocity2: number;
  85292. /** @hidden */
  85293. _currentDragGradient: Nullable<FactorGradient>;
  85294. /** @hidden */
  85295. _currentDrag1: number;
  85296. /** @hidden */
  85297. _currentDrag2: number;
  85298. /** @hidden */
  85299. _randomNoiseCoordinates1: Vector3;
  85300. /** @hidden */
  85301. _randomNoiseCoordinates2: Vector3;
  85302. /**
  85303. * Creates a new instance Particle
  85304. * @param particleSystem the particle system the particle belongs to
  85305. */
  85306. constructor(
  85307. /**
  85308. * The particle system the particle belongs to.
  85309. */
  85310. particleSystem: ParticleSystem);
  85311. private updateCellInfoFromSystem;
  85312. /**
  85313. * Defines how the sprite cell index is updated for the particle
  85314. */
  85315. updateCellIndex(): void;
  85316. /** @hidden */
  85317. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85318. /** @hidden */
  85319. _inheritParticleInfoToSubEmitters(): void;
  85320. /** @hidden */
  85321. _reset(): void;
  85322. /**
  85323. * Copy the properties of particle to another one.
  85324. * @param other the particle to copy the information to.
  85325. */
  85326. copyTo(other: Particle): void;
  85327. }
  85328. }
  85329. declare module BABYLON {
  85330. /**
  85331. * Particle emitter represents a volume emitting particles.
  85332. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85333. */
  85334. export interface IParticleEmitterType {
  85335. /**
  85336. * Called by the particle System when the direction is computed for the created particle.
  85337. * @param worldMatrix is the world matrix of the particle system
  85338. * @param directionToUpdate is the direction vector to update with the result
  85339. * @param particle is the particle we are computed the direction for
  85340. */
  85341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85342. /**
  85343. * Called by the particle System when the position is computed for the created particle.
  85344. * @param worldMatrix is the world matrix of the particle system
  85345. * @param positionToUpdate is the position vector to update with the result
  85346. * @param particle is the particle we are computed the position for
  85347. */
  85348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85349. /**
  85350. * Clones the current emitter and returns a copy of it
  85351. * @returns the new emitter
  85352. */
  85353. clone(): IParticleEmitterType;
  85354. /**
  85355. * Called by the GPUParticleSystem to setup the update shader
  85356. * @param effect defines the update shader
  85357. */
  85358. applyToShader(effect: Effect): void;
  85359. /**
  85360. * Returns a string to use to update the GPU particles update shader
  85361. * @returns the effect defines string
  85362. */
  85363. getEffectDefines(): string;
  85364. /**
  85365. * Returns a string representing the class name
  85366. * @returns a string containing the class name
  85367. */
  85368. getClassName(): string;
  85369. /**
  85370. * Serializes the particle system to a JSON object.
  85371. * @returns the JSON object
  85372. */
  85373. serialize(): any;
  85374. /**
  85375. * Parse properties from a JSON object
  85376. * @param serializationObject defines the JSON object
  85377. * @param scene defines the hosting scene
  85378. */
  85379. parse(serializationObject: any, scene: Scene): void;
  85380. }
  85381. }
  85382. declare module BABYLON {
  85383. /**
  85384. * Particle emitter emitting particles from the inside of a box.
  85385. * It emits the particles randomly between 2 given directions.
  85386. */
  85387. export class BoxParticleEmitter implements IParticleEmitterType {
  85388. /**
  85389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85390. */
  85391. direction1: Vector3;
  85392. /**
  85393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85394. */
  85395. direction2: Vector3;
  85396. /**
  85397. * 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.
  85398. */
  85399. minEmitBox: Vector3;
  85400. /**
  85401. * 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.
  85402. */
  85403. maxEmitBox: Vector3;
  85404. /**
  85405. * Creates a new instance BoxParticleEmitter
  85406. */
  85407. constructor();
  85408. /**
  85409. * Called by the particle System when the direction is computed for the created particle.
  85410. * @param worldMatrix is the world matrix of the particle system
  85411. * @param directionToUpdate is the direction vector to update with the result
  85412. * @param particle is the particle we are computed the direction for
  85413. */
  85414. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85415. /**
  85416. * Called by the particle System when the position is computed for the created particle.
  85417. * @param worldMatrix is the world matrix of the particle system
  85418. * @param positionToUpdate is the position vector to update with the result
  85419. * @param particle is the particle we are computed the position for
  85420. */
  85421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85422. /**
  85423. * Clones the current emitter and returns a copy of it
  85424. * @returns the new emitter
  85425. */
  85426. clone(): BoxParticleEmitter;
  85427. /**
  85428. * Called by the GPUParticleSystem to setup the update shader
  85429. * @param effect defines the update shader
  85430. */
  85431. applyToShader(effect: Effect): void;
  85432. /**
  85433. * Returns a string to use to update the GPU particles update shader
  85434. * @returns a string containng the defines string
  85435. */
  85436. getEffectDefines(): string;
  85437. /**
  85438. * Returns the string "BoxParticleEmitter"
  85439. * @returns a string containing the class name
  85440. */
  85441. getClassName(): string;
  85442. /**
  85443. * Serializes the particle system to a JSON object.
  85444. * @returns the JSON object
  85445. */
  85446. serialize(): any;
  85447. /**
  85448. * Parse properties from a JSON object
  85449. * @param serializationObject defines the JSON object
  85450. */
  85451. parse(serializationObject: any): void;
  85452. }
  85453. }
  85454. declare module BABYLON {
  85455. /**
  85456. * Particle emitter emitting particles from the inside of a cone.
  85457. * It emits the particles alongside the cone volume from the base to the particle.
  85458. * The emission direction might be randomized.
  85459. */
  85460. export class ConeParticleEmitter implements IParticleEmitterType {
  85461. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85462. directionRandomizer: number;
  85463. private _radius;
  85464. private _angle;
  85465. private _height;
  85466. /**
  85467. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85468. */
  85469. radiusRange: number;
  85470. /**
  85471. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85472. */
  85473. heightRange: number;
  85474. /**
  85475. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85476. */
  85477. emitFromSpawnPointOnly: boolean;
  85478. /**
  85479. * Gets or sets the radius of the emission cone
  85480. */
  85481. get radius(): number;
  85482. set radius(value: number);
  85483. /**
  85484. * Gets or sets the angle of the emission cone
  85485. */
  85486. get angle(): number;
  85487. set angle(value: number);
  85488. private _buildHeight;
  85489. /**
  85490. * Creates a new instance ConeParticleEmitter
  85491. * @param radius the radius of the emission cone (1 by default)
  85492. * @param angle the cone base angle (PI by default)
  85493. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85494. */
  85495. constructor(radius?: number, angle?: number,
  85496. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85497. directionRandomizer?: number);
  85498. /**
  85499. * Called by the particle System when the direction is computed for the created particle.
  85500. * @param worldMatrix is the world matrix of the particle system
  85501. * @param directionToUpdate is the direction vector to update with the result
  85502. * @param particle is the particle we are computed the direction for
  85503. */
  85504. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85505. /**
  85506. * Called by the particle System when the position is computed for the created particle.
  85507. * @param worldMatrix is the world matrix of the particle system
  85508. * @param positionToUpdate is the position vector to update with the result
  85509. * @param particle is the particle we are computed the position for
  85510. */
  85511. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85512. /**
  85513. * Clones the current emitter and returns a copy of it
  85514. * @returns the new emitter
  85515. */
  85516. clone(): ConeParticleEmitter;
  85517. /**
  85518. * Called by the GPUParticleSystem to setup the update shader
  85519. * @param effect defines the update shader
  85520. */
  85521. applyToShader(effect: Effect): void;
  85522. /**
  85523. * Returns a string to use to update the GPU particles update shader
  85524. * @returns a string containng the defines string
  85525. */
  85526. getEffectDefines(): string;
  85527. /**
  85528. * Returns the string "ConeParticleEmitter"
  85529. * @returns a string containing the class name
  85530. */
  85531. getClassName(): string;
  85532. /**
  85533. * Serializes the particle system to a JSON object.
  85534. * @returns the JSON object
  85535. */
  85536. serialize(): any;
  85537. /**
  85538. * Parse properties from a JSON object
  85539. * @param serializationObject defines the JSON object
  85540. */
  85541. parse(serializationObject: any): void;
  85542. }
  85543. }
  85544. declare module BABYLON {
  85545. /**
  85546. * Particle emitter emitting particles from the inside of a cylinder.
  85547. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85548. */
  85549. export class CylinderParticleEmitter implements IParticleEmitterType {
  85550. /**
  85551. * The radius of the emission cylinder.
  85552. */
  85553. radius: number;
  85554. /**
  85555. * The height of the emission cylinder.
  85556. */
  85557. height: number;
  85558. /**
  85559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85560. */
  85561. radiusRange: number;
  85562. /**
  85563. * How much to randomize the particle direction [0-1].
  85564. */
  85565. directionRandomizer: number;
  85566. /**
  85567. * Creates a new instance CylinderParticleEmitter
  85568. * @param radius the radius of the emission cylinder (1 by default)
  85569. * @param height the height of the emission cylinder (1 by default)
  85570. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85571. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85572. */
  85573. constructor(
  85574. /**
  85575. * The radius of the emission cylinder.
  85576. */
  85577. radius?: number,
  85578. /**
  85579. * The height of the emission cylinder.
  85580. */
  85581. height?: number,
  85582. /**
  85583. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85584. */
  85585. radiusRange?: number,
  85586. /**
  85587. * How much to randomize the particle direction [0-1].
  85588. */
  85589. directionRandomizer?: number);
  85590. /**
  85591. * Called by the particle System when the direction is computed for the created particle.
  85592. * @param worldMatrix is the world matrix of the particle system
  85593. * @param directionToUpdate is the direction vector to update with the result
  85594. * @param particle is the particle we are computed the direction for
  85595. */
  85596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85597. /**
  85598. * Called by the particle System when the position is computed for the created particle.
  85599. * @param worldMatrix is the world matrix of the particle system
  85600. * @param positionToUpdate is the position vector to update with the result
  85601. * @param particle is the particle we are computed the position for
  85602. */
  85603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85604. /**
  85605. * Clones the current emitter and returns a copy of it
  85606. * @returns the new emitter
  85607. */
  85608. clone(): CylinderParticleEmitter;
  85609. /**
  85610. * Called by the GPUParticleSystem to setup the update shader
  85611. * @param effect defines the update shader
  85612. */
  85613. applyToShader(effect: Effect): void;
  85614. /**
  85615. * Returns a string to use to update the GPU particles update shader
  85616. * @returns a string containng the defines string
  85617. */
  85618. getEffectDefines(): string;
  85619. /**
  85620. * Returns the string "CylinderParticleEmitter"
  85621. * @returns a string containing the class name
  85622. */
  85623. getClassName(): string;
  85624. /**
  85625. * Serializes the particle system to a JSON object.
  85626. * @returns the JSON object
  85627. */
  85628. serialize(): any;
  85629. /**
  85630. * Parse properties from a JSON object
  85631. * @param serializationObject defines the JSON object
  85632. */
  85633. parse(serializationObject: any): void;
  85634. }
  85635. /**
  85636. * Particle emitter emitting particles from the inside of a cylinder.
  85637. * It emits the particles randomly between two vectors.
  85638. */
  85639. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85640. /**
  85641. * The min limit of the emission direction.
  85642. */
  85643. direction1: Vector3;
  85644. /**
  85645. * The max limit of the emission direction.
  85646. */
  85647. direction2: Vector3;
  85648. /**
  85649. * Creates a new instance CylinderDirectedParticleEmitter
  85650. * @param radius the radius of the emission cylinder (1 by default)
  85651. * @param height the height of the emission cylinder (1 by default)
  85652. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85653. * @param direction1 the min limit of the emission direction (up vector by default)
  85654. * @param direction2 the max limit of the emission direction (up vector by default)
  85655. */
  85656. constructor(radius?: number, height?: number, radiusRange?: number,
  85657. /**
  85658. * The min limit of the emission direction.
  85659. */
  85660. direction1?: Vector3,
  85661. /**
  85662. * The max limit of the emission direction.
  85663. */
  85664. direction2?: Vector3);
  85665. /**
  85666. * Called by the particle System when the direction is computed for the created particle.
  85667. * @param worldMatrix is the world matrix of the particle system
  85668. * @param directionToUpdate is the direction vector to update with the result
  85669. * @param particle is the particle we are computed the direction for
  85670. */
  85671. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85672. /**
  85673. * Clones the current emitter and returns a copy of it
  85674. * @returns the new emitter
  85675. */
  85676. clone(): CylinderDirectedParticleEmitter;
  85677. /**
  85678. * Called by the GPUParticleSystem to setup the update shader
  85679. * @param effect defines the update shader
  85680. */
  85681. applyToShader(effect: Effect): void;
  85682. /**
  85683. * Returns a string to use to update the GPU particles update shader
  85684. * @returns a string containng the defines string
  85685. */
  85686. getEffectDefines(): string;
  85687. /**
  85688. * Returns the string "CylinderDirectedParticleEmitter"
  85689. * @returns a string containing the class name
  85690. */
  85691. getClassName(): string;
  85692. /**
  85693. * Serializes the particle system to a JSON object.
  85694. * @returns the JSON object
  85695. */
  85696. serialize(): any;
  85697. /**
  85698. * Parse properties from a JSON object
  85699. * @param serializationObject defines the JSON object
  85700. */
  85701. parse(serializationObject: any): void;
  85702. }
  85703. }
  85704. declare module BABYLON {
  85705. /**
  85706. * Particle emitter emitting particles from the inside of a hemisphere.
  85707. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85708. */
  85709. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85710. /**
  85711. * The radius of the emission hemisphere.
  85712. */
  85713. radius: number;
  85714. /**
  85715. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85716. */
  85717. radiusRange: number;
  85718. /**
  85719. * How much to randomize the particle direction [0-1].
  85720. */
  85721. directionRandomizer: number;
  85722. /**
  85723. * Creates a new instance HemisphericParticleEmitter
  85724. * @param radius the radius of the emission hemisphere (1 by default)
  85725. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85726. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85727. */
  85728. constructor(
  85729. /**
  85730. * The radius of the emission hemisphere.
  85731. */
  85732. radius?: number,
  85733. /**
  85734. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85735. */
  85736. radiusRange?: number,
  85737. /**
  85738. * How much to randomize the particle direction [0-1].
  85739. */
  85740. directionRandomizer?: number);
  85741. /**
  85742. * Called by the particle System when the direction is computed for the created particle.
  85743. * @param worldMatrix is the world matrix of the particle system
  85744. * @param directionToUpdate is the direction vector to update with the result
  85745. * @param particle is the particle we are computed the direction for
  85746. */
  85747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85748. /**
  85749. * Called by the particle System when the position is computed for the created particle.
  85750. * @param worldMatrix is the world matrix of the particle system
  85751. * @param positionToUpdate is the position vector to update with the result
  85752. * @param particle is the particle we are computed the position for
  85753. */
  85754. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85755. /**
  85756. * Clones the current emitter and returns a copy of it
  85757. * @returns the new emitter
  85758. */
  85759. clone(): HemisphericParticleEmitter;
  85760. /**
  85761. * Called by the GPUParticleSystem to setup the update shader
  85762. * @param effect defines the update shader
  85763. */
  85764. applyToShader(effect: Effect): void;
  85765. /**
  85766. * Returns a string to use to update the GPU particles update shader
  85767. * @returns a string containng the defines string
  85768. */
  85769. getEffectDefines(): string;
  85770. /**
  85771. * Returns the string "HemisphericParticleEmitter"
  85772. * @returns a string containing the class name
  85773. */
  85774. getClassName(): string;
  85775. /**
  85776. * Serializes the particle system to a JSON object.
  85777. * @returns the JSON object
  85778. */
  85779. serialize(): any;
  85780. /**
  85781. * Parse properties from a JSON object
  85782. * @param serializationObject defines the JSON object
  85783. */
  85784. parse(serializationObject: any): void;
  85785. }
  85786. }
  85787. declare module BABYLON {
  85788. /**
  85789. * Particle emitter emitting particles from a point.
  85790. * It emits the particles randomly between 2 given directions.
  85791. */
  85792. export class PointParticleEmitter implements IParticleEmitterType {
  85793. /**
  85794. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85795. */
  85796. direction1: Vector3;
  85797. /**
  85798. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85799. */
  85800. direction2: Vector3;
  85801. /**
  85802. * Creates a new instance PointParticleEmitter
  85803. */
  85804. constructor();
  85805. /**
  85806. * Called by the particle System when the direction is computed for the created particle.
  85807. * @param worldMatrix is the world matrix of the particle system
  85808. * @param directionToUpdate is the direction vector to update with the result
  85809. * @param particle is the particle we are computed the direction for
  85810. */
  85811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85812. /**
  85813. * Called by the particle System when the position is computed for the created particle.
  85814. * @param worldMatrix is the world matrix of the particle system
  85815. * @param positionToUpdate is the position vector to update with the result
  85816. * @param particle is the particle we are computed the position for
  85817. */
  85818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85819. /**
  85820. * Clones the current emitter and returns a copy of it
  85821. * @returns the new emitter
  85822. */
  85823. clone(): PointParticleEmitter;
  85824. /**
  85825. * Called by the GPUParticleSystem to setup the update shader
  85826. * @param effect defines the update shader
  85827. */
  85828. applyToShader(effect: Effect): void;
  85829. /**
  85830. * Returns a string to use to update the GPU particles update shader
  85831. * @returns a string containng the defines string
  85832. */
  85833. getEffectDefines(): string;
  85834. /**
  85835. * Returns the string "PointParticleEmitter"
  85836. * @returns a string containing the class name
  85837. */
  85838. getClassName(): string;
  85839. /**
  85840. * Serializes the particle system to a JSON object.
  85841. * @returns the JSON object
  85842. */
  85843. serialize(): any;
  85844. /**
  85845. * Parse properties from a JSON object
  85846. * @param serializationObject defines the JSON object
  85847. */
  85848. parse(serializationObject: any): void;
  85849. }
  85850. }
  85851. declare module BABYLON {
  85852. /**
  85853. * Particle emitter emitting particles from the inside of a sphere.
  85854. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85855. */
  85856. export class SphereParticleEmitter implements IParticleEmitterType {
  85857. /**
  85858. * The radius of the emission sphere.
  85859. */
  85860. radius: number;
  85861. /**
  85862. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85863. */
  85864. radiusRange: number;
  85865. /**
  85866. * How much to randomize the particle direction [0-1].
  85867. */
  85868. directionRandomizer: number;
  85869. /**
  85870. * Creates a new instance SphereParticleEmitter
  85871. * @param radius the radius of the emission sphere (1 by default)
  85872. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85873. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85874. */
  85875. constructor(
  85876. /**
  85877. * The radius of the emission sphere.
  85878. */
  85879. radius?: number,
  85880. /**
  85881. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85882. */
  85883. radiusRange?: number,
  85884. /**
  85885. * How much to randomize the particle direction [0-1].
  85886. */
  85887. directionRandomizer?: number);
  85888. /**
  85889. * Called by the particle System when the direction is computed for the created particle.
  85890. * @param worldMatrix is the world matrix of the particle system
  85891. * @param directionToUpdate is the direction vector to update with the result
  85892. * @param particle is the particle we are computed the direction for
  85893. */
  85894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85895. /**
  85896. * Called by the particle System when the position is computed for the created particle.
  85897. * @param worldMatrix is the world matrix of the particle system
  85898. * @param positionToUpdate is the position vector to update with the result
  85899. * @param particle is the particle we are computed the position for
  85900. */
  85901. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85902. /**
  85903. * Clones the current emitter and returns a copy of it
  85904. * @returns the new emitter
  85905. */
  85906. clone(): SphereParticleEmitter;
  85907. /**
  85908. * Called by the GPUParticleSystem to setup the update shader
  85909. * @param effect defines the update shader
  85910. */
  85911. applyToShader(effect: Effect): void;
  85912. /**
  85913. * Returns a string to use to update the GPU particles update shader
  85914. * @returns a string containng the defines string
  85915. */
  85916. getEffectDefines(): string;
  85917. /**
  85918. * Returns the string "SphereParticleEmitter"
  85919. * @returns a string containing the class name
  85920. */
  85921. getClassName(): string;
  85922. /**
  85923. * Serializes the particle system to a JSON object.
  85924. * @returns the JSON object
  85925. */
  85926. serialize(): any;
  85927. /**
  85928. * Parse properties from a JSON object
  85929. * @param serializationObject defines the JSON object
  85930. */
  85931. parse(serializationObject: any): void;
  85932. }
  85933. /**
  85934. * Particle emitter emitting particles from the inside of a sphere.
  85935. * It emits the particles randomly between two vectors.
  85936. */
  85937. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85938. /**
  85939. * The min limit of the emission direction.
  85940. */
  85941. direction1: Vector3;
  85942. /**
  85943. * The max limit of the emission direction.
  85944. */
  85945. direction2: Vector3;
  85946. /**
  85947. * Creates a new instance SphereDirectedParticleEmitter
  85948. * @param radius the radius of the emission sphere (1 by default)
  85949. * @param direction1 the min limit of the emission direction (up vector by default)
  85950. * @param direction2 the max limit of the emission direction (up vector by default)
  85951. */
  85952. constructor(radius?: number,
  85953. /**
  85954. * The min limit of the emission direction.
  85955. */
  85956. direction1?: Vector3,
  85957. /**
  85958. * The max limit of the emission direction.
  85959. */
  85960. direction2?: Vector3);
  85961. /**
  85962. * Called by the particle System when the direction is computed for the created particle.
  85963. * @param worldMatrix is the world matrix of the particle system
  85964. * @param directionToUpdate is the direction vector to update with the result
  85965. * @param particle is the particle we are computed the direction for
  85966. */
  85967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85968. /**
  85969. * Clones the current emitter and returns a copy of it
  85970. * @returns the new emitter
  85971. */
  85972. clone(): SphereDirectedParticleEmitter;
  85973. /**
  85974. * Called by the GPUParticleSystem to setup the update shader
  85975. * @param effect defines the update shader
  85976. */
  85977. applyToShader(effect: Effect): void;
  85978. /**
  85979. * Returns a string to use to update the GPU particles update shader
  85980. * @returns a string containng the defines string
  85981. */
  85982. getEffectDefines(): string;
  85983. /**
  85984. * Returns the string "SphereDirectedParticleEmitter"
  85985. * @returns a string containing the class name
  85986. */
  85987. getClassName(): string;
  85988. /**
  85989. * Serializes the particle system to a JSON object.
  85990. * @returns the JSON object
  85991. */
  85992. serialize(): any;
  85993. /**
  85994. * Parse properties from a JSON object
  85995. * @param serializationObject defines the JSON object
  85996. */
  85997. parse(serializationObject: any): void;
  85998. }
  85999. }
  86000. declare module BABYLON {
  86001. /**
  86002. * Particle emitter emitting particles from a custom list of positions.
  86003. */
  86004. export class CustomParticleEmitter implements IParticleEmitterType {
  86005. /**
  86006. * Gets or sets the position generator that will create the inital position of each particle.
  86007. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86008. */
  86009. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86010. /**
  86011. * Gets or sets the destination generator that will create the final destination of each particle.
  86012. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86013. */
  86014. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86015. /**
  86016. * Creates a new instance CustomParticleEmitter
  86017. */
  86018. constructor();
  86019. /**
  86020. * Called by the particle System when the direction is computed for the created particle.
  86021. * @param worldMatrix is the world matrix of the particle system
  86022. * @param directionToUpdate is the direction vector to update with the result
  86023. * @param particle is the particle we are computed the direction for
  86024. */
  86025. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86026. /**
  86027. * Called by the particle System when the position is computed for the created particle.
  86028. * @param worldMatrix is the world matrix of the particle system
  86029. * @param positionToUpdate is the position vector to update with the result
  86030. * @param particle is the particle we are computed the position for
  86031. */
  86032. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86033. /**
  86034. * Clones the current emitter and returns a copy of it
  86035. * @returns the new emitter
  86036. */
  86037. clone(): CustomParticleEmitter;
  86038. /**
  86039. * Called by the GPUParticleSystem to setup the update shader
  86040. * @param effect defines the update shader
  86041. */
  86042. applyToShader(effect: Effect): void;
  86043. /**
  86044. * Returns a string to use to update the GPU particles update shader
  86045. * @returns a string containng the defines string
  86046. */
  86047. getEffectDefines(): string;
  86048. /**
  86049. * Returns the string "PointParticleEmitter"
  86050. * @returns a string containing the class name
  86051. */
  86052. getClassName(): string;
  86053. /**
  86054. * Serializes the particle system to a JSON object.
  86055. * @returns the JSON object
  86056. */
  86057. serialize(): any;
  86058. /**
  86059. * Parse properties from a JSON object
  86060. * @param serializationObject defines the JSON object
  86061. */
  86062. parse(serializationObject: any): void;
  86063. }
  86064. }
  86065. declare module BABYLON {
  86066. /**
  86067. * Particle emitter emitting particles from the inside of a box.
  86068. * It emits the particles randomly between 2 given directions.
  86069. */
  86070. export class MeshParticleEmitter implements IParticleEmitterType {
  86071. /** Defines the mesh to use as source */
  86072. mesh?: AbstractMesh | undefined;
  86073. private _indices;
  86074. private _positions;
  86075. private _normals;
  86076. private _storedNormal;
  86077. /**
  86078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86079. */
  86080. direction1: Vector3;
  86081. /**
  86082. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86083. */
  86084. direction2: Vector3;
  86085. /**
  86086. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86087. */
  86088. useMeshNormalsForDirection: boolean;
  86089. /**
  86090. * Creates a new instance MeshParticleEmitter
  86091. * @param mesh defines the mesh to use as source
  86092. */
  86093. constructor(
  86094. /** Defines the mesh to use as source */
  86095. mesh?: AbstractMesh | undefined);
  86096. /**
  86097. * Called by the particle System when the direction is computed for the created particle.
  86098. * @param worldMatrix is the world matrix of the particle system
  86099. * @param directionToUpdate is the direction vector to update with the result
  86100. * @param particle is the particle we are computed the direction for
  86101. */
  86102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86103. /**
  86104. * Called by the particle System when the position is computed for the created particle.
  86105. * @param worldMatrix is the world matrix of the particle system
  86106. * @param positionToUpdate is the position vector to update with the result
  86107. * @param particle is the particle we are computed the position for
  86108. */
  86109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86110. /**
  86111. * Clones the current emitter and returns a copy of it
  86112. * @returns the new emitter
  86113. */
  86114. clone(): MeshParticleEmitter;
  86115. /**
  86116. * Called by the GPUParticleSystem to setup the update shader
  86117. * @param effect defines the update shader
  86118. */
  86119. applyToShader(effect: Effect): void;
  86120. /**
  86121. * Returns a string to use to update the GPU particles update shader
  86122. * @returns a string containng the defines string
  86123. */
  86124. getEffectDefines(): string;
  86125. /**
  86126. * Returns the string "BoxParticleEmitter"
  86127. * @returns a string containing the class name
  86128. */
  86129. getClassName(): string;
  86130. /**
  86131. * Serializes the particle system to a JSON object.
  86132. * @returns the JSON object
  86133. */
  86134. serialize(): any;
  86135. /**
  86136. * Parse properties from a JSON object
  86137. * @param serializationObject defines the JSON object
  86138. * @param scene defines the hosting scene
  86139. */
  86140. parse(serializationObject: any, scene: Scene): void;
  86141. }
  86142. }
  86143. declare module BABYLON {
  86144. /**
  86145. * Interface representing a particle system in Babylon.js.
  86146. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86147. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86148. */
  86149. export interface IParticleSystem {
  86150. /**
  86151. * List of animations used by the particle system.
  86152. */
  86153. animations: Animation[];
  86154. /**
  86155. * The id of the Particle system.
  86156. */
  86157. id: string;
  86158. /**
  86159. * The name of the Particle system.
  86160. */
  86161. name: string;
  86162. /**
  86163. * The emitter represents the Mesh or position we are attaching the particle system to.
  86164. */
  86165. emitter: Nullable<AbstractMesh | Vector3>;
  86166. /**
  86167. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86168. */
  86169. isBillboardBased: boolean;
  86170. /**
  86171. * The rendering group used by the Particle system to chose when to render.
  86172. */
  86173. renderingGroupId: number;
  86174. /**
  86175. * The layer mask we are rendering the particles through.
  86176. */
  86177. layerMask: number;
  86178. /**
  86179. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86180. */
  86181. updateSpeed: number;
  86182. /**
  86183. * The amount of time the particle system is running (depends of the overall update speed).
  86184. */
  86185. targetStopDuration: number;
  86186. /**
  86187. * The texture used to render each particle. (this can be a spritesheet)
  86188. */
  86189. particleTexture: Nullable<Texture>;
  86190. /**
  86191. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86192. */
  86193. blendMode: number;
  86194. /**
  86195. * Minimum life time of emitting particles.
  86196. */
  86197. minLifeTime: number;
  86198. /**
  86199. * Maximum life time of emitting particles.
  86200. */
  86201. maxLifeTime: number;
  86202. /**
  86203. * Minimum Size of emitting particles.
  86204. */
  86205. minSize: number;
  86206. /**
  86207. * Maximum Size of emitting particles.
  86208. */
  86209. maxSize: number;
  86210. /**
  86211. * Minimum scale of emitting particles on X axis.
  86212. */
  86213. minScaleX: number;
  86214. /**
  86215. * Maximum scale of emitting particles on X axis.
  86216. */
  86217. maxScaleX: number;
  86218. /**
  86219. * Minimum scale of emitting particles on Y axis.
  86220. */
  86221. minScaleY: number;
  86222. /**
  86223. * Maximum scale of emitting particles on Y axis.
  86224. */
  86225. maxScaleY: number;
  86226. /**
  86227. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86228. */
  86229. color1: Color4;
  86230. /**
  86231. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86232. */
  86233. color2: Color4;
  86234. /**
  86235. * Color the particle will have at the end of its lifetime.
  86236. */
  86237. colorDead: Color4;
  86238. /**
  86239. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86240. */
  86241. emitRate: number;
  86242. /**
  86243. * You can use gravity if you want to give an orientation to your particles.
  86244. */
  86245. gravity: Vector3;
  86246. /**
  86247. * Minimum power of emitting particles.
  86248. */
  86249. minEmitPower: number;
  86250. /**
  86251. * Maximum power of emitting particles.
  86252. */
  86253. maxEmitPower: number;
  86254. /**
  86255. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86256. */
  86257. minAngularSpeed: number;
  86258. /**
  86259. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86260. */
  86261. maxAngularSpeed: number;
  86262. /**
  86263. * Gets or sets the minimal initial rotation in radians.
  86264. */
  86265. minInitialRotation: number;
  86266. /**
  86267. * Gets or sets the maximal initial rotation in radians.
  86268. */
  86269. maxInitialRotation: number;
  86270. /**
  86271. * The particle emitter type defines the emitter used by the particle system.
  86272. * It can be for example box, sphere, or cone...
  86273. */
  86274. particleEmitterType: Nullable<IParticleEmitterType>;
  86275. /**
  86276. * Defines the delay in milliseconds before starting the system (0 by default)
  86277. */
  86278. startDelay: number;
  86279. /**
  86280. * 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
  86281. */
  86282. preWarmCycles: number;
  86283. /**
  86284. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86285. */
  86286. preWarmStepOffset: number;
  86287. /**
  86288. * 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)
  86289. */
  86290. spriteCellChangeSpeed: number;
  86291. /**
  86292. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86293. */
  86294. startSpriteCellID: number;
  86295. /**
  86296. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86297. */
  86298. endSpriteCellID: number;
  86299. /**
  86300. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86301. */
  86302. spriteCellWidth: number;
  86303. /**
  86304. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86305. */
  86306. spriteCellHeight: number;
  86307. /**
  86308. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86309. */
  86310. spriteRandomStartCell: boolean;
  86311. /**
  86312. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86313. */
  86314. isAnimationSheetEnabled: boolean;
  86315. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86316. translationPivot: Vector2;
  86317. /**
  86318. * Gets or sets a texture used to add random noise to particle positions
  86319. */
  86320. noiseTexture: Nullable<BaseTexture>;
  86321. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86322. noiseStrength: Vector3;
  86323. /**
  86324. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86325. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86326. */
  86327. billboardMode: number;
  86328. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86329. limitVelocityDamping: number;
  86330. /**
  86331. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86332. */
  86333. beginAnimationOnStart: boolean;
  86334. /**
  86335. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86336. */
  86337. beginAnimationFrom: number;
  86338. /**
  86339. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86340. */
  86341. beginAnimationTo: number;
  86342. /**
  86343. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86344. */
  86345. beginAnimationLoop: boolean;
  86346. /**
  86347. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86348. */
  86349. disposeOnStop: boolean;
  86350. /**
  86351. * Gets the maximum number of particles active at the same time.
  86352. * @returns The max number of active particles.
  86353. */
  86354. getCapacity(): number;
  86355. /**
  86356. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86357. * @returns True if it has been started, otherwise false.
  86358. */
  86359. isStarted(): boolean;
  86360. /**
  86361. * Animates the particle system for this frame.
  86362. */
  86363. animate(): void;
  86364. /**
  86365. * Renders the particle system in its current state.
  86366. * @returns the current number of particles
  86367. */
  86368. render(): number;
  86369. /**
  86370. * Dispose the particle system and frees its associated resources.
  86371. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86372. */
  86373. dispose(disposeTexture?: boolean): void;
  86374. /**
  86375. * Clones the particle system.
  86376. * @param name The name of the cloned object
  86377. * @param newEmitter The new emitter to use
  86378. * @returns the cloned particle system
  86379. */
  86380. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86381. /**
  86382. * Serializes the particle system to a JSON object.
  86383. * @returns the JSON object
  86384. */
  86385. serialize(): any;
  86386. /**
  86387. * Rebuild the particle system
  86388. */
  86389. rebuild(): void;
  86390. /**
  86391. * Starts the particle system and begins to emit
  86392. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86393. */
  86394. start(delay?: number): void;
  86395. /**
  86396. * Stops the particle system.
  86397. */
  86398. stop(): void;
  86399. /**
  86400. * Remove all active particles
  86401. */
  86402. reset(): void;
  86403. /**
  86404. * Is this system ready to be used/rendered
  86405. * @return true if the system is ready
  86406. */
  86407. isReady(): boolean;
  86408. /**
  86409. * Adds a new color gradient
  86410. * @param gradient defines the gradient to use (between 0 and 1)
  86411. * @param color1 defines the color to affect to the specified gradient
  86412. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86413. * @returns the current particle system
  86414. */
  86415. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86416. /**
  86417. * Remove a specific color gradient
  86418. * @param gradient defines the gradient to remove
  86419. * @returns the current particle system
  86420. */
  86421. removeColorGradient(gradient: number): IParticleSystem;
  86422. /**
  86423. * Adds a new size gradient
  86424. * @param gradient defines the gradient to use (between 0 and 1)
  86425. * @param factor defines the size factor to affect to the specified gradient
  86426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86427. * @returns the current particle system
  86428. */
  86429. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86430. /**
  86431. * Remove a specific size gradient
  86432. * @param gradient defines the gradient to remove
  86433. * @returns the current particle system
  86434. */
  86435. removeSizeGradient(gradient: number): IParticleSystem;
  86436. /**
  86437. * Gets the current list of color gradients.
  86438. * You must use addColorGradient and removeColorGradient to udpate this list
  86439. * @returns the list of color gradients
  86440. */
  86441. getColorGradients(): Nullable<Array<ColorGradient>>;
  86442. /**
  86443. * Gets the current list of size gradients.
  86444. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86445. * @returns the list of size gradients
  86446. */
  86447. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86448. /**
  86449. * Gets the current list of angular speed gradients.
  86450. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86451. * @returns the list of angular speed gradients
  86452. */
  86453. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86454. /**
  86455. * Adds a new angular speed gradient
  86456. * @param gradient defines the gradient to use (between 0 and 1)
  86457. * @param factor defines the angular speed to affect to the specified gradient
  86458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86459. * @returns the current particle system
  86460. */
  86461. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86462. /**
  86463. * Remove a specific angular speed gradient
  86464. * @param gradient defines the gradient to remove
  86465. * @returns the current particle system
  86466. */
  86467. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86468. /**
  86469. * Gets the current list of velocity gradients.
  86470. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86471. * @returns the list of velocity gradients
  86472. */
  86473. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86474. /**
  86475. * Adds a new velocity gradient
  86476. * @param gradient defines the gradient to use (between 0 and 1)
  86477. * @param factor defines the velocity to affect to the specified gradient
  86478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86479. * @returns the current particle system
  86480. */
  86481. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86482. /**
  86483. * Remove a specific velocity gradient
  86484. * @param gradient defines the gradient to remove
  86485. * @returns the current particle system
  86486. */
  86487. removeVelocityGradient(gradient: number): IParticleSystem;
  86488. /**
  86489. * Gets the current list of limit velocity gradients.
  86490. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86491. * @returns the list of limit velocity gradients
  86492. */
  86493. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86494. /**
  86495. * Adds a new limit velocity gradient
  86496. * @param gradient defines the gradient to use (between 0 and 1)
  86497. * @param factor defines the limit velocity to affect to the specified gradient
  86498. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86499. * @returns the current particle system
  86500. */
  86501. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86502. /**
  86503. * Remove a specific limit velocity gradient
  86504. * @param gradient defines the gradient to remove
  86505. * @returns the current particle system
  86506. */
  86507. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86508. /**
  86509. * Adds a new drag gradient
  86510. * @param gradient defines the gradient to use (between 0 and 1)
  86511. * @param factor defines the drag to affect to the specified gradient
  86512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86513. * @returns the current particle system
  86514. */
  86515. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86516. /**
  86517. * Remove a specific drag gradient
  86518. * @param gradient defines the gradient to remove
  86519. * @returns the current particle system
  86520. */
  86521. removeDragGradient(gradient: number): IParticleSystem;
  86522. /**
  86523. * Gets the current list of drag gradients.
  86524. * You must use addDragGradient and removeDragGradient to udpate this list
  86525. * @returns the list of drag gradients
  86526. */
  86527. getDragGradients(): Nullable<Array<FactorGradient>>;
  86528. /**
  86529. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86530. * @param gradient defines the gradient to use (between 0 and 1)
  86531. * @param factor defines the emit rate to affect to the specified gradient
  86532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86533. * @returns the current particle system
  86534. */
  86535. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86536. /**
  86537. * Remove a specific emit rate gradient
  86538. * @param gradient defines the gradient to remove
  86539. * @returns the current particle system
  86540. */
  86541. removeEmitRateGradient(gradient: number): IParticleSystem;
  86542. /**
  86543. * Gets the current list of emit rate gradients.
  86544. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86545. * @returns the list of emit rate gradients
  86546. */
  86547. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86548. /**
  86549. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86550. * @param gradient defines the gradient to use (between 0 and 1)
  86551. * @param factor defines the start size to affect to the specified gradient
  86552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86553. * @returns the current particle system
  86554. */
  86555. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86556. /**
  86557. * Remove a specific start size gradient
  86558. * @param gradient defines the gradient to remove
  86559. * @returns the current particle system
  86560. */
  86561. removeStartSizeGradient(gradient: number): IParticleSystem;
  86562. /**
  86563. * Gets the current list of start size gradients.
  86564. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86565. * @returns the list of start size gradients
  86566. */
  86567. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86568. /**
  86569. * Adds a new life time gradient
  86570. * @param gradient defines the gradient to use (between 0 and 1)
  86571. * @param factor defines the life time factor to affect to the specified gradient
  86572. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86573. * @returns the current particle system
  86574. */
  86575. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86576. /**
  86577. * Remove a specific life time gradient
  86578. * @param gradient defines the gradient to remove
  86579. * @returns the current particle system
  86580. */
  86581. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86582. /**
  86583. * Gets the current list of life time gradients.
  86584. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86585. * @returns the list of life time gradients
  86586. */
  86587. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86588. /**
  86589. * Gets the current list of color gradients.
  86590. * You must use addColorGradient and removeColorGradient to udpate this list
  86591. * @returns the list of color gradients
  86592. */
  86593. getColorGradients(): Nullable<Array<ColorGradient>>;
  86594. /**
  86595. * Adds a new ramp gradient used to remap particle colors
  86596. * @param gradient defines the gradient to use (between 0 and 1)
  86597. * @param color defines the color to affect to the specified gradient
  86598. * @returns the current particle system
  86599. */
  86600. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86601. /**
  86602. * Gets the current list of ramp gradients.
  86603. * You must use addRampGradient and removeRampGradient to udpate this list
  86604. * @returns the list of ramp gradients
  86605. */
  86606. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86607. /** Gets or sets a boolean indicating that ramp gradients must be used
  86608. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86609. */
  86610. useRampGradients: boolean;
  86611. /**
  86612. * Adds a new color remap gradient
  86613. * @param gradient defines the gradient to use (between 0 and 1)
  86614. * @param min defines the color remap minimal range
  86615. * @param max defines the color remap maximal range
  86616. * @returns the current particle system
  86617. */
  86618. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86619. /**
  86620. * Gets the current list of color remap gradients.
  86621. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86622. * @returns the list of color remap gradients
  86623. */
  86624. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86625. /**
  86626. * Adds a new alpha remap gradient
  86627. * @param gradient defines the gradient to use (between 0 and 1)
  86628. * @param min defines the alpha remap minimal range
  86629. * @param max defines the alpha remap maximal range
  86630. * @returns the current particle system
  86631. */
  86632. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86633. /**
  86634. * Gets the current list of alpha remap gradients.
  86635. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86636. * @returns the list of alpha remap gradients
  86637. */
  86638. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86639. /**
  86640. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86643. * @returns the emitter
  86644. */
  86645. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86646. /**
  86647. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86648. * @param radius The radius of the hemisphere to emit from
  86649. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86650. * @returns the emitter
  86651. */
  86652. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86653. /**
  86654. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86655. * @param radius The radius of the sphere to emit from
  86656. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86657. * @returns the emitter
  86658. */
  86659. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86660. /**
  86661. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86662. * @param radius The radius of the sphere to emit from
  86663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86665. * @returns the emitter
  86666. */
  86667. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86668. /**
  86669. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86670. * @param radius The radius of the emission cylinder
  86671. * @param height The height of the emission cylinder
  86672. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86673. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86674. * @returns the emitter
  86675. */
  86676. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86677. /**
  86678. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86679. * @param radius The radius of the cylinder to emit from
  86680. * @param height The height of the emission cylinder
  86681. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86682. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86683. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86684. * @returns the emitter
  86685. */
  86686. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86687. /**
  86688. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86689. * @param radius The radius of the cone to emit from
  86690. * @param angle The base angle of the cone
  86691. * @returns the emitter
  86692. */
  86693. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86694. /**
  86695. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86698. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86699. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86700. * @returns the emitter
  86701. */
  86702. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86703. /**
  86704. * Get hosting scene
  86705. * @returns the scene
  86706. */
  86707. getScene(): Scene;
  86708. }
  86709. }
  86710. declare module BABYLON {
  86711. /**
  86712. * 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.
  86713. * @see https://doc.babylonjs.com/how_to/transformnode
  86714. */
  86715. export class TransformNode extends Node {
  86716. /**
  86717. * Object will not rotate to face the camera
  86718. */
  86719. static BILLBOARDMODE_NONE: number;
  86720. /**
  86721. * Object will rotate to face the camera but only on the x axis
  86722. */
  86723. static BILLBOARDMODE_X: number;
  86724. /**
  86725. * Object will rotate to face the camera but only on the y axis
  86726. */
  86727. static BILLBOARDMODE_Y: number;
  86728. /**
  86729. * Object will rotate to face the camera but only on the z axis
  86730. */
  86731. static BILLBOARDMODE_Z: number;
  86732. /**
  86733. * Object will rotate to face the camera
  86734. */
  86735. static BILLBOARDMODE_ALL: number;
  86736. /**
  86737. * Object will rotate to face the camera's position instead of orientation
  86738. */
  86739. static BILLBOARDMODE_USE_POSITION: number;
  86740. private _forward;
  86741. private _forwardInverted;
  86742. private _up;
  86743. private _right;
  86744. private _rightInverted;
  86745. private _position;
  86746. private _rotation;
  86747. private _rotationQuaternion;
  86748. protected _scaling: Vector3;
  86749. protected _isDirty: boolean;
  86750. private _transformToBoneReferal;
  86751. private _isAbsoluteSynced;
  86752. private _billboardMode;
  86753. /**
  86754. * Gets or sets the billboard mode. Default is 0.
  86755. *
  86756. * | Value | Type | Description |
  86757. * | --- | --- | --- |
  86758. * | 0 | BILLBOARDMODE_NONE | |
  86759. * | 1 | BILLBOARDMODE_X | |
  86760. * | 2 | BILLBOARDMODE_Y | |
  86761. * | 4 | BILLBOARDMODE_Z | |
  86762. * | 7 | BILLBOARDMODE_ALL | |
  86763. *
  86764. */
  86765. get billboardMode(): number;
  86766. set billboardMode(value: number);
  86767. private _preserveParentRotationForBillboard;
  86768. /**
  86769. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86770. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86771. */
  86772. get preserveParentRotationForBillboard(): boolean;
  86773. set preserveParentRotationForBillboard(value: boolean);
  86774. /**
  86775. * 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
  86776. */
  86777. scalingDeterminant: number;
  86778. private _infiniteDistance;
  86779. /**
  86780. * Gets or sets the distance of the object to max, often used by skybox
  86781. */
  86782. get infiniteDistance(): boolean;
  86783. set infiniteDistance(value: boolean);
  86784. /**
  86785. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86786. * By default the system will update normals to compensate
  86787. */
  86788. ignoreNonUniformScaling: boolean;
  86789. /**
  86790. * 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
  86791. */
  86792. reIntegrateRotationIntoRotationQuaternion: boolean;
  86793. /** @hidden */
  86794. _poseMatrix: Nullable<Matrix>;
  86795. /** @hidden */
  86796. _localMatrix: Matrix;
  86797. private _usePivotMatrix;
  86798. private _absolutePosition;
  86799. private _absoluteScaling;
  86800. private _absoluteRotationQuaternion;
  86801. private _pivotMatrix;
  86802. private _pivotMatrixInverse;
  86803. protected _postMultiplyPivotMatrix: boolean;
  86804. protected _isWorldMatrixFrozen: boolean;
  86805. /** @hidden */
  86806. _indexInSceneTransformNodesArray: number;
  86807. /**
  86808. * An event triggered after the world matrix is updated
  86809. */
  86810. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86811. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86812. /**
  86813. * Gets a string identifying the name of the class
  86814. * @returns "TransformNode" string
  86815. */
  86816. getClassName(): string;
  86817. /**
  86818. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86819. */
  86820. get position(): Vector3;
  86821. set position(newPosition: Vector3);
  86822. /**
  86823. * 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)).
  86824. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86825. */
  86826. get rotation(): Vector3;
  86827. set rotation(newRotation: Vector3);
  86828. /**
  86829. * 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)).
  86830. */
  86831. get scaling(): Vector3;
  86832. set scaling(newScaling: Vector3);
  86833. /**
  86834. * 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).
  86835. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86836. */
  86837. get rotationQuaternion(): Nullable<Quaternion>;
  86838. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86839. /**
  86840. * The forward direction of that transform in world space.
  86841. */
  86842. get forward(): Vector3;
  86843. /**
  86844. * The up direction of that transform in world space.
  86845. */
  86846. get up(): Vector3;
  86847. /**
  86848. * The right direction of that transform in world space.
  86849. */
  86850. get right(): Vector3;
  86851. /**
  86852. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86853. * @param matrix the matrix to copy the pose from
  86854. * @returns this TransformNode.
  86855. */
  86856. updatePoseMatrix(matrix: Matrix): TransformNode;
  86857. /**
  86858. * Returns the mesh Pose matrix.
  86859. * @returns the pose matrix
  86860. */
  86861. getPoseMatrix(): Matrix;
  86862. /** @hidden */
  86863. _isSynchronized(): boolean;
  86864. /** @hidden */
  86865. _initCache(): void;
  86866. /**
  86867. * Flag the transform node as dirty (Forcing it to update everything)
  86868. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86869. * @returns this transform node
  86870. */
  86871. markAsDirty(property: string): TransformNode;
  86872. /**
  86873. * Returns the current mesh absolute position.
  86874. * Returns a Vector3.
  86875. */
  86876. get absolutePosition(): Vector3;
  86877. /**
  86878. * Returns the current mesh absolute scaling.
  86879. * Returns a Vector3.
  86880. */
  86881. get absoluteScaling(): Vector3;
  86882. /**
  86883. * Returns the current mesh absolute rotation.
  86884. * Returns a Quaternion.
  86885. */
  86886. get absoluteRotationQuaternion(): Quaternion;
  86887. /**
  86888. * Sets a new matrix to apply before all other transformation
  86889. * @param matrix defines the transform matrix
  86890. * @returns the current TransformNode
  86891. */
  86892. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86893. /**
  86894. * Sets a new pivot matrix to the current node
  86895. * @param matrix defines the new pivot matrix to use
  86896. * @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
  86897. * @returns the current TransformNode
  86898. */
  86899. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86900. /**
  86901. * Returns the mesh pivot matrix.
  86902. * Default : Identity.
  86903. * @returns the matrix
  86904. */
  86905. getPivotMatrix(): Matrix;
  86906. /**
  86907. * Instantiate (when possible) or clone that node with its hierarchy
  86908. * @param newParent defines the new parent to use for the instance (or clone)
  86909. * @param options defines options to configure how copy is done
  86910. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86911. * @returns an instance (or a clone) of the current node with its hiearchy
  86912. */
  86913. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86914. doNotInstantiate: boolean;
  86915. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86916. /**
  86917. * Prevents the World matrix to be computed any longer
  86918. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86919. * @returns the TransformNode.
  86920. */
  86921. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86922. /**
  86923. * Allows back the World matrix computation.
  86924. * @returns the TransformNode.
  86925. */
  86926. unfreezeWorldMatrix(): this;
  86927. /**
  86928. * True if the World matrix has been frozen.
  86929. */
  86930. get isWorldMatrixFrozen(): boolean;
  86931. /**
  86932. * Retuns the mesh absolute position in the World.
  86933. * @returns a Vector3.
  86934. */
  86935. getAbsolutePosition(): Vector3;
  86936. /**
  86937. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86938. * @param absolutePosition the absolute position to set
  86939. * @returns the TransformNode.
  86940. */
  86941. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86942. /**
  86943. * Sets the mesh position in its local space.
  86944. * @param vector3 the position to set in localspace
  86945. * @returns the TransformNode.
  86946. */
  86947. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86948. /**
  86949. * Returns the mesh position in the local space from the current World matrix values.
  86950. * @returns a new Vector3.
  86951. */
  86952. getPositionExpressedInLocalSpace(): Vector3;
  86953. /**
  86954. * Translates the mesh along the passed Vector3 in its local space.
  86955. * @param vector3 the distance to translate in localspace
  86956. * @returns the TransformNode.
  86957. */
  86958. locallyTranslate(vector3: Vector3): TransformNode;
  86959. private static _lookAtVectorCache;
  86960. /**
  86961. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86962. * @param targetPoint the position (must be in same space as current mesh) to look at
  86963. * @param yawCor optional yaw (y-axis) correction in radians
  86964. * @param pitchCor optional pitch (x-axis) correction in radians
  86965. * @param rollCor optional roll (z-axis) correction in radians
  86966. * @param space the choosen space of the target
  86967. * @returns the TransformNode.
  86968. */
  86969. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86970. /**
  86971. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86972. * This Vector3 is expressed in the World space.
  86973. * @param localAxis axis to rotate
  86974. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86975. */
  86976. getDirection(localAxis: Vector3): Vector3;
  86977. /**
  86978. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86979. * localAxis is expressed in the mesh local space.
  86980. * result is computed in the Wordl space from the mesh World matrix.
  86981. * @param localAxis axis to rotate
  86982. * @param result the resulting transformnode
  86983. * @returns this TransformNode.
  86984. */
  86985. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86986. /**
  86987. * Sets this transform node rotation to the given local axis.
  86988. * @param localAxis the axis in local space
  86989. * @param yawCor optional yaw (y-axis) correction in radians
  86990. * @param pitchCor optional pitch (x-axis) correction in radians
  86991. * @param rollCor optional roll (z-axis) correction in radians
  86992. * @returns this TransformNode
  86993. */
  86994. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86995. /**
  86996. * Sets a new pivot point to the current node
  86997. * @param point defines the new pivot point to use
  86998. * @param space defines if the point is in world or local space (local by default)
  86999. * @returns the current TransformNode
  87000. */
  87001. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87002. /**
  87003. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87004. * @returns the pivot point
  87005. */
  87006. getPivotPoint(): Vector3;
  87007. /**
  87008. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87009. * @param result the vector3 to store the result
  87010. * @returns this TransformNode.
  87011. */
  87012. getPivotPointToRef(result: Vector3): TransformNode;
  87013. /**
  87014. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87015. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87016. */
  87017. getAbsolutePivotPoint(): Vector3;
  87018. /**
  87019. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87020. * @param result vector3 to store the result
  87021. * @returns this TransformNode.
  87022. */
  87023. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87024. /**
  87025. * Defines the passed node as the parent of the current node.
  87026. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87027. * @see https://doc.babylonjs.com/how_to/parenting
  87028. * @param node the node ot set as the parent
  87029. * @returns this TransformNode.
  87030. */
  87031. setParent(node: Nullable<Node>): TransformNode;
  87032. private _nonUniformScaling;
  87033. /**
  87034. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87035. */
  87036. get nonUniformScaling(): boolean;
  87037. /** @hidden */
  87038. _updateNonUniformScalingState(value: boolean): boolean;
  87039. /**
  87040. * Attach the current TransformNode to another TransformNode associated with a bone
  87041. * @param bone Bone affecting the TransformNode
  87042. * @param affectedTransformNode TransformNode associated with the bone
  87043. * @returns this object
  87044. */
  87045. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87046. /**
  87047. * Detach the transform node if its associated with a bone
  87048. * @returns this object
  87049. */
  87050. detachFromBone(): TransformNode;
  87051. private static _rotationAxisCache;
  87052. /**
  87053. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87054. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87055. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87056. * The passed axis is also normalized.
  87057. * @param axis the axis to rotate around
  87058. * @param amount the amount to rotate in radians
  87059. * @param space Space to rotate in (Default: local)
  87060. * @returns the TransformNode.
  87061. */
  87062. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87063. /**
  87064. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87065. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87066. * The passed axis is also normalized. .
  87067. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87068. * @param point the point to rotate around
  87069. * @param axis the axis to rotate around
  87070. * @param amount the amount to rotate in radians
  87071. * @returns the TransformNode
  87072. */
  87073. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87074. /**
  87075. * Translates the mesh along the axis vector for the passed distance in the given space.
  87076. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87077. * @param axis the axis to translate in
  87078. * @param distance the distance to translate
  87079. * @param space Space to rotate in (Default: local)
  87080. * @returns the TransformNode.
  87081. */
  87082. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87083. /**
  87084. * Adds a rotation step to the mesh current rotation.
  87085. * x, y, z are Euler angles expressed in radians.
  87086. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87087. * This means this rotation is made in the mesh local space only.
  87088. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87089. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87090. * ```javascript
  87091. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87092. * ```
  87093. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87094. * 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.
  87095. * @param x Rotation to add
  87096. * @param y Rotation to add
  87097. * @param z Rotation to add
  87098. * @returns the TransformNode.
  87099. */
  87100. addRotation(x: number, y: number, z: number): TransformNode;
  87101. /**
  87102. * @hidden
  87103. */
  87104. protected _getEffectiveParent(): Nullable<Node>;
  87105. /**
  87106. * Computes the world matrix of the node
  87107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87108. * @returns the world matrix
  87109. */
  87110. computeWorldMatrix(force?: boolean): Matrix;
  87111. /**
  87112. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87113. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87114. */
  87115. resetLocalMatrix(independentOfChildren?: boolean): void;
  87116. protected _afterComputeWorldMatrix(): void;
  87117. /**
  87118. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87119. * @param func callback function to add
  87120. *
  87121. * @returns the TransformNode.
  87122. */
  87123. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87124. /**
  87125. * Removes a registered callback function.
  87126. * @param func callback function to remove
  87127. * @returns the TransformNode.
  87128. */
  87129. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87130. /**
  87131. * Gets the position of the current mesh in camera space
  87132. * @param camera defines the camera to use
  87133. * @returns a position
  87134. */
  87135. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87136. /**
  87137. * Returns the distance from the mesh to the active camera
  87138. * @param camera defines the camera to use
  87139. * @returns the distance
  87140. */
  87141. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87142. /**
  87143. * Clone the current transform node
  87144. * @param name Name of the new clone
  87145. * @param newParent New parent for the clone
  87146. * @param doNotCloneChildren Do not clone children hierarchy
  87147. * @returns the new transform node
  87148. */
  87149. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87150. /**
  87151. * Serializes the objects information.
  87152. * @param currentSerializationObject defines the object to serialize in
  87153. * @returns the serialized object
  87154. */
  87155. serialize(currentSerializationObject?: any): any;
  87156. /**
  87157. * Returns a new TransformNode object parsed from the source provided.
  87158. * @param parsedTransformNode is the source.
  87159. * @param scene the scne the object belongs to
  87160. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87161. * @returns a new TransformNode object parsed from the source provided.
  87162. */
  87163. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87164. /**
  87165. * Get all child-transformNodes of this node
  87166. * @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
  87167. * @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
  87168. * @returns an array of TransformNode
  87169. */
  87170. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87171. /**
  87172. * Releases resources associated with this transform node.
  87173. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87174. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87175. */
  87176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87177. /**
  87178. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87179. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87180. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87181. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87182. * @returns the current mesh
  87183. */
  87184. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87185. private _syncAbsoluteScalingAndRotation;
  87186. }
  87187. }
  87188. declare module BABYLON {
  87189. /**
  87190. * Class used to override all child animations of a given target
  87191. */
  87192. export class AnimationPropertiesOverride {
  87193. /**
  87194. * Gets or sets a value indicating if animation blending must be used
  87195. */
  87196. enableBlending: boolean;
  87197. /**
  87198. * Gets or sets the blending speed to use when enableBlending is true
  87199. */
  87200. blendingSpeed: number;
  87201. /**
  87202. * Gets or sets the default loop mode to use
  87203. */
  87204. loopMode: number;
  87205. }
  87206. }
  87207. declare module BABYLON {
  87208. /**
  87209. * Class used to store bone information
  87210. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87211. */
  87212. export class Bone extends Node {
  87213. /**
  87214. * defines the bone name
  87215. */
  87216. name: string;
  87217. private static _tmpVecs;
  87218. private static _tmpQuat;
  87219. private static _tmpMats;
  87220. /**
  87221. * Gets the list of child bones
  87222. */
  87223. children: Bone[];
  87224. /** Gets the animations associated with this bone */
  87225. animations: Animation[];
  87226. /**
  87227. * Gets or sets bone length
  87228. */
  87229. length: number;
  87230. /**
  87231. * @hidden Internal only
  87232. * Set this value to map this bone to a different index in the transform matrices
  87233. * Set this value to -1 to exclude the bone from the transform matrices
  87234. */
  87235. _index: Nullable<number>;
  87236. private _skeleton;
  87237. private _localMatrix;
  87238. private _restPose;
  87239. private _baseMatrix;
  87240. private _absoluteTransform;
  87241. private _invertedAbsoluteTransform;
  87242. private _parent;
  87243. private _scalingDeterminant;
  87244. private _worldTransform;
  87245. private _localScaling;
  87246. private _localRotation;
  87247. private _localPosition;
  87248. private _needToDecompose;
  87249. private _needToCompose;
  87250. /** @hidden */
  87251. _linkedTransformNode: Nullable<TransformNode>;
  87252. /** @hidden */
  87253. _waitingTransformNodeId: Nullable<string>;
  87254. /** @hidden */
  87255. get _matrix(): Matrix;
  87256. /** @hidden */
  87257. set _matrix(value: Matrix);
  87258. /**
  87259. * Create a new bone
  87260. * @param name defines the bone name
  87261. * @param skeleton defines the parent skeleton
  87262. * @param parentBone defines the parent (can be null if the bone is the root)
  87263. * @param localMatrix defines the local matrix
  87264. * @param restPose defines the rest pose matrix
  87265. * @param baseMatrix defines the base matrix
  87266. * @param index defines index of the bone in the hiearchy
  87267. */
  87268. constructor(
  87269. /**
  87270. * defines the bone name
  87271. */
  87272. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87273. /**
  87274. * Gets the current object class name.
  87275. * @return the class name
  87276. */
  87277. getClassName(): string;
  87278. /**
  87279. * Gets the parent skeleton
  87280. * @returns a skeleton
  87281. */
  87282. getSkeleton(): Skeleton;
  87283. /**
  87284. * Gets parent bone
  87285. * @returns a bone or null if the bone is the root of the bone hierarchy
  87286. */
  87287. getParent(): Nullable<Bone>;
  87288. /**
  87289. * Returns an array containing the root bones
  87290. * @returns an array containing the root bones
  87291. */
  87292. getChildren(): Array<Bone>;
  87293. /**
  87294. * Gets the node index in matrix array generated for rendering
  87295. * @returns the node index
  87296. */
  87297. getIndex(): number;
  87298. /**
  87299. * Sets the parent bone
  87300. * @param parent defines the parent (can be null if the bone is the root)
  87301. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87302. */
  87303. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87304. /**
  87305. * Gets the local matrix
  87306. * @returns a matrix
  87307. */
  87308. getLocalMatrix(): Matrix;
  87309. /**
  87310. * Gets the base matrix (initial matrix which remains unchanged)
  87311. * @returns a matrix
  87312. */
  87313. getBaseMatrix(): Matrix;
  87314. /**
  87315. * Gets the rest pose matrix
  87316. * @returns a matrix
  87317. */
  87318. getRestPose(): Matrix;
  87319. /**
  87320. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87321. */
  87322. getWorldMatrix(): Matrix;
  87323. /**
  87324. * Sets the local matrix to rest pose matrix
  87325. */
  87326. returnToRest(): void;
  87327. /**
  87328. * Gets the inverse of the absolute transform matrix.
  87329. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87330. * @returns a matrix
  87331. */
  87332. getInvertedAbsoluteTransform(): Matrix;
  87333. /**
  87334. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87335. * @returns a matrix
  87336. */
  87337. getAbsoluteTransform(): Matrix;
  87338. /**
  87339. * Links with the given transform node.
  87340. * The local matrix of this bone is copied from the transform node every frame.
  87341. * @param transformNode defines the transform node to link to
  87342. */
  87343. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87344. /**
  87345. * Gets the node used to drive the bone's transformation
  87346. * @returns a transform node or null
  87347. */
  87348. getTransformNode(): Nullable<TransformNode>;
  87349. /** Gets or sets current position (in local space) */
  87350. get position(): Vector3;
  87351. set position(newPosition: Vector3);
  87352. /** Gets or sets current rotation (in local space) */
  87353. get rotation(): Vector3;
  87354. set rotation(newRotation: Vector3);
  87355. /** Gets or sets current rotation quaternion (in local space) */
  87356. get rotationQuaternion(): Quaternion;
  87357. set rotationQuaternion(newRotation: Quaternion);
  87358. /** Gets or sets current scaling (in local space) */
  87359. get scaling(): Vector3;
  87360. set scaling(newScaling: Vector3);
  87361. /**
  87362. * Gets the animation properties override
  87363. */
  87364. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87365. private _decompose;
  87366. private _compose;
  87367. /**
  87368. * Update the base and local matrices
  87369. * @param matrix defines the new base or local matrix
  87370. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87371. * @param updateLocalMatrix defines if the local matrix should be updated
  87372. */
  87373. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87374. /** @hidden */
  87375. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87376. /**
  87377. * Flag the bone as dirty (Forcing it to update everything)
  87378. */
  87379. markAsDirty(): void;
  87380. /** @hidden */
  87381. _markAsDirtyAndCompose(): void;
  87382. private _markAsDirtyAndDecompose;
  87383. /**
  87384. * Translate the bone in local or world space
  87385. * @param vec The amount to translate the bone
  87386. * @param space The space that the translation is in
  87387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87388. */
  87389. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87390. /**
  87391. * Set the postion of the bone in local or world space
  87392. * @param position The position to set the bone
  87393. * @param space The space that the position is in
  87394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87395. */
  87396. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87397. /**
  87398. * Set the absolute position of the bone (world space)
  87399. * @param position The position to set the bone
  87400. * @param mesh The mesh that this bone is attached to
  87401. */
  87402. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87403. /**
  87404. * Scale the bone on the x, y and z axes (in local space)
  87405. * @param x The amount to scale the bone on the x axis
  87406. * @param y The amount to scale the bone on the y axis
  87407. * @param z The amount to scale the bone on the z axis
  87408. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87409. */
  87410. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87411. /**
  87412. * Set the bone scaling in local space
  87413. * @param scale defines the scaling vector
  87414. */
  87415. setScale(scale: Vector3): void;
  87416. /**
  87417. * Gets the current scaling in local space
  87418. * @returns the current scaling vector
  87419. */
  87420. getScale(): Vector3;
  87421. /**
  87422. * Gets the current scaling in local space and stores it in a target vector
  87423. * @param result defines the target vector
  87424. */
  87425. getScaleToRef(result: Vector3): void;
  87426. /**
  87427. * Set the yaw, pitch, and roll of the bone in local or world space
  87428. * @param yaw The rotation of the bone on the y axis
  87429. * @param pitch The rotation of the bone on the x axis
  87430. * @param roll The rotation of the bone on the z axis
  87431. * @param space The space that the axes of rotation are in
  87432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87433. */
  87434. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87435. /**
  87436. * Add a rotation to the bone on an axis in local or world space
  87437. * @param axis The axis to rotate the bone on
  87438. * @param amount The amount to rotate the bone
  87439. * @param space The space that the axis is in
  87440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87441. */
  87442. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87443. /**
  87444. * Set the rotation of the bone to a particular axis angle in local or world space
  87445. * @param axis The axis to rotate the bone on
  87446. * @param angle The angle that the bone should be rotated to
  87447. * @param space The space that the axis is in
  87448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87449. */
  87450. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87451. /**
  87452. * Set the euler rotation of the bone in local of world space
  87453. * @param rotation The euler rotation that the bone should be set to
  87454. * @param space The space that the rotation is in
  87455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87456. */
  87457. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87458. /**
  87459. * Set the quaternion rotation of the bone in local of world space
  87460. * @param quat The quaternion rotation that the bone should be set to
  87461. * @param space The space that the rotation is in
  87462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87463. */
  87464. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87465. /**
  87466. * Set the rotation matrix of the bone in local of world space
  87467. * @param rotMat The rotation matrix that the bone should be set to
  87468. * @param space The space that the rotation is in
  87469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87470. */
  87471. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87472. private _rotateWithMatrix;
  87473. private _getNegativeRotationToRef;
  87474. /**
  87475. * Get the position of the bone in local or world space
  87476. * @param space The space that the returned position is in
  87477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87478. * @returns The position of the bone
  87479. */
  87480. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87481. /**
  87482. * Copy the position of the bone to a vector3 in local or world space
  87483. * @param space The space that the returned position is in
  87484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87485. * @param result The vector3 to copy the position to
  87486. */
  87487. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87488. /**
  87489. * Get the absolute position of the bone (world space)
  87490. * @param mesh The mesh that this bone is attached to
  87491. * @returns The absolute position of the bone
  87492. */
  87493. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87494. /**
  87495. * Copy the absolute position of the bone (world space) to the result param
  87496. * @param mesh The mesh that this bone is attached to
  87497. * @param result The vector3 to copy the absolute position to
  87498. */
  87499. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87500. /**
  87501. * Compute the absolute transforms of this bone and its children
  87502. */
  87503. computeAbsoluteTransforms(): void;
  87504. /**
  87505. * Get the world direction from an axis that is in the local space of the bone
  87506. * @param localAxis The local direction that is used to compute the world direction
  87507. * @param mesh The mesh that this bone is attached to
  87508. * @returns The world direction
  87509. */
  87510. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87511. /**
  87512. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87513. * @param localAxis The local direction that is used to compute the world direction
  87514. * @param mesh The mesh that this bone is attached to
  87515. * @param result The vector3 that the world direction will be copied to
  87516. */
  87517. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87518. /**
  87519. * Get the euler rotation of the bone in local or world space
  87520. * @param space The space that the rotation should be in
  87521. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87522. * @returns The euler rotation
  87523. */
  87524. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87525. /**
  87526. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87527. * @param space The space that the rotation should be in
  87528. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87529. * @param result The vector3 that the rotation should be copied to
  87530. */
  87531. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87532. /**
  87533. * Get the quaternion rotation of the bone in either local or world space
  87534. * @param space The space that the rotation should be in
  87535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87536. * @returns The quaternion rotation
  87537. */
  87538. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87539. /**
  87540. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87541. * @param space The space that the rotation should be in
  87542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87543. * @param result The quaternion that the rotation should be copied to
  87544. */
  87545. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87546. /**
  87547. * Get the rotation matrix of the bone in local or world space
  87548. * @param space The space that the rotation should be in
  87549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87550. * @returns The rotation matrix
  87551. */
  87552. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87553. /**
  87554. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87555. * @param space The space that the rotation should be in
  87556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87557. * @param result The quaternion that the rotation should be copied to
  87558. */
  87559. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87560. /**
  87561. * Get the world position of a point that is in the local space of the bone
  87562. * @param position The local position
  87563. * @param mesh The mesh that this bone is attached to
  87564. * @returns The world position
  87565. */
  87566. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87567. /**
  87568. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87569. * @param position The local position
  87570. * @param mesh The mesh that this bone is attached to
  87571. * @param result The vector3 that the world position should be copied to
  87572. */
  87573. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87574. /**
  87575. * Get the local position of a point that is in world space
  87576. * @param position The world position
  87577. * @param mesh The mesh that this bone is attached to
  87578. * @returns The local position
  87579. */
  87580. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87581. /**
  87582. * Get the local position of a point that is in world space and copy it to the result param
  87583. * @param position The world position
  87584. * @param mesh The mesh that this bone is attached to
  87585. * @param result The vector3 that the local position should be copied to
  87586. */
  87587. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87588. }
  87589. }
  87590. declare module BABYLON {
  87591. /**
  87592. * Defines a runtime animation
  87593. */
  87594. export class RuntimeAnimation {
  87595. private _events;
  87596. /**
  87597. * The current frame of the runtime animation
  87598. */
  87599. private _currentFrame;
  87600. /**
  87601. * The animation used by the runtime animation
  87602. */
  87603. private _animation;
  87604. /**
  87605. * The target of the runtime animation
  87606. */
  87607. private _target;
  87608. /**
  87609. * The initiating animatable
  87610. */
  87611. private _host;
  87612. /**
  87613. * The original value of the runtime animation
  87614. */
  87615. private _originalValue;
  87616. /**
  87617. * The original blend value of the runtime animation
  87618. */
  87619. private _originalBlendValue;
  87620. /**
  87621. * The offsets cache of the runtime animation
  87622. */
  87623. private _offsetsCache;
  87624. /**
  87625. * The high limits cache of the runtime animation
  87626. */
  87627. private _highLimitsCache;
  87628. /**
  87629. * Specifies if the runtime animation has been stopped
  87630. */
  87631. private _stopped;
  87632. /**
  87633. * The blending factor of the runtime animation
  87634. */
  87635. private _blendingFactor;
  87636. /**
  87637. * The BabylonJS scene
  87638. */
  87639. private _scene;
  87640. /**
  87641. * The current value of the runtime animation
  87642. */
  87643. private _currentValue;
  87644. /** @hidden */
  87645. _animationState: _IAnimationState;
  87646. /**
  87647. * The active target of the runtime animation
  87648. */
  87649. private _activeTargets;
  87650. private _currentActiveTarget;
  87651. private _directTarget;
  87652. /**
  87653. * The target path of the runtime animation
  87654. */
  87655. private _targetPath;
  87656. /**
  87657. * The weight of the runtime animation
  87658. */
  87659. private _weight;
  87660. /**
  87661. * The ratio offset of the runtime animation
  87662. */
  87663. private _ratioOffset;
  87664. /**
  87665. * The previous delay of the runtime animation
  87666. */
  87667. private _previousDelay;
  87668. /**
  87669. * The previous ratio of the runtime animation
  87670. */
  87671. private _previousRatio;
  87672. private _enableBlending;
  87673. private _keys;
  87674. private _minFrame;
  87675. private _maxFrame;
  87676. private _minValue;
  87677. private _maxValue;
  87678. private _targetIsArray;
  87679. /**
  87680. * Gets the current frame of the runtime animation
  87681. */
  87682. get currentFrame(): number;
  87683. /**
  87684. * Gets the weight of the runtime animation
  87685. */
  87686. get weight(): number;
  87687. /**
  87688. * Gets the current value of the runtime animation
  87689. */
  87690. get currentValue(): any;
  87691. /**
  87692. * Gets the target path of the runtime animation
  87693. */
  87694. get targetPath(): string;
  87695. /**
  87696. * Gets the actual target of the runtime animation
  87697. */
  87698. get target(): any;
  87699. /** @hidden */
  87700. _onLoop: () => void;
  87701. /**
  87702. * Create a new RuntimeAnimation object
  87703. * @param target defines the target of the animation
  87704. * @param animation defines the source animation object
  87705. * @param scene defines the hosting scene
  87706. * @param host defines the initiating Animatable
  87707. */
  87708. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87709. private _preparePath;
  87710. /**
  87711. * Gets the animation from the runtime animation
  87712. */
  87713. get animation(): Animation;
  87714. /**
  87715. * Resets the runtime animation to the beginning
  87716. * @param restoreOriginal defines whether to restore the target property to the original value
  87717. */
  87718. reset(restoreOriginal?: boolean): void;
  87719. /**
  87720. * Specifies if the runtime animation is stopped
  87721. * @returns Boolean specifying if the runtime animation is stopped
  87722. */
  87723. isStopped(): boolean;
  87724. /**
  87725. * Disposes of the runtime animation
  87726. */
  87727. dispose(): void;
  87728. /**
  87729. * Apply the interpolated value to the target
  87730. * @param currentValue defines the value computed by the animation
  87731. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87732. */
  87733. setValue(currentValue: any, weight: number): void;
  87734. private _getOriginalValues;
  87735. private _setValue;
  87736. /**
  87737. * Gets the loop pmode of the runtime animation
  87738. * @returns Loop Mode
  87739. */
  87740. private _getCorrectLoopMode;
  87741. /**
  87742. * Move the current animation to a given frame
  87743. * @param frame defines the frame to move to
  87744. */
  87745. goToFrame(frame: number): void;
  87746. /**
  87747. * @hidden Internal use only
  87748. */
  87749. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87750. /**
  87751. * Execute the current animation
  87752. * @param delay defines the delay to add to the current frame
  87753. * @param from defines the lower bound of the animation range
  87754. * @param to defines the upper bound of the animation range
  87755. * @param loop defines if the current animation must loop
  87756. * @param speedRatio defines the current speed ratio
  87757. * @param weight defines the weight of the animation (default is -1 so no weight)
  87758. * @param onLoop optional callback called when animation loops
  87759. * @returns a boolean indicating if the animation is running
  87760. */
  87761. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87762. }
  87763. }
  87764. declare module BABYLON {
  87765. /**
  87766. * Class used to store an actual running animation
  87767. */
  87768. export class Animatable {
  87769. /** defines the target object */
  87770. target: any;
  87771. /** defines the starting frame number (default is 0) */
  87772. fromFrame: number;
  87773. /** defines the ending frame number (default is 100) */
  87774. toFrame: number;
  87775. /** defines if the animation must loop (default is false) */
  87776. loopAnimation: boolean;
  87777. /** defines a callback to call when animation ends if it is not looping */
  87778. onAnimationEnd?: (() => void) | null | undefined;
  87779. /** defines a callback to call when animation loops */
  87780. onAnimationLoop?: (() => void) | null | undefined;
  87781. private _localDelayOffset;
  87782. private _pausedDelay;
  87783. private _runtimeAnimations;
  87784. private _paused;
  87785. private _scene;
  87786. private _speedRatio;
  87787. private _weight;
  87788. private _syncRoot;
  87789. /**
  87790. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87791. * This will only apply for non looping animation (default is true)
  87792. */
  87793. disposeOnEnd: boolean;
  87794. /**
  87795. * Gets a boolean indicating if the animation has started
  87796. */
  87797. animationStarted: boolean;
  87798. /**
  87799. * Observer raised when the animation ends
  87800. */
  87801. onAnimationEndObservable: Observable<Animatable>;
  87802. /**
  87803. * Observer raised when the animation loops
  87804. */
  87805. onAnimationLoopObservable: Observable<Animatable>;
  87806. /**
  87807. * Gets the root Animatable used to synchronize and normalize animations
  87808. */
  87809. get syncRoot(): Nullable<Animatable>;
  87810. /**
  87811. * Gets the current frame of the first RuntimeAnimation
  87812. * Used to synchronize Animatables
  87813. */
  87814. get masterFrame(): number;
  87815. /**
  87816. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87817. */
  87818. get weight(): number;
  87819. set weight(value: number);
  87820. /**
  87821. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87822. */
  87823. get speedRatio(): number;
  87824. set speedRatio(value: number);
  87825. /**
  87826. * Creates a new Animatable
  87827. * @param scene defines the hosting scene
  87828. * @param target defines the target object
  87829. * @param fromFrame defines the starting frame number (default is 0)
  87830. * @param toFrame defines the ending frame number (default is 100)
  87831. * @param loopAnimation defines if the animation must loop (default is false)
  87832. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87833. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87834. * @param animations defines a group of animation to add to the new Animatable
  87835. * @param onAnimationLoop defines a callback to call when animation loops
  87836. */
  87837. constructor(scene: Scene,
  87838. /** defines the target object */
  87839. target: any,
  87840. /** defines the starting frame number (default is 0) */
  87841. fromFrame?: number,
  87842. /** defines the ending frame number (default is 100) */
  87843. toFrame?: number,
  87844. /** defines if the animation must loop (default is false) */
  87845. loopAnimation?: boolean, speedRatio?: number,
  87846. /** defines a callback to call when animation ends if it is not looping */
  87847. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87848. /** defines a callback to call when animation loops */
  87849. onAnimationLoop?: (() => void) | null | undefined);
  87850. /**
  87851. * Synchronize and normalize current Animatable with a source Animatable
  87852. * This is useful when using animation weights and when animations are not of the same length
  87853. * @param root defines the root Animatable to synchronize with
  87854. * @returns the current Animatable
  87855. */
  87856. syncWith(root: Animatable): Animatable;
  87857. /**
  87858. * Gets the list of runtime animations
  87859. * @returns an array of RuntimeAnimation
  87860. */
  87861. getAnimations(): RuntimeAnimation[];
  87862. /**
  87863. * Adds more animations to the current animatable
  87864. * @param target defines the target of the animations
  87865. * @param animations defines the new animations to add
  87866. */
  87867. appendAnimations(target: any, animations: Animation[]): void;
  87868. /**
  87869. * Gets the source animation for a specific property
  87870. * @param property defines the propertyu to look for
  87871. * @returns null or the source animation for the given property
  87872. */
  87873. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87874. /**
  87875. * Gets the runtime animation for a specific property
  87876. * @param property defines the propertyu to look for
  87877. * @returns null or the runtime animation for the given property
  87878. */
  87879. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87880. /**
  87881. * Resets the animatable to its original state
  87882. */
  87883. reset(): void;
  87884. /**
  87885. * Allows the animatable to blend with current running animations
  87886. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87887. * @param blendingSpeed defines the blending speed to use
  87888. */
  87889. enableBlending(blendingSpeed: number): void;
  87890. /**
  87891. * Disable animation blending
  87892. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87893. */
  87894. disableBlending(): void;
  87895. /**
  87896. * Jump directly to a given frame
  87897. * @param frame defines the frame to jump to
  87898. */
  87899. goToFrame(frame: number): void;
  87900. /**
  87901. * Pause the animation
  87902. */
  87903. pause(): void;
  87904. /**
  87905. * Restart the animation
  87906. */
  87907. restart(): void;
  87908. private _raiseOnAnimationEnd;
  87909. /**
  87910. * Stop and delete the current animation
  87911. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87912. * @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)
  87913. */
  87914. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87915. /**
  87916. * Wait asynchronously for the animation to end
  87917. * @returns a promise which will be fullfilled when the animation ends
  87918. */
  87919. waitAsync(): Promise<Animatable>;
  87920. /** @hidden */
  87921. _animate(delay: number): boolean;
  87922. }
  87923. interface Scene {
  87924. /** @hidden */
  87925. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87926. /** @hidden */
  87927. _processLateAnimationBindingsForMatrices(holder: {
  87928. totalWeight: number;
  87929. animations: RuntimeAnimation[];
  87930. originalValue: Matrix;
  87931. }): any;
  87932. /** @hidden */
  87933. _processLateAnimationBindingsForQuaternions(holder: {
  87934. totalWeight: number;
  87935. animations: RuntimeAnimation[];
  87936. originalValue: Quaternion;
  87937. }, refQuaternion: Quaternion): Quaternion;
  87938. /** @hidden */
  87939. _processLateAnimationBindings(): void;
  87940. /**
  87941. * Will start the animation sequence of a given target
  87942. * @param target defines the target
  87943. * @param from defines from which frame should animation start
  87944. * @param to defines until which frame should animation run.
  87945. * @param weight defines the weight to apply to the animation (1.0 by default)
  87946. * @param loop defines if the animation loops
  87947. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87948. * @param onAnimationEnd defines the function to be executed when the animation ends
  87949. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87950. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87951. * @param onAnimationLoop defines the callback to call when an animation loops
  87952. * @returns the animatable object created for this animation
  87953. */
  87954. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87955. /**
  87956. * Will start the animation sequence of a given target
  87957. * @param target defines the target
  87958. * @param from defines from which frame should animation start
  87959. * @param to defines until which frame should animation run.
  87960. * @param loop defines if the animation loops
  87961. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87962. * @param onAnimationEnd defines the function to be executed when the animation ends
  87963. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87964. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87965. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87966. * @param onAnimationLoop defines the callback to call when an animation loops
  87967. * @returns the animatable object created for this animation
  87968. */
  87969. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87970. /**
  87971. * Will start the animation sequence of a given target and its hierarchy
  87972. * @param target defines the target
  87973. * @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.
  87974. * @param from defines from which frame should animation start
  87975. * @param to defines until which frame should animation run.
  87976. * @param loop defines if the animation loops
  87977. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87978. * @param onAnimationEnd defines the function to be executed when the animation ends
  87979. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87980. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87981. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87982. * @param onAnimationLoop defines the callback to call when an animation loops
  87983. * @returns the list of created animatables
  87984. */
  87985. 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[];
  87986. /**
  87987. * Begin a new animation on a given node
  87988. * @param target defines the target where the animation will take place
  87989. * @param animations defines the list of animations to start
  87990. * @param from defines the initial value
  87991. * @param to defines the final value
  87992. * @param loop defines if you want animation to loop (off by default)
  87993. * @param speedRatio defines the speed ratio to apply to all animations
  87994. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87995. * @param onAnimationLoop defines the callback to call when an animation loops
  87996. * @returns the list of created animatables
  87997. */
  87998. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  87999. /**
  88000. * Begin a new animation on a given node and its hierarchy
  88001. * @param target defines the root node where the animation will take place
  88002. * @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.
  88003. * @param animations defines the list of animations to start
  88004. * @param from defines the initial value
  88005. * @param to defines the final value
  88006. * @param loop defines if you want animation to loop (off by default)
  88007. * @param speedRatio defines the speed ratio to apply to all animations
  88008. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88009. * @param onAnimationLoop defines the callback to call when an animation loops
  88010. * @returns the list of animatables created for all nodes
  88011. */
  88012. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88013. /**
  88014. * Gets the animatable associated with a specific target
  88015. * @param target defines the target of the animatable
  88016. * @returns the required animatable if found
  88017. */
  88018. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88019. /**
  88020. * Gets all animatables associated with a given target
  88021. * @param target defines the target to look animatables for
  88022. * @returns an array of Animatables
  88023. */
  88024. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88025. /**
  88026. * Stops and removes all animations that have been applied to the scene
  88027. */
  88028. stopAllAnimations(): void;
  88029. /**
  88030. * Gets the current delta time used by animation engine
  88031. */
  88032. deltaTime: number;
  88033. }
  88034. interface Bone {
  88035. /**
  88036. * Copy an animation range from another bone
  88037. * @param source defines the source bone
  88038. * @param rangeName defines the range name to copy
  88039. * @param frameOffset defines the frame offset
  88040. * @param rescaleAsRequired defines if rescaling must be applied if required
  88041. * @param skelDimensionsRatio defines the scaling ratio
  88042. * @returns true if operation was successful
  88043. */
  88044. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88045. }
  88046. }
  88047. declare module BABYLON {
  88048. /**
  88049. * Class used to handle skinning animations
  88050. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88051. */
  88052. export class Skeleton implements IAnimatable {
  88053. /** defines the skeleton name */
  88054. name: string;
  88055. /** defines the skeleton Id */
  88056. id: string;
  88057. /**
  88058. * Defines the list of child bones
  88059. */
  88060. bones: Bone[];
  88061. /**
  88062. * Defines an estimate of the dimension of the skeleton at rest
  88063. */
  88064. dimensionsAtRest: Vector3;
  88065. /**
  88066. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88067. */
  88068. needInitialSkinMatrix: boolean;
  88069. /**
  88070. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88071. */
  88072. overrideMesh: Nullable<AbstractMesh>;
  88073. /**
  88074. * Gets the list of animations attached to this skeleton
  88075. */
  88076. animations: Array<Animation>;
  88077. private _scene;
  88078. private _isDirty;
  88079. private _transformMatrices;
  88080. private _transformMatrixTexture;
  88081. private _meshesWithPoseMatrix;
  88082. private _animatables;
  88083. private _identity;
  88084. private _synchronizedWithMesh;
  88085. private _ranges;
  88086. private _lastAbsoluteTransformsUpdateId;
  88087. private _canUseTextureForBones;
  88088. private _uniqueId;
  88089. /** @hidden */
  88090. _numBonesWithLinkedTransformNode: number;
  88091. /** @hidden */
  88092. _hasWaitingData: Nullable<boolean>;
  88093. /**
  88094. * Specifies if the skeleton should be serialized
  88095. */
  88096. doNotSerialize: boolean;
  88097. private _useTextureToStoreBoneMatrices;
  88098. /**
  88099. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88100. * Please note that this option is not available if the hardware does not support it
  88101. */
  88102. get useTextureToStoreBoneMatrices(): boolean;
  88103. set useTextureToStoreBoneMatrices(value: boolean);
  88104. private _animationPropertiesOverride;
  88105. /**
  88106. * Gets or sets the animation properties override
  88107. */
  88108. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88109. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88110. /**
  88111. * List of inspectable custom properties (used by the Inspector)
  88112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88113. */
  88114. inspectableCustomProperties: IInspectable[];
  88115. /**
  88116. * An observable triggered before computing the skeleton's matrices
  88117. */
  88118. onBeforeComputeObservable: Observable<Skeleton>;
  88119. /**
  88120. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88121. */
  88122. get isUsingTextureForMatrices(): boolean;
  88123. /**
  88124. * Gets the unique ID of this skeleton
  88125. */
  88126. get uniqueId(): number;
  88127. /**
  88128. * Creates a new skeleton
  88129. * @param name defines the skeleton name
  88130. * @param id defines the skeleton Id
  88131. * @param scene defines the hosting scene
  88132. */
  88133. constructor(
  88134. /** defines the skeleton name */
  88135. name: string,
  88136. /** defines the skeleton Id */
  88137. id: string, scene: Scene);
  88138. /**
  88139. * Gets the current object class name.
  88140. * @return the class name
  88141. */
  88142. getClassName(): string;
  88143. /**
  88144. * Returns an array containing the root bones
  88145. * @returns an array containing the root bones
  88146. */
  88147. getChildren(): Array<Bone>;
  88148. /**
  88149. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88150. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88151. * @returns a Float32Array containing matrices data
  88152. */
  88153. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88154. /**
  88155. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88156. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88157. * @returns a raw texture containing the data
  88158. */
  88159. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88160. /**
  88161. * Gets the current hosting scene
  88162. * @returns a scene object
  88163. */
  88164. getScene(): Scene;
  88165. /**
  88166. * Gets a string representing the current skeleton data
  88167. * @param fullDetails defines a boolean indicating if we want a verbose version
  88168. * @returns a string representing the current skeleton data
  88169. */
  88170. toString(fullDetails?: boolean): string;
  88171. /**
  88172. * Get bone's index searching by name
  88173. * @param name defines bone's name to search for
  88174. * @return the indice of the bone. Returns -1 if not found
  88175. */
  88176. getBoneIndexByName(name: string): number;
  88177. /**
  88178. * Creater a new animation range
  88179. * @param name defines the name of the range
  88180. * @param from defines the start key
  88181. * @param to defines the end key
  88182. */
  88183. createAnimationRange(name: string, from: number, to: number): void;
  88184. /**
  88185. * Delete a specific animation range
  88186. * @param name defines the name of the range
  88187. * @param deleteFrames defines if frames must be removed as well
  88188. */
  88189. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88190. /**
  88191. * Gets a specific animation range
  88192. * @param name defines the name of the range to look for
  88193. * @returns the requested animation range or null if not found
  88194. */
  88195. getAnimationRange(name: string): Nullable<AnimationRange>;
  88196. /**
  88197. * Gets the list of all animation ranges defined on this skeleton
  88198. * @returns an array
  88199. */
  88200. getAnimationRanges(): Nullable<AnimationRange>[];
  88201. /**
  88202. * Copy animation range from a source skeleton.
  88203. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88204. * @param source defines the source skeleton
  88205. * @param name defines the name of the range to copy
  88206. * @param rescaleAsRequired defines if rescaling must be applied if required
  88207. * @returns true if operation was successful
  88208. */
  88209. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88210. /**
  88211. * Forces the skeleton to go to rest pose
  88212. */
  88213. returnToRest(): void;
  88214. private _getHighestAnimationFrame;
  88215. /**
  88216. * Begin a specific animation range
  88217. * @param name defines the name of the range to start
  88218. * @param loop defines if looping must be turned on (false by default)
  88219. * @param speedRatio defines the speed ratio to apply (1 by default)
  88220. * @param onAnimationEnd defines a callback which will be called when animation will end
  88221. * @returns a new animatable
  88222. */
  88223. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88224. /** @hidden */
  88225. _markAsDirty(): void;
  88226. /** @hidden */
  88227. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88228. /** @hidden */
  88229. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88230. private _computeTransformMatrices;
  88231. /**
  88232. * Build all resources required to render a skeleton
  88233. */
  88234. prepare(): void;
  88235. /**
  88236. * Gets the list of animatables currently running for this skeleton
  88237. * @returns an array of animatables
  88238. */
  88239. getAnimatables(): IAnimatable[];
  88240. /**
  88241. * Clone the current skeleton
  88242. * @param name defines the name of the new skeleton
  88243. * @param id defines the id of the new skeleton
  88244. * @returns the new skeleton
  88245. */
  88246. clone(name: string, id?: string): Skeleton;
  88247. /**
  88248. * Enable animation blending for this skeleton
  88249. * @param blendingSpeed defines the blending speed to apply
  88250. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88251. */
  88252. enableBlending(blendingSpeed?: number): void;
  88253. /**
  88254. * Releases all resources associated with the current skeleton
  88255. */
  88256. dispose(): void;
  88257. /**
  88258. * Serialize the skeleton in a JSON object
  88259. * @returns a JSON object
  88260. */
  88261. serialize(): any;
  88262. /**
  88263. * Creates a new skeleton from serialized data
  88264. * @param parsedSkeleton defines the serialized data
  88265. * @param scene defines the hosting scene
  88266. * @returns a new skeleton
  88267. */
  88268. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88269. /**
  88270. * Compute all node absolute transforms
  88271. * @param forceUpdate defines if computation must be done even if cache is up to date
  88272. */
  88273. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88274. /**
  88275. * Gets the root pose matrix
  88276. * @returns a matrix
  88277. */
  88278. getPoseMatrix(): Nullable<Matrix>;
  88279. /**
  88280. * Sorts bones per internal index
  88281. */
  88282. sortBones(): void;
  88283. private _sortBones;
  88284. }
  88285. }
  88286. declare module BABYLON {
  88287. /**
  88288. * Creates an instance based on a source mesh.
  88289. */
  88290. export class InstancedMesh extends AbstractMesh {
  88291. private _sourceMesh;
  88292. private _currentLOD;
  88293. /** @hidden */
  88294. _indexInSourceMeshInstanceArray: number;
  88295. constructor(name: string, source: Mesh);
  88296. /**
  88297. * Returns the string "InstancedMesh".
  88298. */
  88299. getClassName(): string;
  88300. /** Gets the list of lights affecting that mesh */
  88301. get lightSources(): Light[];
  88302. _resyncLightSources(): void;
  88303. _resyncLightSource(light: Light): void;
  88304. _removeLightSource(light: Light, dispose: boolean): void;
  88305. /**
  88306. * If the source mesh receives shadows
  88307. */
  88308. get receiveShadows(): boolean;
  88309. /**
  88310. * The material of the source mesh
  88311. */
  88312. get material(): Nullable<Material>;
  88313. /**
  88314. * Visibility of the source mesh
  88315. */
  88316. get visibility(): number;
  88317. /**
  88318. * Skeleton of the source mesh
  88319. */
  88320. get skeleton(): Nullable<Skeleton>;
  88321. /**
  88322. * Rendering ground id of the source mesh
  88323. */
  88324. get renderingGroupId(): number;
  88325. set renderingGroupId(value: number);
  88326. /**
  88327. * Returns the total number of vertices (integer).
  88328. */
  88329. getTotalVertices(): number;
  88330. /**
  88331. * Returns a positive integer : the total number of indices in this mesh geometry.
  88332. * @returns the numner of indices or zero if the mesh has no geometry.
  88333. */
  88334. getTotalIndices(): number;
  88335. /**
  88336. * The source mesh of the instance
  88337. */
  88338. get sourceMesh(): Mesh;
  88339. /**
  88340. * Is this node ready to be used/rendered
  88341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88342. * @return {boolean} is it ready
  88343. */
  88344. isReady(completeCheck?: boolean): boolean;
  88345. /**
  88346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88348. * @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.
  88349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88350. */
  88351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88352. /**
  88353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88355. * The `data` are either a numeric array either a Float32Array.
  88356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88357. * 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).
  88358. * Note that a new underlying VertexBuffer object is created each call.
  88359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88360. *
  88361. * Possible `kind` values :
  88362. * - VertexBuffer.PositionKind
  88363. * - VertexBuffer.UVKind
  88364. * - VertexBuffer.UV2Kind
  88365. * - VertexBuffer.UV3Kind
  88366. * - VertexBuffer.UV4Kind
  88367. * - VertexBuffer.UV5Kind
  88368. * - VertexBuffer.UV6Kind
  88369. * - VertexBuffer.ColorKind
  88370. * - VertexBuffer.MatricesIndicesKind
  88371. * - VertexBuffer.MatricesIndicesExtraKind
  88372. * - VertexBuffer.MatricesWeightsKind
  88373. * - VertexBuffer.MatricesWeightsExtraKind
  88374. *
  88375. * Returns the Mesh.
  88376. */
  88377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88378. /**
  88379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88380. * If the mesh has no geometry, it is simply returned as it is.
  88381. * The `data` are either a numeric array either a Float32Array.
  88382. * No new underlying VertexBuffer object is created.
  88383. * 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.
  88384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88385. *
  88386. * Possible `kind` values :
  88387. * - VertexBuffer.PositionKind
  88388. * - VertexBuffer.UVKind
  88389. * - VertexBuffer.UV2Kind
  88390. * - VertexBuffer.UV3Kind
  88391. * - VertexBuffer.UV4Kind
  88392. * - VertexBuffer.UV5Kind
  88393. * - VertexBuffer.UV6Kind
  88394. * - VertexBuffer.ColorKind
  88395. * - VertexBuffer.MatricesIndicesKind
  88396. * - VertexBuffer.MatricesIndicesExtraKind
  88397. * - VertexBuffer.MatricesWeightsKind
  88398. * - VertexBuffer.MatricesWeightsExtraKind
  88399. *
  88400. * Returns the Mesh.
  88401. */
  88402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88403. /**
  88404. * Sets the mesh indices.
  88405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88407. * This method creates a new index buffer each call.
  88408. * Returns the Mesh.
  88409. */
  88410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88411. /**
  88412. * Boolean : True if the mesh owns the requested kind of data.
  88413. */
  88414. isVerticesDataPresent(kind: string): boolean;
  88415. /**
  88416. * Returns an array of indices (IndicesArray).
  88417. */
  88418. getIndices(): Nullable<IndicesArray>;
  88419. get _positions(): Nullable<Vector3[]>;
  88420. /**
  88421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88422. * This means the mesh underlying bounding box and sphere are recomputed.
  88423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88424. * @returns the current mesh
  88425. */
  88426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88427. /** @hidden */
  88428. _preActivate(): InstancedMesh;
  88429. /** @hidden */
  88430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88431. /** @hidden */
  88432. _postActivate(): void;
  88433. getWorldMatrix(): Matrix;
  88434. get isAnInstance(): boolean;
  88435. /**
  88436. * Returns the current associated LOD AbstractMesh.
  88437. */
  88438. getLOD(camera: Camera): AbstractMesh;
  88439. /** @hidden */
  88440. _syncSubMeshes(): InstancedMesh;
  88441. /** @hidden */
  88442. _generatePointsArray(): boolean;
  88443. /**
  88444. * Creates a new InstancedMesh from the current mesh.
  88445. * - name (string) : the cloned mesh name
  88446. * - newParent (optional Node) : the optional Node to parent the clone to.
  88447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88448. *
  88449. * Returns the clone.
  88450. */
  88451. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88452. /**
  88453. * Disposes the InstancedMesh.
  88454. * Returns nothing.
  88455. */
  88456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88457. }
  88458. interface Mesh {
  88459. /**
  88460. * Register a custom buffer that will be instanced
  88461. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88462. * @param kind defines the buffer kind
  88463. * @param stride defines the stride in floats
  88464. */
  88465. registerInstancedBuffer(kind: string, stride: number): void;
  88466. /** @hidden */
  88467. _userInstancedBuffersStorage: {
  88468. data: {
  88469. [key: string]: Float32Array;
  88470. };
  88471. sizes: {
  88472. [key: string]: number;
  88473. };
  88474. vertexBuffers: {
  88475. [key: string]: Nullable<VertexBuffer>;
  88476. };
  88477. strides: {
  88478. [key: string]: number;
  88479. };
  88480. };
  88481. }
  88482. interface AbstractMesh {
  88483. /**
  88484. * Object used to store instanced buffers defined by user
  88485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88486. */
  88487. instancedBuffers: {
  88488. [key: string]: any;
  88489. };
  88490. }
  88491. }
  88492. declare module BABYLON {
  88493. /**
  88494. * Defines the options associated with the creation of a shader material.
  88495. */
  88496. export interface IShaderMaterialOptions {
  88497. /**
  88498. * Does the material work in alpha blend mode
  88499. */
  88500. needAlphaBlending: boolean;
  88501. /**
  88502. * Does the material work in alpha test mode
  88503. */
  88504. needAlphaTesting: boolean;
  88505. /**
  88506. * The list of attribute names used in the shader
  88507. */
  88508. attributes: string[];
  88509. /**
  88510. * The list of unifrom names used in the shader
  88511. */
  88512. uniforms: string[];
  88513. /**
  88514. * The list of UBO names used in the shader
  88515. */
  88516. uniformBuffers: string[];
  88517. /**
  88518. * The list of sampler names used in the shader
  88519. */
  88520. samplers: string[];
  88521. /**
  88522. * The list of defines used in the shader
  88523. */
  88524. defines: string[];
  88525. }
  88526. /**
  88527. * 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.
  88528. *
  88529. * This returned material effects how the mesh will look based on the code in the shaders.
  88530. *
  88531. * @see http://doc.babylonjs.com/how_to/shader_material
  88532. */
  88533. export class ShaderMaterial extends Material {
  88534. private _shaderPath;
  88535. private _options;
  88536. private _textures;
  88537. private _textureArrays;
  88538. private _floats;
  88539. private _ints;
  88540. private _floatsArrays;
  88541. private _colors3;
  88542. private _colors3Arrays;
  88543. private _colors4;
  88544. private _colors4Arrays;
  88545. private _vectors2;
  88546. private _vectors3;
  88547. private _vectors4;
  88548. private _matrices;
  88549. private _matrixArrays;
  88550. private _matrices3x3;
  88551. private _matrices2x2;
  88552. private _vectors2Arrays;
  88553. private _vectors3Arrays;
  88554. private _vectors4Arrays;
  88555. private _cachedWorldViewMatrix;
  88556. private _cachedWorldViewProjectionMatrix;
  88557. private _renderId;
  88558. private _multiview;
  88559. /**
  88560. * Instantiate a new shader material.
  88561. * 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.
  88562. * This returned material effects how the mesh will look based on the code in the shaders.
  88563. * @see http://doc.babylonjs.com/how_to/shader_material
  88564. * @param name Define the name of the material in the scene
  88565. * @param scene Define the scene the material belongs to
  88566. * @param shaderPath Defines the route to the shader code in one of three ways:
  88567. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88568. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88569. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88570. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88571. * @param options Define the options used to create the shader
  88572. */
  88573. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88574. /**
  88575. * Gets the shader path used to define the shader code
  88576. * It can be modified to trigger a new compilation
  88577. */
  88578. get shaderPath(): any;
  88579. /**
  88580. * Sets the shader path used to define the shader code
  88581. * It can be modified to trigger a new compilation
  88582. */
  88583. set shaderPath(shaderPath: any);
  88584. /**
  88585. * Gets the options used to compile the shader.
  88586. * They can be modified to trigger a new compilation
  88587. */
  88588. get options(): IShaderMaterialOptions;
  88589. /**
  88590. * Gets the current class name of the material e.g. "ShaderMaterial"
  88591. * Mainly use in serialization.
  88592. * @returns the class name
  88593. */
  88594. getClassName(): string;
  88595. /**
  88596. * Specifies if the material will require alpha blending
  88597. * @returns a boolean specifying if alpha blending is needed
  88598. */
  88599. needAlphaBlending(): boolean;
  88600. /**
  88601. * Specifies if this material should be rendered in alpha test mode
  88602. * @returns a boolean specifying if an alpha test is needed.
  88603. */
  88604. needAlphaTesting(): boolean;
  88605. private _checkUniform;
  88606. /**
  88607. * Set a texture in the shader.
  88608. * @param name Define the name of the uniform samplers as defined in the shader
  88609. * @param texture Define the texture to bind to this sampler
  88610. * @return the material itself allowing "fluent" like uniform updates
  88611. */
  88612. setTexture(name: string, texture: Texture): ShaderMaterial;
  88613. /**
  88614. * Set a texture array in the shader.
  88615. * @param name Define the name of the uniform sampler array as defined in the shader
  88616. * @param textures Define the list of textures to bind to this sampler
  88617. * @return the material itself allowing "fluent" like uniform updates
  88618. */
  88619. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88620. /**
  88621. * Set a float in the shader.
  88622. * @param name Define the name of the uniform as defined in the shader
  88623. * @param value Define the value to give to the uniform
  88624. * @return the material itself allowing "fluent" like uniform updates
  88625. */
  88626. setFloat(name: string, value: number): ShaderMaterial;
  88627. /**
  88628. * Set a int in the shader.
  88629. * @param name Define the name of the uniform as defined in the shader
  88630. * @param value Define the value to give to the uniform
  88631. * @return the material itself allowing "fluent" like uniform updates
  88632. */
  88633. setInt(name: string, value: number): ShaderMaterial;
  88634. /**
  88635. * Set an array of floats in the shader.
  88636. * @param name Define the name of the uniform as defined in the shader
  88637. * @param value Define the value to give to the uniform
  88638. * @return the material itself allowing "fluent" like uniform updates
  88639. */
  88640. setFloats(name: string, value: number[]): ShaderMaterial;
  88641. /**
  88642. * Set a vec3 in the shader from a Color3.
  88643. * @param name Define the name of the uniform as defined in the shader
  88644. * @param value Define the value to give to the uniform
  88645. * @return the material itself allowing "fluent" like uniform updates
  88646. */
  88647. setColor3(name: string, value: Color3): ShaderMaterial;
  88648. /**
  88649. * Set a vec3 array in the shader from a Color3 array.
  88650. * @param name Define the name of the uniform as defined in the shader
  88651. * @param value Define the value to give to the uniform
  88652. * @return the material itself allowing "fluent" like uniform updates
  88653. */
  88654. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88655. /**
  88656. * Set a vec4 in the shader from a Color4.
  88657. * @param name Define the name of the uniform as defined in the shader
  88658. * @param value Define the value to give to the uniform
  88659. * @return the material itself allowing "fluent" like uniform updates
  88660. */
  88661. setColor4(name: string, value: Color4): ShaderMaterial;
  88662. /**
  88663. * Set a vec4 array in the shader from a Color4 array.
  88664. * @param name Define the name of the uniform as defined in the shader
  88665. * @param value Define the value to give to the uniform
  88666. * @return the material itself allowing "fluent" like uniform updates
  88667. */
  88668. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88669. /**
  88670. * Set a vec2 in the shader from a Vector2.
  88671. * @param name Define the name of the uniform as defined in the shader
  88672. * @param value Define the value to give to the uniform
  88673. * @return the material itself allowing "fluent" like uniform updates
  88674. */
  88675. setVector2(name: string, value: Vector2): ShaderMaterial;
  88676. /**
  88677. * Set a vec3 in the shader from a Vector3.
  88678. * @param name Define the name of the uniform as defined in the shader
  88679. * @param value Define the value to give to the uniform
  88680. * @return the material itself allowing "fluent" like uniform updates
  88681. */
  88682. setVector3(name: string, value: Vector3): ShaderMaterial;
  88683. /**
  88684. * Set a vec4 in the shader from a Vector4.
  88685. * @param name Define the name of the uniform as defined in the shader
  88686. * @param value Define the value to give to the uniform
  88687. * @return the material itself allowing "fluent" like uniform updates
  88688. */
  88689. setVector4(name: string, value: Vector4): ShaderMaterial;
  88690. /**
  88691. * Set a mat4 in the shader from a Matrix.
  88692. * @param name Define the name of the uniform as defined in the shader
  88693. * @param value Define the value to give to the uniform
  88694. * @return the material itself allowing "fluent" like uniform updates
  88695. */
  88696. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88697. /**
  88698. * Set a float32Array in the shader from a matrix array.
  88699. * @param name Define the name of the uniform as defined in the shader
  88700. * @param value Define the value to give to the uniform
  88701. * @return the material itself allowing "fluent" like uniform updates
  88702. */
  88703. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88704. /**
  88705. * Set a mat3 in the shader from a Float32Array.
  88706. * @param name Define the name of the uniform as defined in the shader
  88707. * @param value Define the value to give to the uniform
  88708. * @return the material itself allowing "fluent" like uniform updates
  88709. */
  88710. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88711. /**
  88712. * Set a mat2 in the shader from a Float32Array.
  88713. * @param name Define the name of the uniform as defined in the shader
  88714. * @param value Define the value to give to the uniform
  88715. * @return the material itself allowing "fluent" like uniform updates
  88716. */
  88717. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88718. /**
  88719. * Set a vec2 array in the shader from a number array.
  88720. * @param name Define the name of the uniform as defined in the shader
  88721. * @param value Define the value to give to the uniform
  88722. * @return the material itself allowing "fluent" like uniform updates
  88723. */
  88724. setArray2(name: string, value: number[]): ShaderMaterial;
  88725. /**
  88726. * Set a vec3 array in the shader from a number array.
  88727. * @param name Define the name of the uniform as defined in the shader
  88728. * @param value Define the value to give to the uniform
  88729. * @return the material itself allowing "fluent" like uniform updates
  88730. */
  88731. setArray3(name: string, value: number[]): ShaderMaterial;
  88732. /**
  88733. * Set a vec4 array in the shader from a number array.
  88734. * @param name Define the name of the uniform as defined in the shader
  88735. * @param value Define the value to give to the uniform
  88736. * @return the material itself allowing "fluent" like uniform updates
  88737. */
  88738. setArray4(name: string, value: number[]): ShaderMaterial;
  88739. private _checkCache;
  88740. /**
  88741. * Specifies that the submesh is ready to be used
  88742. * @param mesh defines the mesh to check
  88743. * @param subMesh defines which submesh to check
  88744. * @param useInstances specifies that instances should be used
  88745. * @returns a boolean indicating that the submesh is ready or not
  88746. */
  88747. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88748. /**
  88749. * Checks if the material is ready to render the requested mesh
  88750. * @param mesh Define the mesh to render
  88751. * @param useInstances Define whether or not the material is used with instances
  88752. * @returns true if ready, otherwise false
  88753. */
  88754. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88755. /**
  88756. * Binds the world matrix to the material
  88757. * @param world defines the world transformation matrix
  88758. */
  88759. bindOnlyWorldMatrix(world: Matrix): void;
  88760. /**
  88761. * Binds the material to the mesh
  88762. * @param world defines the world transformation matrix
  88763. * @param mesh defines the mesh to bind the material to
  88764. */
  88765. bind(world: Matrix, mesh?: Mesh): void;
  88766. /**
  88767. * Gets the active textures from the material
  88768. * @returns an array of textures
  88769. */
  88770. getActiveTextures(): BaseTexture[];
  88771. /**
  88772. * Specifies if the material uses a texture
  88773. * @param texture defines the texture to check against the material
  88774. * @returns a boolean specifying if the material uses the texture
  88775. */
  88776. hasTexture(texture: BaseTexture): boolean;
  88777. /**
  88778. * Makes a duplicate of the material, and gives it a new name
  88779. * @param name defines the new name for the duplicated material
  88780. * @returns the cloned material
  88781. */
  88782. clone(name: string): ShaderMaterial;
  88783. /**
  88784. * Disposes the material
  88785. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88786. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88787. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88788. */
  88789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88790. /**
  88791. * Serializes this material in a JSON representation
  88792. * @returns the serialized material object
  88793. */
  88794. serialize(): any;
  88795. /**
  88796. * Creates a shader material from parsed shader material data
  88797. * @param source defines the JSON represnetation of the material
  88798. * @param scene defines the hosting scene
  88799. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88800. * @returns a new material
  88801. */
  88802. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88803. }
  88804. }
  88805. declare module BABYLON {
  88806. /** @hidden */
  88807. export var colorPixelShader: {
  88808. name: string;
  88809. shader: string;
  88810. };
  88811. }
  88812. declare module BABYLON {
  88813. /** @hidden */
  88814. export var colorVertexShader: {
  88815. name: string;
  88816. shader: string;
  88817. };
  88818. }
  88819. declare module BABYLON {
  88820. /**
  88821. * Line mesh
  88822. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88823. */
  88824. export class LinesMesh extends Mesh {
  88825. /**
  88826. * If vertex color should be applied to the mesh
  88827. */
  88828. readonly useVertexColor?: boolean | undefined;
  88829. /**
  88830. * If vertex alpha should be applied to the mesh
  88831. */
  88832. readonly useVertexAlpha?: boolean | undefined;
  88833. /**
  88834. * Color of the line (Default: White)
  88835. */
  88836. color: Color3;
  88837. /**
  88838. * Alpha of the line (Default: 1)
  88839. */
  88840. alpha: number;
  88841. /**
  88842. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88843. * This margin is expressed in world space coordinates, so its value may vary.
  88844. * Default value is 0.1
  88845. */
  88846. intersectionThreshold: number;
  88847. private _colorShader;
  88848. private color4;
  88849. /**
  88850. * Creates a new LinesMesh
  88851. * @param name defines the name
  88852. * @param scene defines the hosting scene
  88853. * @param parent defines the parent mesh if any
  88854. * @param source defines the optional source LinesMesh used to clone data from
  88855. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88856. * When false, achieved by calling a clone(), also passing False.
  88857. * This will make creation of children, recursive.
  88858. * @param useVertexColor defines if this LinesMesh supports vertex color
  88859. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88860. */
  88861. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88862. /**
  88863. * If vertex color should be applied to the mesh
  88864. */
  88865. useVertexColor?: boolean | undefined,
  88866. /**
  88867. * If vertex alpha should be applied to the mesh
  88868. */
  88869. useVertexAlpha?: boolean | undefined);
  88870. private _addClipPlaneDefine;
  88871. private _removeClipPlaneDefine;
  88872. isReady(): boolean;
  88873. /**
  88874. * Returns the string "LineMesh"
  88875. */
  88876. getClassName(): string;
  88877. /**
  88878. * @hidden
  88879. */
  88880. get material(): Material;
  88881. /**
  88882. * @hidden
  88883. */
  88884. set material(value: Material);
  88885. /**
  88886. * @hidden
  88887. */
  88888. get checkCollisions(): boolean;
  88889. /** @hidden */
  88890. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88891. /** @hidden */
  88892. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88893. /**
  88894. * Disposes of the line mesh
  88895. * @param doNotRecurse If children should be disposed
  88896. */
  88897. dispose(doNotRecurse?: boolean): void;
  88898. /**
  88899. * Returns a new LineMesh object cloned from the current one.
  88900. */
  88901. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88902. /**
  88903. * Creates a new InstancedLinesMesh object from the mesh model.
  88904. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88905. * @param name defines the name of the new instance
  88906. * @returns a new InstancedLinesMesh
  88907. */
  88908. createInstance(name: string): InstancedLinesMesh;
  88909. }
  88910. /**
  88911. * Creates an instance based on a source LinesMesh
  88912. */
  88913. export class InstancedLinesMesh extends InstancedMesh {
  88914. /**
  88915. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88916. * This margin is expressed in world space coordinates, so its value may vary.
  88917. * Initilized with the intersectionThreshold value of the source LinesMesh
  88918. */
  88919. intersectionThreshold: number;
  88920. constructor(name: string, source: LinesMesh);
  88921. /**
  88922. * Returns the string "InstancedLinesMesh".
  88923. */
  88924. getClassName(): string;
  88925. }
  88926. }
  88927. declare module BABYLON {
  88928. /** @hidden */
  88929. export var linePixelShader: {
  88930. name: string;
  88931. shader: string;
  88932. };
  88933. }
  88934. declare module BABYLON {
  88935. /** @hidden */
  88936. export var lineVertexShader: {
  88937. name: string;
  88938. shader: string;
  88939. };
  88940. }
  88941. declare module BABYLON {
  88942. interface AbstractMesh {
  88943. /**
  88944. * Gets the edgesRenderer associated with the mesh
  88945. */
  88946. edgesRenderer: Nullable<EdgesRenderer>;
  88947. }
  88948. interface LinesMesh {
  88949. /**
  88950. * Enables the edge rendering mode on the mesh.
  88951. * This mode makes the mesh edges visible
  88952. * @param epsilon defines the maximal distance between two angles to detect a face
  88953. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88954. * @returns the currentAbstractMesh
  88955. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88956. */
  88957. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88958. }
  88959. interface InstancedLinesMesh {
  88960. /**
  88961. * Enables the edge rendering mode on the mesh.
  88962. * This mode makes the mesh edges visible
  88963. * @param epsilon defines the maximal distance between two angles to detect a face
  88964. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88965. * @returns the current InstancedLinesMesh
  88966. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88967. */
  88968. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88969. }
  88970. /**
  88971. * Defines the minimum contract an Edges renderer should follow.
  88972. */
  88973. export interface IEdgesRenderer extends IDisposable {
  88974. /**
  88975. * Gets or sets a boolean indicating if the edgesRenderer is active
  88976. */
  88977. isEnabled: boolean;
  88978. /**
  88979. * Renders the edges of the attached mesh,
  88980. */
  88981. render(): void;
  88982. /**
  88983. * Checks wether or not the edges renderer is ready to render.
  88984. * @return true if ready, otherwise false.
  88985. */
  88986. isReady(): boolean;
  88987. }
  88988. /**
  88989. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88990. */
  88991. export class EdgesRenderer implements IEdgesRenderer {
  88992. /**
  88993. * Define the size of the edges with an orthographic camera
  88994. */
  88995. edgesWidthScalerForOrthographic: number;
  88996. /**
  88997. * Define the size of the edges with a perspective camera
  88998. */
  88999. edgesWidthScalerForPerspective: number;
  89000. protected _source: AbstractMesh;
  89001. protected _linesPositions: number[];
  89002. protected _linesNormals: number[];
  89003. protected _linesIndices: number[];
  89004. protected _epsilon: number;
  89005. protected _indicesCount: number;
  89006. protected _lineShader: ShaderMaterial;
  89007. protected _ib: DataBuffer;
  89008. protected _buffers: {
  89009. [key: string]: Nullable<VertexBuffer>;
  89010. };
  89011. protected _checkVerticesInsteadOfIndices: boolean;
  89012. private _meshRebuildObserver;
  89013. private _meshDisposeObserver;
  89014. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89015. isEnabled: boolean;
  89016. /**
  89017. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89018. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89019. * @param source Mesh used to create edges
  89020. * @param epsilon sum of angles in adjacency to check for edge
  89021. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89022. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89023. */
  89024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89025. protected _prepareRessources(): void;
  89026. /** @hidden */
  89027. _rebuild(): void;
  89028. /**
  89029. * Releases the required resources for the edges renderer
  89030. */
  89031. dispose(): void;
  89032. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89033. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89034. /**
  89035. * Checks if the pair of p0 and p1 is en edge
  89036. * @param faceIndex
  89037. * @param edge
  89038. * @param faceNormals
  89039. * @param p0
  89040. * @param p1
  89041. * @private
  89042. */
  89043. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89044. /**
  89045. * push line into the position, normal and index buffer
  89046. * @protected
  89047. */
  89048. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89049. /**
  89050. * Generates lines edges from adjacencjes
  89051. * @private
  89052. */
  89053. _generateEdgesLines(): void;
  89054. /**
  89055. * Checks wether or not the edges renderer is ready to render.
  89056. * @return true if ready, otherwise false.
  89057. */
  89058. isReady(): boolean;
  89059. /**
  89060. * Renders the edges of the attached mesh,
  89061. */
  89062. render(): void;
  89063. }
  89064. /**
  89065. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89066. */
  89067. export class LineEdgesRenderer extends EdgesRenderer {
  89068. /**
  89069. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89070. * @param source LineMesh used to generate edges
  89071. * @param epsilon not important (specified angle for edge detection)
  89072. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89073. */
  89074. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89075. /**
  89076. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89077. */
  89078. _generateEdgesLines(): void;
  89079. }
  89080. }
  89081. declare module BABYLON {
  89082. /**
  89083. * This represents the object necessary to create a rendering group.
  89084. * This is exclusively used and created by the rendering manager.
  89085. * To modify the behavior, you use the available helpers in your scene or meshes.
  89086. * @hidden
  89087. */
  89088. export class RenderingGroup {
  89089. index: number;
  89090. private static _zeroVector;
  89091. private _scene;
  89092. private _opaqueSubMeshes;
  89093. private _transparentSubMeshes;
  89094. private _alphaTestSubMeshes;
  89095. private _depthOnlySubMeshes;
  89096. private _particleSystems;
  89097. private _spriteManagers;
  89098. private _opaqueSortCompareFn;
  89099. private _alphaTestSortCompareFn;
  89100. private _transparentSortCompareFn;
  89101. private _renderOpaque;
  89102. private _renderAlphaTest;
  89103. private _renderTransparent;
  89104. /** @hidden */
  89105. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89106. onBeforeTransparentRendering: () => void;
  89107. /**
  89108. * Set the opaque sort comparison function.
  89109. * If null the sub meshes will be render in the order they were created
  89110. */
  89111. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89112. /**
  89113. * Set the alpha test sort comparison function.
  89114. * If null the sub meshes will be render in the order they were created
  89115. */
  89116. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89117. /**
  89118. * Set the transparent sort comparison function.
  89119. * If null the sub meshes will be render in the order they were created
  89120. */
  89121. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89122. /**
  89123. * Creates a new rendering group.
  89124. * @param index The rendering group index
  89125. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89126. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89127. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89128. */
  89129. 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>);
  89130. /**
  89131. * Render all the sub meshes contained in the group.
  89132. * @param customRenderFunction Used to override the default render behaviour of the group.
  89133. * @returns true if rendered some submeshes.
  89134. */
  89135. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89136. /**
  89137. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89138. * @param subMeshes The submeshes to render
  89139. */
  89140. private renderOpaqueSorted;
  89141. /**
  89142. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89143. * @param subMeshes The submeshes to render
  89144. */
  89145. private renderAlphaTestSorted;
  89146. /**
  89147. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89148. * @param subMeshes The submeshes to render
  89149. */
  89150. private renderTransparentSorted;
  89151. /**
  89152. * Renders the submeshes in a specified order.
  89153. * @param subMeshes The submeshes to sort before render
  89154. * @param sortCompareFn The comparison function use to sort
  89155. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89156. * @param transparent Specifies to activate blending if true
  89157. */
  89158. private static renderSorted;
  89159. /**
  89160. * Renders the submeshes in the order they were dispatched (no sort applied).
  89161. * @param subMeshes The submeshes to render
  89162. */
  89163. private static renderUnsorted;
  89164. /**
  89165. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89166. * are rendered back to front if in the same alpha index.
  89167. *
  89168. * @param a The first submesh
  89169. * @param b The second submesh
  89170. * @returns The result of the comparison
  89171. */
  89172. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89173. /**
  89174. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89175. * are rendered back to front.
  89176. *
  89177. * @param a The first submesh
  89178. * @param b The second submesh
  89179. * @returns The result of the comparison
  89180. */
  89181. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89182. /**
  89183. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89184. * are rendered front to back (prevent overdraw).
  89185. *
  89186. * @param a The first submesh
  89187. * @param b The second submesh
  89188. * @returns The result of the comparison
  89189. */
  89190. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89191. /**
  89192. * Resets the different lists of submeshes to prepare a new frame.
  89193. */
  89194. prepare(): void;
  89195. dispose(): void;
  89196. /**
  89197. * Inserts the submesh in its correct queue depending on its material.
  89198. * @param subMesh The submesh to dispatch
  89199. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89200. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89201. */
  89202. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89203. dispatchSprites(spriteManager: ISpriteManager): void;
  89204. dispatchParticles(particleSystem: IParticleSystem): void;
  89205. private _renderParticles;
  89206. private _renderSprites;
  89207. }
  89208. }
  89209. declare module BABYLON {
  89210. /**
  89211. * Interface describing the different options available in the rendering manager
  89212. * regarding Auto Clear between groups.
  89213. */
  89214. export interface IRenderingManagerAutoClearSetup {
  89215. /**
  89216. * Defines whether or not autoclear is enable.
  89217. */
  89218. autoClear: boolean;
  89219. /**
  89220. * Defines whether or not to autoclear the depth buffer.
  89221. */
  89222. depth: boolean;
  89223. /**
  89224. * Defines whether or not to autoclear the stencil buffer.
  89225. */
  89226. stencil: boolean;
  89227. }
  89228. /**
  89229. * This class is used by the onRenderingGroupObservable
  89230. */
  89231. export class RenderingGroupInfo {
  89232. /**
  89233. * The Scene that being rendered
  89234. */
  89235. scene: Scene;
  89236. /**
  89237. * The camera currently used for the rendering pass
  89238. */
  89239. camera: Nullable<Camera>;
  89240. /**
  89241. * The ID of the renderingGroup being processed
  89242. */
  89243. renderingGroupId: number;
  89244. }
  89245. /**
  89246. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89247. * It is enable to manage the different groups as well as the different necessary sort functions.
  89248. * This should not be used directly aside of the few static configurations
  89249. */
  89250. export class RenderingManager {
  89251. /**
  89252. * The max id used for rendering groups (not included)
  89253. */
  89254. static MAX_RENDERINGGROUPS: number;
  89255. /**
  89256. * The min id used for rendering groups (included)
  89257. */
  89258. static MIN_RENDERINGGROUPS: number;
  89259. /**
  89260. * Used to globally prevent autoclearing scenes.
  89261. */
  89262. static AUTOCLEAR: boolean;
  89263. /**
  89264. * @hidden
  89265. */
  89266. _useSceneAutoClearSetup: boolean;
  89267. private _scene;
  89268. private _renderingGroups;
  89269. private _depthStencilBufferAlreadyCleaned;
  89270. private _autoClearDepthStencil;
  89271. private _customOpaqueSortCompareFn;
  89272. private _customAlphaTestSortCompareFn;
  89273. private _customTransparentSortCompareFn;
  89274. private _renderingGroupInfo;
  89275. /**
  89276. * Instantiates a new rendering group for a particular scene
  89277. * @param scene Defines the scene the groups belongs to
  89278. */
  89279. constructor(scene: Scene);
  89280. private _clearDepthStencilBuffer;
  89281. /**
  89282. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89283. * @hidden
  89284. */
  89285. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89286. /**
  89287. * Resets the different information of the group to prepare a new frame
  89288. * @hidden
  89289. */
  89290. reset(): void;
  89291. /**
  89292. * Dispose and release the group and its associated resources.
  89293. * @hidden
  89294. */
  89295. dispose(): void;
  89296. /**
  89297. * Clear the info related to rendering groups preventing retention points during dispose.
  89298. */
  89299. freeRenderingGroups(): void;
  89300. private _prepareRenderingGroup;
  89301. /**
  89302. * Add a sprite manager to the rendering manager in order to render it this frame.
  89303. * @param spriteManager Define the sprite manager to render
  89304. */
  89305. dispatchSprites(spriteManager: ISpriteManager): void;
  89306. /**
  89307. * Add a particle system to the rendering manager in order to render it this frame.
  89308. * @param particleSystem Define the particle system to render
  89309. */
  89310. dispatchParticles(particleSystem: IParticleSystem): void;
  89311. /**
  89312. * Add a submesh to the manager in order to render it this frame
  89313. * @param subMesh The submesh to dispatch
  89314. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89315. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89316. */
  89317. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89318. /**
  89319. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89320. * This allowed control for front to back rendering or reversly depending of the special needs.
  89321. *
  89322. * @param renderingGroupId The rendering group id corresponding to its index
  89323. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89324. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89325. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89326. */
  89327. 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;
  89328. /**
  89329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89330. *
  89331. * @param renderingGroupId The rendering group id corresponding to its index
  89332. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89333. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89334. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89335. */
  89336. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89337. /**
  89338. * Gets the current auto clear configuration for one rendering group of the rendering
  89339. * manager.
  89340. * @param index the rendering group index to get the information for
  89341. * @returns The auto clear setup for the requested rendering group
  89342. */
  89343. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89344. }
  89345. }
  89346. declare module BABYLON {
  89347. /**
  89348. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89349. */
  89350. export interface ICustomShaderOptions {
  89351. /**
  89352. * Gets or sets the custom shader name to use
  89353. */
  89354. shaderName: string;
  89355. /**
  89356. * The list of attribute names used in the shader
  89357. */
  89358. attributes?: string[];
  89359. /**
  89360. * The list of unifrom names used in the shader
  89361. */
  89362. uniforms?: string[];
  89363. /**
  89364. * The list of sampler names used in the shader
  89365. */
  89366. samplers?: string[];
  89367. /**
  89368. * The list of defines used in the shader
  89369. */
  89370. defines?: string[];
  89371. }
  89372. /**
  89373. * Interface to implement to create a shadow generator compatible with BJS.
  89374. */
  89375. export interface IShadowGenerator {
  89376. /**
  89377. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89378. * @returns The render target texture if present otherwise, null
  89379. */
  89380. getShadowMap(): Nullable<RenderTargetTexture>;
  89381. /**
  89382. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89383. * @param subMesh The submesh we want to render in the shadow map
  89384. * @param useInstances Defines wether will draw in the map using instances
  89385. * @returns true if ready otherwise, false
  89386. */
  89387. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89388. /**
  89389. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89390. * @param defines Defines of the material we want to update
  89391. * @param lightIndex Index of the light in the enabled light list of the material
  89392. */
  89393. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89394. /**
  89395. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89396. * defined in the generator but impacting the effect).
  89397. * It implies the unifroms available on the materials are the standard BJS ones.
  89398. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89399. * @param effect The effect we are binfing the information for
  89400. */
  89401. bindShadowLight(lightIndex: string, effect: Effect): void;
  89402. /**
  89403. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89404. * (eq to shadow prjection matrix * light transform matrix)
  89405. * @returns The transform matrix used to create the shadow map
  89406. */
  89407. getTransformMatrix(): Matrix;
  89408. /**
  89409. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89410. * Cube and 2D textures for instance.
  89411. */
  89412. recreateShadowMap(): void;
  89413. /**
  89414. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89415. * @param onCompiled Callback triggered at the and of the effects compilation
  89416. * @param options Sets of optional options forcing the compilation with different modes
  89417. */
  89418. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89419. useInstances: boolean;
  89420. }>): void;
  89421. /**
  89422. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89423. * @param options Sets of optional options forcing the compilation with different modes
  89424. * @returns A promise that resolves when the compilation completes
  89425. */
  89426. forceCompilationAsync(options?: Partial<{
  89427. useInstances: boolean;
  89428. }>): Promise<void>;
  89429. /**
  89430. * Serializes the shadow generator setup to a json object.
  89431. * @returns The serialized JSON object
  89432. */
  89433. serialize(): any;
  89434. /**
  89435. * Disposes the Shadow map and related Textures and effects.
  89436. */
  89437. dispose(): void;
  89438. }
  89439. /**
  89440. * Default implementation IShadowGenerator.
  89441. * This is the main object responsible of generating shadows in the framework.
  89442. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89443. */
  89444. export class ShadowGenerator implements IShadowGenerator {
  89445. /**
  89446. * Name of the shadow generator class
  89447. */
  89448. static CLASSNAME: string;
  89449. /**
  89450. * Shadow generator mode None: no filtering applied.
  89451. */
  89452. static readonly FILTER_NONE: number;
  89453. /**
  89454. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89455. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89456. */
  89457. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89458. /**
  89459. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89460. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89461. */
  89462. static readonly FILTER_POISSONSAMPLING: number;
  89463. /**
  89464. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89465. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89466. */
  89467. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89468. /**
  89469. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89470. * edge artifacts on steep falloff.
  89471. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89472. */
  89473. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89474. /**
  89475. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89476. * edge artifacts on steep falloff.
  89477. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89478. */
  89479. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89480. /**
  89481. * Shadow generator mode PCF: Percentage Closer Filtering
  89482. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89483. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89484. */
  89485. static readonly FILTER_PCF: number;
  89486. /**
  89487. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89488. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89489. * Contact Hardening
  89490. */
  89491. static readonly FILTER_PCSS: number;
  89492. /**
  89493. * Reserved for PCF and PCSS
  89494. * Highest Quality.
  89495. *
  89496. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89497. *
  89498. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89499. */
  89500. static readonly QUALITY_HIGH: number;
  89501. /**
  89502. * Reserved for PCF and PCSS
  89503. * Good tradeoff for quality/perf cross devices
  89504. *
  89505. * Execute PCF on a 3*3 kernel.
  89506. *
  89507. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89508. */
  89509. static readonly QUALITY_MEDIUM: number;
  89510. /**
  89511. * Reserved for PCF and PCSS
  89512. * The lowest quality but the fastest.
  89513. *
  89514. * Execute PCF on a 1*1 kernel.
  89515. *
  89516. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89517. */
  89518. static readonly QUALITY_LOW: number;
  89519. /** Gets or sets the custom shader name to use */
  89520. customShaderOptions: ICustomShaderOptions;
  89521. /**
  89522. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89523. */
  89524. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89525. /**
  89526. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89527. */
  89528. onAfterShadowMapRenderObservable: Observable<Effect>;
  89529. /**
  89530. * Observable triggered before a mesh is rendered in the shadow map.
  89531. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89532. */
  89533. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89534. /**
  89535. * Observable triggered after a mesh is rendered in the shadow map.
  89536. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89537. */
  89538. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89539. protected _bias: number;
  89540. /**
  89541. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89542. */
  89543. get bias(): number;
  89544. /**
  89545. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89546. */
  89547. set bias(bias: number);
  89548. protected _normalBias: number;
  89549. /**
  89550. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89551. */
  89552. get normalBias(): number;
  89553. /**
  89554. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89555. */
  89556. set normalBias(normalBias: number);
  89557. protected _blurBoxOffset: number;
  89558. /**
  89559. * Gets the blur box offset: offset applied during the blur pass.
  89560. * Only useful if useKernelBlur = false
  89561. */
  89562. get blurBoxOffset(): number;
  89563. /**
  89564. * Sets the blur box offset: offset applied during the blur pass.
  89565. * Only useful if useKernelBlur = false
  89566. */
  89567. set blurBoxOffset(value: number);
  89568. protected _blurScale: number;
  89569. /**
  89570. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89571. * 2 means half of the size.
  89572. */
  89573. get blurScale(): number;
  89574. /**
  89575. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89576. * 2 means half of the size.
  89577. */
  89578. set blurScale(value: number);
  89579. protected _blurKernel: number;
  89580. /**
  89581. * Gets the blur kernel: kernel size of the blur pass.
  89582. * Only useful if useKernelBlur = true
  89583. */
  89584. get blurKernel(): number;
  89585. /**
  89586. * Sets the blur kernel: kernel size of the blur pass.
  89587. * Only useful if useKernelBlur = true
  89588. */
  89589. set blurKernel(value: number);
  89590. protected _useKernelBlur: boolean;
  89591. /**
  89592. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89593. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89594. */
  89595. get useKernelBlur(): boolean;
  89596. /**
  89597. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89598. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89599. */
  89600. set useKernelBlur(value: boolean);
  89601. protected _depthScale: number;
  89602. /**
  89603. * Gets the depth scale used in ESM mode.
  89604. */
  89605. get depthScale(): number;
  89606. /**
  89607. * Sets the depth scale used in ESM mode.
  89608. * This can override the scale stored on the light.
  89609. */
  89610. set depthScale(value: number);
  89611. protected _validateFilter(filter: number): number;
  89612. protected _filter: number;
  89613. /**
  89614. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89615. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89616. */
  89617. get filter(): number;
  89618. /**
  89619. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89620. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89621. */
  89622. set filter(value: number);
  89623. /**
  89624. * Gets if the current filter is set to Poisson Sampling.
  89625. */
  89626. get usePoissonSampling(): boolean;
  89627. /**
  89628. * Sets the current filter to Poisson Sampling.
  89629. */
  89630. set usePoissonSampling(value: boolean);
  89631. /**
  89632. * Gets if the current filter is set to ESM.
  89633. */
  89634. get useExponentialShadowMap(): boolean;
  89635. /**
  89636. * Sets the current filter is to ESM.
  89637. */
  89638. set useExponentialShadowMap(value: boolean);
  89639. /**
  89640. * Gets if the current filter is set to filtered ESM.
  89641. */
  89642. get useBlurExponentialShadowMap(): boolean;
  89643. /**
  89644. * Gets if the current filter is set to filtered ESM.
  89645. */
  89646. set useBlurExponentialShadowMap(value: boolean);
  89647. /**
  89648. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89649. * exponential to prevent steep falloff artifacts).
  89650. */
  89651. get useCloseExponentialShadowMap(): boolean;
  89652. /**
  89653. * Sets the current filter to "close ESM" (using the inverse of the
  89654. * exponential to prevent steep falloff artifacts).
  89655. */
  89656. set useCloseExponentialShadowMap(value: boolean);
  89657. /**
  89658. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89659. * exponential to prevent steep falloff artifacts).
  89660. */
  89661. get useBlurCloseExponentialShadowMap(): boolean;
  89662. /**
  89663. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89664. * exponential to prevent steep falloff artifacts).
  89665. */
  89666. set useBlurCloseExponentialShadowMap(value: boolean);
  89667. /**
  89668. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89669. */
  89670. get usePercentageCloserFiltering(): boolean;
  89671. /**
  89672. * Sets the current filter to "PCF" (percentage closer filtering).
  89673. */
  89674. set usePercentageCloserFiltering(value: boolean);
  89675. protected _filteringQuality: number;
  89676. /**
  89677. * Gets the PCF or PCSS Quality.
  89678. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89679. */
  89680. get filteringQuality(): number;
  89681. /**
  89682. * Sets the PCF or PCSS Quality.
  89683. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89684. */
  89685. set filteringQuality(filteringQuality: number);
  89686. /**
  89687. * Gets if the current filter is set to "PCSS" (contact hardening).
  89688. */
  89689. get useContactHardeningShadow(): boolean;
  89690. /**
  89691. * Sets the current filter to "PCSS" (contact hardening).
  89692. */
  89693. set useContactHardeningShadow(value: boolean);
  89694. protected _contactHardeningLightSizeUVRatio: number;
  89695. /**
  89696. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89697. * Using a ratio helps keeping shape stability independently of the map size.
  89698. *
  89699. * It does not account for the light projection as it was having too much
  89700. * instability during the light setup or during light position changes.
  89701. *
  89702. * Only valid if useContactHardeningShadow is true.
  89703. */
  89704. get contactHardeningLightSizeUVRatio(): number;
  89705. /**
  89706. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89707. * Using a ratio helps keeping shape stability independently of the map size.
  89708. *
  89709. * It does not account for the light projection as it was having too much
  89710. * instability during the light setup or during light position changes.
  89711. *
  89712. * Only valid if useContactHardeningShadow is true.
  89713. */
  89714. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89715. protected _darkness: number;
  89716. /** Gets or sets the actual darkness of a shadow */
  89717. get darkness(): number;
  89718. set darkness(value: number);
  89719. /**
  89720. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89721. * 0 means strongest and 1 would means no shadow.
  89722. * @returns the darkness.
  89723. */
  89724. getDarkness(): number;
  89725. /**
  89726. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89727. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89728. * @returns the shadow generator allowing fluent coding.
  89729. */
  89730. setDarkness(darkness: number): ShadowGenerator;
  89731. protected _transparencyShadow: boolean;
  89732. /** Gets or sets the ability to have transparent shadow */
  89733. get transparencyShadow(): boolean;
  89734. set transparencyShadow(value: boolean);
  89735. /**
  89736. * Sets the ability to have transparent shadow (boolean).
  89737. * @param transparent True if transparent else False
  89738. * @returns the shadow generator allowing fluent coding
  89739. */
  89740. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89741. protected _shadowMap: Nullable<RenderTargetTexture>;
  89742. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89743. /**
  89744. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89745. * @returns The render target texture if present otherwise, null
  89746. */
  89747. getShadowMap(): Nullable<RenderTargetTexture>;
  89748. /**
  89749. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89750. * @returns The render target texture if the shadow map is present otherwise, null
  89751. */
  89752. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89753. /**
  89754. * Gets the class name of that object
  89755. * @returns "ShadowGenerator"
  89756. */
  89757. getClassName(): string;
  89758. /**
  89759. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89760. * @param mesh Mesh to add
  89761. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89762. * @returns the Shadow Generator itself
  89763. */
  89764. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89765. /**
  89766. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89767. * @param mesh Mesh to remove
  89768. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89769. * @returns the Shadow Generator itself
  89770. */
  89771. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89772. /**
  89773. * Controls the extent to which the shadows fade out at the edge of the frustum
  89774. */
  89775. frustumEdgeFalloff: number;
  89776. protected _light: IShadowLight;
  89777. /**
  89778. * Returns the associated light object.
  89779. * @returns the light generating the shadow
  89780. */
  89781. getLight(): IShadowLight;
  89782. /**
  89783. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89784. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89785. * It might on the other hand introduce peter panning.
  89786. */
  89787. forceBackFacesOnly: boolean;
  89788. protected _scene: Scene;
  89789. protected _lightDirection: Vector3;
  89790. protected _effect: Effect;
  89791. protected _viewMatrix: Matrix;
  89792. protected _projectionMatrix: Matrix;
  89793. protected _transformMatrix: Matrix;
  89794. protected _cachedPosition: Vector3;
  89795. protected _cachedDirection: Vector3;
  89796. protected _cachedDefines: string;
  89797. protected _currentRenderID: number;
  89798. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89799. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89800. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89801. protected _blurPostProcesses: PostProcess[];
  89802. protected _mapSize: number;
  89803. protected _currentFaceIndex: number;
  89804. protected _currentFaceIndexCache: number;
  89805. protected _textureType: number;
  89806. protected _defaultTextureMatrix: Matrix;
  89807. protected _storedUniqueId: Nullable<number>;
  89808. /** @hidden */
  89809. static _SceneComponentInitialization: (scene: Scene) => void;
  89810. /**
  89811. * Creates a ShadowGenerator object.
  89812. * A ShadowGenerator is the required tool to use the shadows.
  89813. * Each light casting shadows needs to use its own ShadowGenerator.
  89814. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89815. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89816. * @param light The light object generating the shadows.
  89817. * @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.
  89818. */
  89819. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89820. protected _initializeGenerator(): void;
  89821. protected _createTargetRenderTexture(): void;
  89822. protected _initializeShadowMap(): void;
  89823. protected _initializeBlurRTTAndPostProcesses(): void;
  89824. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89825. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89826. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89827. protected _applyFilterValues(): void;
  89828. /**
  89829. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89830. * @param onCompiled Callback triggered at the and of the effects compilation
  89831. * @param options Sets of optional options forcing the compilation with different modes
  89832. */
  89833. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89834. useInstances: boolean;
  89835. }>): void;
  89836. /**
  89837. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89838. * @param options Sets of optional options forcing the compilation with different modes
  89839. * @returns A promise that resolves when the compilation completes
  89840. */
  89841. forceCompilationAsync(options?: Partial<{
  89842. useInstances: boolean;
  89843. }>): Promise<void>;
  89844. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89845. /**
  89846. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89847. * @param subMesh The submesh we want to render in the shadow map
  89848. * @param useInstances Defines wether will draw in the map using instances
  89849. * @returns true if ready otherwise, false
  89850. */
  89851. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89852. /**
  89853. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89854. * @param defines Defines of the material we want to update
  89855. * @param lightIndex Index of the light in the enabled light list of the material
  89856. */
  89857. prepareDefines(defines: any, lightIndex: number): void;
  89858. /**
  89859. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89860. * defined in the generator but impacting the effect).
  89861. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89862. * @param effect The effect we are binfing the information for
  89863. */
  89864. bindShadowLight(lightIndex: string, effect: Effect): void;
  89865. /**
  89866. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89867. * (eq to shadow prjection matrix * light transform matrix)
  89868. * @returns The transform matrix used to create the shadow map
  89869. */
  89870. getTransformMatrix(): Matrix;
  89871. /**
  89872. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89873. * Cube and 2D textures for instance.
  89874. */
  89875. recreateShadowMap(): void;
  89876. protected _disposeBlurPostProcesses(): void;
  89877. protected _disposeRTTandPostProcesses(): void;
  89878. /**
  89879. * Disposes the ShadowGenerator.
  89880. * Returns nothing.
  89881. */
  89882. dispose(): void;
  89883. /**
  89884. * Serializes the shadow generator setup to a json object.
  89885. * @returns The serialized JSON object
  89886. */
  89887. serialize(): any;
  89888. /**
  89889. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89890. * @param parsedShadowGenerator The JSON object to parse
  89891. * @param scene The scene to create the shadow map for
  89892. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89893. * @returns The parsed shadow generator
  89894. */
  89895. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89896. }
  89897. }
  89898. declare module BABYLON {
  89899. /**
  89900. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89901. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89902. * 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.
  89903. */
  89904. export abstract class Light extends Node {
  89905. /**
  89906. * Falloff Default: light is falling off following the material specification:
  89907. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89908. */
  89909. static readonly FALLOFF_DEFAULT: number;
  89910. /**
  89911. * Falloff Physical: light is falling off following the inverse squared distance law.
  89912. */
  89913. static readonly FALLOFF_PHYSICAL: number;
  89914. /**
  89915. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89916. * to enhance interoperability with other engines.
  89917. */
  89918. static readonly FALLOFF_GLTF: number;
  89919. /**
  89920. * Falloff Standard: light is falling off like in the standard material
  89921. * to enhance interoperability with other materials.
  89922. */
  89923. static readonly FALLOFF_STANDARD: number;
  89924. /**
  89925. * If every light affecting the material is in this lightmapMode,
  89926. * material.lightmapTexture adds or multiplies
  89927. * (depends on material.useLightmapAsShadowmap)
  89928. * after every other light calculations.
  89929. */
  89930. static readonly LIGHTMAP_DEFAULT: number;
  89931. /**
  89932. * material.lightmapTexture as only diffuse lighting from this light
  89933. * adds only specular lighting from this light
  89934. * adds dynamic shadows
  89935. */
  89936. static readonly LIGHTMAP_SPECULAR: number;
  89937. /**
  89938. * material.lightmapTexture as only lighting
  89939. * no light calculation from this light
  89940. * only adds dynamic shadows from this light
  89941. */
  89942. static readonly LIGHTMAP_SHADOWSONLY: number;
  89943. /**
  89944. * Each light type uses the default quantity according to its type:
  89945. * point/spot lights use luminous intensity
  89946. * directional lights use illuminance
  89947. */
  89948. static readonly INTENSITYMODE_AUTOMATIC: number;
  89949. /**
  89950. * lumen (lm)
  89951. */
  89952. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89953. /**
  89954. * candela (lm/sr)
  89955. */
  89956. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89957. /**
  89958. * lux (lm/m^2)
  89959. */
  89960. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89961. /**
  89962. * nit (cd/m^2)
  89963. */
  89964. static readonly INTENSITYMODE_LUMINANCE: number;
  89965. /**
  89966. * Light type const id of the point light.
  89967. */
  89968. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89969. /**
  89970. * Light type const id of the directional light.
  89971. */
  89972. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89973. /**
  89974. * Light type const id of the spot light.
  89975. */
  89976. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89977. /**
  89978. * Light type const id of the hemispheric light.
  89979. */
  89980. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89981. /**
  89982. * Diffuse gives the basic color to an object.
  89983. */
  89984. diffuse: Color3;
  89985. /**
  89986. * Specular produces a highlight color on an object.
  89987. * Note: This is note affecting PBR materials.
  89988. */
  89989. specular: Color3;
  89990. /**
  89991. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89992. * falling off base on range or angle.
  89993. * This can be set to any values in Light.FALLOFF_x.
  89994. *
  89995. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89996. * other types of materials.
  89997. */
  89998. falloffType: number;
  89999. /**
  90000. * Strength of the light.
  90001. * Note: By default it is define in the framework own unit.
  90002. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90003. */
  90004. intensity: number;
  90005. private _range;
  90006. protected _inverseSquaredRange: number;
  90007. /**
  90008. * Defines how far from the source the light is impacting in scene units.
  90009. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90010. */
  90011. get range(): number;
  90012. /**
  90013. * Defines how far from the source the light is impacting in scene units.
  90014. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90015. */
  90016. set range(value: number);
  90017. /**
  90018. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90019. * of light.
  90020. */
  90021. private _photometricScale;
  90022. private _intensityMode;
  90023. /**
  90024. * Gets the photometric scale used to interpret the intensity.
  90025. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90026. */
  90027. get intensityMode(): number;
  90028. /**
  90029. * Sets the photometric scale used to interpret the intensity.
  90030. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90031. */
  90032. set intensityMode(value: number);
  90033. private _radius;
  90034. /**
  90035. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90036. */
  90037. get radius(): number;
  90038. /**
  90039. * sets the light radius used by PBR Materials to simulate soft area lights.
  90040. */
  90041. set radius(value: number);
  90042. private _renderPriority;
  90043. /**
  90044. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90045. * exceeding the number allowed of the materials.
  90046. */
  90047. renderPriority: number;
  90048. private _shadowEnabled;
  90049. /**
  90050. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90051. * the current shadow generator.
  90052. */
  90053. get shadowEnabled(): boolean;
  90054. /**
  90055. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90056. * the current shadow generator.
  90057. */
  90058. set shadowEnabled(value: boolean);
  90059. private _includedOnlyMeshes;
  90060. /**
  90061. * Gets the only meshes impacted by this light.
  90062. */
  90063. get includedOnlyMeshes(): AbstractMesh[];
  90064. /**
  90065. * Sets the only meshes impacted by this light.
  90066. */
  90067. set includedOnlyMeshes(value: AbstractMesh[]);
  90068. private _excludedMeshes;
  90069. /**
  90070. * Gets the meshes not impacted by this light.
  90071. */
  90072. get excludedMeshes(): AbstractMesh[];
  90073. /**
  90074. * Sets the meshes not impacted by this light.
  90075. */
  90076. set excludedMeshes(value: AbstractMesh[]);
  90077. private _excludeWithLayerMask;
  90078. /**
  90079. * Gets the layer id use to find what meshes are not impacted by the light.
  90080. * Inactive if 0
  90081. */
  90082. get excludeWithLayerMask(): number;
  90083. /**
  90084. * Sets the layer id use to find what meshes are not impacted by the light.
  90085. * Inactive if 0
  90086. */
  90087. set excludeWithLayerMask(value: number);
  90088. private _includeOnlyWithLayerMask;
  90089. /**
  90090. * Gets the layer id use to find what meshes are impacted by the light.
  90091. * Inactive if 0
  90092. */
  90093. get includeOnlyWithLayerMask(): number;
  90094. /**
  90095. * Sets the layer id use to find what meshes are impacted by the light.
  90096. * Inactive if 0
  90097. */
  90098. set includeOnlyWithLayerMask(value: number);
  90099. private _lightmapMode;
  90100. /**
  90101. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90102. */
  90103. get lightmapMode(): number;
  90104. /**
  90105. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90106. */
  90107. set lightmapMode(value: number);
  90108. /**
  90109. * Shadow generator associted to the light.
  90110. * @hidden Internal use only.
  90111. */
  90112. _shadowGenerator: Nullable<IShadowGenerator>;
  90113. /**
  90114. * @hidden Internal use only.
  90115. */
  90116. _excludedMeshesIds: string[];
  90117. /**
  90118. * @hidden Internal use only.
  90119. */
  90120. _includedOnlyMeshesIds: string[];
  90121. /**
  90122. * The current light unifom buffer.
  90123. * @hidden Internal use only.
  90124. */
  90125. _uniformBuffer: UniformBuffer;
  90126. /** @hidden */
  90127. _renderId: number;
  90128. /**
  90129. * Creates a Light object in the scene.
  90130. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90131. * @param name The firendly name of the light
  90132. * @param scene The scene the light belongs too
  90133. */
  90134. constructor(name: string, scene: Scene);
  90135. protected abstract _buildUniformLayout(): void;
  90136. /**
  90137. * Sets the passed Effect "effect" with the Light information.
  90138. * @param effect The effect to update
  90139. * @param lightIndex The index of the light in the effect to update
  90140. * @returns The light
  90141. */
  90142. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90143. /**
  90144. * Sets the passed Effect "effect" with the Light textures.
  90145. * @param effect The effect to update
  90146. * @param lightIndex The index of the light in the effect to update
  90147. * @returns The light
  90148. */
  90149. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90150. /**
  90151. * Binds the lights information from the scene to the effect for the given mesh.
  90152. * @param lightIndex Light index
  90153. * @param scene The scene where the light belongs to
  90154. * @param effect The effect we are binding the data to
  90155. * @param useSpecular Defines if specular is supported
  90156. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90157. */
  90158. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90159. /**
  90160. * Sets the passed Effect "effect" with the Light information.
  90161. * @param effect The effect to update
  90162. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90163. * @returns The light
  90164. */
  90165. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90166. /**
  90167. * Returns the string "Light".
  90168. * @returns the class name
  90169. */
  90170. getClassName(): string;
  90171. /** @hidden */
  90172. readonly _isLight: boolean;
  90173. /**
  90174. * Converts the light information to a readable string for debug purpose.
  90175. * @param fullDetails Supports for multiple levels of logging within scene loading
  90176. * @returns the human readable light info
  90177. */
  90178. toString(fullDetails?: boolean): string;
  90179. /** @hidden */
  90180. protected _syncParentEnabledState(): void;
  90181. /**
  90182. * Set the enabled state of this node.
  90183. * @param value - the new enabled state
  90184. */
  90185. setEnabled(value: boolean): void;
  90186. /**
  90187. * Returns the Light associated shadow generator if any.
  90188. * @return the associated shadow generator.
  90189. */
  90190. getShadowGenerator(): Nullable<IShadowGenerator>;
  90191. /**
  90192. * Returns a Vector3, the absolute light position in the World.
  90193. * @returns the world space position of the light
  90194. */
  90195. getAbsolutePosition(): Vector3;
  90196. /**
  90197. * Specifies if the light will affect the passed mesh.
  90198. * @param mesh The mesh to test against the light
  90199. * @return true the mesh is affected otherwise, false.
  90200. */
  90201. canAffectMesh(mesh: AbstractMesh): boolean;
  90202. /**
  90203. * Sort function to order lights for rendering.
  90204. * @param a First Light object to compare to second.
  90205. * @param b Second Light object to compare first.
  90206. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90207. */
  90208. static CompareLightsPriority(a: Light, b: Light): number;
  90209. /**
  90210. * Releases resources associated with this node.
  90211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90213. */
  90214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90215. /**
  90216. * Returns the light type ID (integer).
  90217. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90218. */
  90219. getTypeID(): number;
  90220. /**
  90221. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90222. * @returns the scaled intensity in intensity mode unit
  90223. */
  90224. getScaledIntensity(): number;
  90225. /**
  90226. * Returns a new Light object, named "name", from the current one.
  90227. * @param name The name of the cloned light
  90228. * @returns the new created light
  90229. */
  90230. clone(name: string): Nullable<Light>;
  90231. /**
  90232. * Serializes the current light into a Serialization object.
  90233. * @returns the serialized object.
  90234. */
  90235. serialize(): any;
  90236. /**
  90237. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90238. * This new light is named "name" and added to the passed scene.
  90239. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90240. * @param name The friendly name of the light
  90241. * @param scene The scene the new light will belong to
  90242. * @returns the constructor function
  90243. */
  90244. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90245. /**
  90246. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90247. * @param parsedLight The JSON representation of the light
  90248. * @param scene The scene to create the parsed light in
  90249. * @returns the created light after parsing
  90250. */
  90251. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90252. private _hookArrayForExcluded;
  90253. private _hookArrayForIncludedOnly;
  90254. private _resyncMeshes;
  90255. /**
  90256. * Forces the meshes to update their light related information in their rendering used effects
  90257. * @hidden Internal Use Only
  90258. */
  90259. _markMeshesAsLightDirty(): void;
  90260. /**
  90261. * Recomputes the cached photometric scale if needed.
  90262. */
  90263. private _computePhotometricScale;
  90264. /**
  90265. * Returns the Photometric Scale according to the light type and intensity mode.
  90266. */
  90267. private _getPhotometricScale;
  90268. /**
  90269. * Reorder the light in the scene according to their defined priority.
  90270. * @hidden Internal Use Only
  90271. */
  90272. _reorderLightsInScene(): void;
  90273. /**
  90274. * Prepares the list of defines specific to the light type.
  90275. * @param defines the list of defines
  90276. * @param lightIndex defines the index of the light for the effect
  90277. */
  90278. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90279. }
  90280. }
  90281. declare module BABYLON {
  90282. /**
  90283. * Interface used to define Action
  90284. */
  90285. export interface IAction {
  90286. /**
  90287. * Trigger for the action
  90288. */
  90289. trigger: number;
  90290. /** Options of the trigger */
  90291. triggerOptions: any;
  90292. /**
  90293. * Gets the trigger parameters
  90294. * @returns the trigger parameters
  90295. */
  90296. getTriggerParameter(): any;
  90297. /**
  90298. * Internal only - executes current action event
  90299. * @hidden
  90300. */
  90301. _executeCurrent(evt?: ActionEvent): void;
  90302. /**
  90303. * Serialize placeholder for child classes
  90304. * @param parent of child
  90305. * @returns the serialized object
  90306. */
  90307. serialize(parent: any): any;
  90308. /**
  90309. * Internal only
  90310. * @hidden
  90311. */
  90312. _prepare(): void;
  90313. /**
  90314. * Internal only - manager for action
  90315. * @hidden
  90316. */
  90317. _actionManager: AbstractActionManager;
  90318. /**
  90319. * Adds action to chain of actions, may be a DoNothingAction
  90320. * @param action defines the next action to execute
  90321. * @returns The action passed in
  90322. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90323. */
  90324. then(action: IAction): IAction;
  90325. }
  90326. /**
  90327. * The action to be carried out following a trigger
  90328. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90329. */
  90330. export class Action implements IAction {
  90331. /** the trigger, with or without parameters, for the action */
  90332. triggerOptions: any;
  90333. /**
  90334. * Trigger for the action
  90335. */
  90336. trigger: number;
  90337. /**
  90338. * Internal only - manager for action
  90339. * @hidden
  90340. */
  90341. _actionManager: ActionManager;
  90342. private _nextActiveAction;
  90343. private _child;
  90344. private _condition?;
  90345. private _triggerParameter;
  90346. /**
  90347. * An event triggered prior to action being executed.
  90348. */
  90349. onBeforeExecuteObservable: Observable<Action>;
  90350. /**
  90351. * Creates a new Action
  90352. * @param triggerOptions the trigger, with or without parameters, for the action
  90353. * @param condition an optional determinant of action
  90354. */
  90355. constructor(
  90356. /** the trigger, with or without parameters, for the action */
  90357. triggerOptions: any, condition?: Condition);
  90358. /**
  90359. * Internal only
  90360. * @hidden
  90361. */
  90362. _prepare(): void;
  90363. /**
  90364. * Gets the trigger parameters
  90365. * @returns the trigger parameters
  90366. */
  90367. getTriggerParameter(): any;
  90368. /**
  90369. * Internal only - executes current action event
  90370. * @hidden
  90371. */
  90372. _executeCurrent(evt?: ActionEvent): void;
  90373. /**
  90374. * Execute placeholder for child classes
  90375. * @param evt optional action event
  90376. */
  90377. execute(evt?: ActionEvent): void;
  90378. /**
  90379. * Skips to next active action
  90380. */
  90381. skipToNextActiveAction(): void;
  90382. /**
  90383. * Adds action to chain of actions, may be a DoNothingAction
  90384. * @param action defines the next action to execute
  90385. * @returns The action passed in
  90386. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90387. */
  90388. then(action: Action): Action;
  90389. /**
  90390. * Internal only
  90391. * @hidden
  90392. */
  90393. _getProperty(propertyPath: string): string;
  90394. /**
  90395. * Internal only
  90396. * @hidden
  90397. */
  90398. _getEffectiveTarget(target: any, propertyPath: string): any;
  90399. /**
  90400. * Serialize placeholder for child classes
  90401. * @param parent of child
  90402. * @returns the serialized object
  90403. */
  90404. serialize(parent: any): any;
  90405. /**
  90406. * Internal only called by serialize
  90407. * @hidden
  90408. */
  90409. protected _serialize(serializedAction: any, parent?: any): any;
  90410. /**
  90411. * Internal only
  90412. * @hidden
  90413. */
  90414. static _SerializeValueAsString: (value: any) => string;
  90415. /**
  90416. * Internal only
  90417. * @hidden
  90418. */
  90419. static _GetTargetProperty: (target: Node | Scene) => {
  90420. name: string;
  90421. targetType: string;
  90422. value: string;
  90423. };
  90424. }
  90425. }
  90426. declare module BABYLON {
  90427. /**
  90428. * A Condition applied to an Action
  90429. */
  90430. export class Condition {
  90431. /**
  90432. * Internal only - manager for action
  90433. * @hidden
  90434. */
  90435. _actionManager: ActionManager;
  90436. /**
  90437. * Internal only
  90438. * @hidden
  90439. */
  90440. _evaluationId: number;
  90441. /**
  90442. * Internal only
  90443. * @hidden
  90444. */
  90445. _currentResult: boolean;
  90446. /**
  90447. * Creates a new Condition
  90448. * @param actionManager the manager of the action the condition is applied to
  90449. */
  90450. constructor(actionManager: ActionManager);
  90451. /**
  90452. * Check if the current condition is valid
  90453. * @returns a boolean
  90454. */
  90455. isValid(): boolean;
  90456. /**
  90457. * Internal only
  90458. * @hidden
  90459. */
  90460. _getProperty(propertyPath: string): string;
  90461. /**
  90462. * Internal only
  90463. * @hidden
  90464. */
  90465. _getEffectiveTarget(target: any, propertyPath: string): any;
  90466. /**
  90467. * Serialize placeholder for child classes
  90468. * @returns the serialized object
  90469. */
  90470. serialize(): any;
  90471. /**
  90472. * Internal only
  90473. * @hidden
  90474. */
  90475. protected _serialize(serializedCondition: any): any;
  90476. }
  90477. /**
  90478. * Defines specific conditional operators as extensions of Condition
  90479. */
  90480. export class ValueCondition extends Condition {
  90481. /** path to specify the property of the target the conditional operator uses */
  90482. propertyPath: string;
  90483. /** the value compared by the conditional operator against the current value of the property */
  90484. value: any;
  90485. /** the conditional operator, default ValueCondition.IsEqual */
  90486. operator: number;
  90487. /**
  90488. * Internal only
  90489. * @hidden
  90490. */
  90491. private static _IsEqual;
  90492. /**
  90493. * Internal only
  90494. * @hidden
  90495. */
  90496. private static _IsDifferent;
  90497. /**
  90498. * Internal only
  90499. * @hidden
  90500. */
  90501. private static _IsGreater;
  90502. /**
  90503. * Internal only
  90504. * @hidden
  90505. */
  90506. private static _IsLesser;
  90507. /**
  90508. * returns the number for IsEqual
  90509. */
  90510. static get IsEqual(): number;
  90511. /**
  90512. * Returns the number for IsDifferent
  90513. */
  90514. static get IsDifferent(): number;
  90515. /**
  90516. * Returns the number for IsGreater
  90517. */
  90518. static get IsGreater(): number;
  90519. /**
  90520. * Returns the number for IsLesser
  90521. */
  90522. static get IsLesser(): number;
  90523. /**
  90524. * Internal only The action manager for the condition
  90525. * @hidden
  90526. */
  90527. _actionManager: ActionManager;
  90528. /**
  90529. * Internal only
  90530. * @hidden
  90531. */
  90532. private _target;
  90533. /**
  90534. * Internal only
  90535. * @hidden
  90536. */
  90537. private _effectiveTarget;
  90538. /**
  90539. * Internal only
  90540. * @hidden
  90541. */
  90542. private _property;
  90543. /**
  90544. * Creates a new ValueCondition
  90545. * @param actionManager manager for the action the condition applies to
  90546. * @param target for the action
  90547. * @param propertyPath path to specify the property of the target the conditional operator uses
  90548. * @param value the value compared by the conditional operator against the current value of the property
  90549. * @param operator the conditional operator, default ValueCondition.IsEqual
  90550. */
  90551. constructor(actionManager: ActionManager, target: any,
  90552. /** path to specify the property of the target the conditional operator uses */
  90553. propertyPath: string,
  90554. /** the value compared by the conditional operator against the current value of the property */
  90555. value: any,
  90556. /** the conditional operator, default ValueCondition.IsEqual */
  90557. operator?: number);
  90558. /**
  90559. * Compares the given value with the property value for the specified conditional operator
  90560. * @returns the result of the comparison
  90561. */
  90562. isValid(): boolean;
  90563. /**
  90564. * Serialize the ValueCondition into a JSON compatible object
  90565. * @returns serialization object
  90566. */
  90567. serialize(): any;
  90568. /**
  90569. * Gets the name of the conditional operator for the ValueCondition
  90570. * @param operator the conditional operator
  90571. * @returns the name
  90572. */
  90573. static GetOperatorName(operator: number): string;
  90574. }
  90575. /**
  90576. * Defines a predicate condition as an extension of Condition
  90577. */
  90578. export class PredicateCondition extends Condition {
  90579. /** defines the predicate function used to validate the condition */
  90580. predicate: () => boolean;
  90581. /**
  90582. * Internal only - manager for action
  90583. * @hidden
  90584. */
  90585. _actionManager: ActionManager;
  90586. /**
  90587. * Creates a new PredicateCondition
  90588. * @param actionManager manager for the action the condition applies to
  90589. * @param predicate defines the predicate function used to validate the condition
  90590. */
  90591. constructor(actionManager: ActionManager,
  90592. /** defines the predicate function used to validate the condition */
  90593. predicate: () => boolean);
  90594. /**
  90595. * @returns the validity of the predicate condition
  90596. */
  90597. isValid(): boolean;
  90598. }
  90599. /**
  90600. * Defines a state condition as an extension of Condition
  90601. */
  90602. export class StateCondition extends Condition {
  90603. /** Value to compare with target state */
  90604. value: string;
  90605. /**
  90606. * Internal only - manager for action
  90607. * @hidden
  90608. */
  90609. _actionManager: ActionManager;
  90610. /**
  90611. * Internal only
  90612. * @hidden
  90613. */
  90614. private _target;
  90615. /**
  90616. * Creates a new StateCondition
  90617. * @param actionManager manager for the action the condition applies to
  90618. * @param target of the condition
  90619. * @param value to compare with target state
  90620. */
  90621. constructor(actionManager: ActionManager, target: any,
  90622. /** Value to compare with target state */
  90623. value: string);
  90624. /**
  90625. * Gets a boolean indicating if the current condition is met
  90626. * @returns the validity of the state
  90627. */
  90628. isValid(): boolean;
  90629. /**
  90630. * Serialize the StateCondition into a JSON compatible object
  90631. * @returns serialization object
  90632. */
  90633. serialize(): any;
  90634. }
  90635. }
  90636. declare module BABYLON {
  90637. /**
  90638. * This defines an action responsible to toggle a boolean once triggered.
  90639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90640. */
  90641. export class SwitchBooleanAction extends Action {
  90642. /**
  90643. * The path to the boolean property in the target object
  90644. */
  90645. propertyPath: string;
  90646. private _target;
  90647. private _effectiveTarget;
  90648. private _property;
  90649. /**
  90650. * Instantiate the action
  90651. * @param triggerOptions defines the trigger options
  90652. * @param target defines the object containing the boolean
  90653. * @param propertyPath defines the path to the boolean property in the target object
  90654. * @param condition defines the trigger related conditions
  90655. */
  90656. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90657. /** @hidden */
  90658. _prepare(): void;
  90659. /**
  90660. * Execute the action toggle the boolean value.
  90661. */
  90662. execute(): void;
  90663. /**
  90664. * Serializes the actions and its related information.
  90665. * @param parent defines the object to serialize in
  90666. * @returns the serialized object
  90667. */
  90668. serialize(parent: any): any;
  90669. }
  90670. /**
  90671. * This defines an action responsible to set a the state field of the target
  90672. * to a desired value once triggered.
  90673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90674. */
  90675. export class SetStateAction extends Action {
  90676. /**
  90677. * The value to store in the state field.
  90678. */
  90679. value: string;
  90680. private _target;
  90681. /**
  90682. * Instantiate the action
  90683. * @param triggerOptions defines the trigger options
  90684. * @param target defines the object containing the state property
  90685. * @param value defines the value to store in the state field
  90686. * @param condition defines the trigger related conditions
  90687. */
  90688. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90689. /**
  90690. * Execute the action and store the value on the target state property.
  90691. */
  90692. execute(): void;
  90693. /**
  90694. * Serializes the actions and its related information.
  90695. * @param parent defines the object to serialize in
  90696. * @returns the serialized object
  90697. */
  90698. serialize(parent: any): any;
  90699. }
  90700. /**
  90701. * This defines an action responsible to set a property of the target
  90702. * to a desired value once triggered.
  90703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90704. */
  90705. export class SetValueAction extends Action {
  90706. /**
  90707. * The path of the property to set in the target.
  90708. */
  90709. propertyPath: string;
  90710. /**
  90711. * The value to set in the property
  90712. */
  90713. value: any;
  90714. private _target;
  90715. private _effectiveTarget;
  90716. private _property;
  90717. /**
  90718. * Instantiate the action
  90719. * @param triggerOptions defines the trigger options
  90720. * @param target defines the object containing the property
  90721. * @param propertyPath defines the path of the property to set in the target
  90722. * @param value defines the value to set in the property
  90723. * @param condition defines the trigger related conditions
  90724. */
  90725. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90726. /** @hidden */
  90727. _prepare(): void;
  90728. /**
  90729. * Execute the action and set the targetted property to the desired value.
  90730. */
  90731. execute(): void;
  90732. /**
  90733. * Serializes the actions and its related information.
  90734. * @param parent defines the object to serialize in
  90735. * @returns the serialized object
  90736. */
  90737. serialize(parent: any): any;
  90738. }
  90739. /**
  90740. * This defines an action responsible to increment the target value
  90741. * to a desired value once triggered.
  90742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90743. */
  90744. export class IncrementValueAction extends Action {
  90745. /**
  90746. * The path of the property to increment in the target.
  90747. */
  90748. propertyPath: string;
  90749. /**
  90750. * The value we should increment the property by.
  90751. */
  90752. value: any;
  90753. private _target;
  90754. private _effectiveTarget;
  90755. private _property;
  90756. /**
  90757. * Instantiate the action
  90758. * @param triggerOptions defines the trigger options
  90759. * @param target defines the object containing the property
  90760. * @param propertyPath defines the path of the property to increment in the target
  90761. * @param value defines the value value we should increment the property by
  90762. * @param condition defines the trigger related conditions
  90763. */
  90764. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90765. /** @hidden */
  90766. _prepare(): void;
  90767. /**
  90768. * Execute the action and increment the target of the value amount.
  90769. */
  90770. execute(): void;
  90771. /**
  90772. * Serializes the actions and its related information.
  90773. * @param parent defines the object to serialize in
  90774. * @returns the serialized object
  90775. */
  90776. serialize(parent: any): any;
  90777. }
  90778. /**
  90779. * This defines an action responsible to start an animation once triggered.
  90780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90781. */
  90782. export class PlayAnimationAction extends Action {
  90783. /**
  90784. * Where the animation should start (animation frame)
  90785. */
  90786. from: number;
  90787. /**
  90788. * Where the animation should stop (animation frame)
  90789. */
  90790. to: number;
  90791. /**
  90792. * Define if the animation should loop or stop after the first play.
  90793. */
  90794. loop?: boolean;
  90795. private _target;
  90796. /**
  90797. * Instantiate the action
  90798. * @param triggerOptions defines the trigger options
  90799. * @param target defines the target animation or animation name
  90800. * @param from defines from where the animation should start (animation frame)
  90801. * @param end defines where the animation should stop (animation frame)
  90802. * @param loop defines if the animation should loop or stop after the first play
  90803. * @param condition defines the trigger related conditions
  90804. */
  90805. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90806. /** @hidden */
  90807. _prepare(): void;
  90808. /**
  90809. * Execute the action and play the animation.
  90810. */
  90811. execute(): void;
  90812. /**
  90813. * Serializes the actions and its related information.
  90814. * @param parent defines the object to serialize in
  90815. * @returns the serialized object
  90816. */
  90817. serialize(parent: any): any;
  90818. }
  90819. /**
  90820. * This defines an action responsible to stop an animation once triggered.
  90821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90822. */
  90823. export class StopAnimationAction extends Action {
  90824. private _target;
  90825. /**
  90826. * Instantiate the action
  90827. * @param triggerOptions defines the trigger options
  90828. * @param target defines the target animation or animation name
  90829. * @param condition defines the trigger related conditions
  90830. */
  90831. constructor(triggerOptions: any, target: any, condition?: Condition);
  90832. /** @hidden */
  90833. _prepare(): void;
  90834. /**
  90835. * Execute the action and stop the animation.
  90836. */
  90837. execute(): void;
  90838. /**
  90839. * Serializes the actions and its related information.
  90840. * @param parent defines the object to serialize in
  90841. * @returns the serialized object
  90842. */
  90843. serialize(parent: any): any;
  90844. }
  90845. /**
  90846. * This defines an action responsible that does nothing once triggered.
  90847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90848. */
  90849. export class DoNothingAction extends Action {
  90850. /**
  90851. * Instantiate the action
  90852. * @param triggerOptions defines the trigger options
  90853. * @param condition defines the trigger related conditions
  90854. */
  90855. constructor(triggerOptions?: any, condition?: Condition);
  90856. /**
  90857. * Execute the action and do nothing.
  90858. */
  90859. execute(): void;
  90860. /**
  90861. * Serializes the actions and its related information.
  90862. * @param parent defines the object to serialize in
  90863. * @returns the serialized object
  90864. */
  90865. serialize(parent: any): any;
  90866. }
  90867. /**
  90868. * This defines an action responsible to trigger several actions once triggered.
  90869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90870. */
  90871. export class CombineAction extends Action {
  90872. /**
  90873. * The list of aggregated animations to run.
  90874. */
  90875. children: Action[];
  90876. /**
  90877. * Instantiate the action
  90878. * @param triggerOptions defines the trigger options
  90879. * @param children defines the list of aggregated animations to run
  90880. * @param condition defines the trigger related conditions
  90881. */
  90882. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90883. /** @hidden */
  90884. _prepare(): void;
  90885. /**
  90886. * Execute the action and executes all the aggregated actions.
  90887. */
  90888. execute(evt: ActionEvent): void;
  90889. /**
  90890. * Serializes the actions and its related information.
  90891. * @param parent defines the object to serialize in
  90892. * @returns the serialized object
  90893. */
  90894. serialize(parent: any): any;
  90895. }
  90896. /**
  90897. * This defines an action responsible to run code (external event) once triggered.
  90898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90899. */
  90900. export class ExecuteCodeAction extends Action {
  90901. /**
  90902. * The callback function to run.
  90903. */
  90904. func: (evt: ActionEvent) => void;
  90905. /**
  90906. * Instantiate the action
  90907. * @param triggerOptions defines the trigger options
  90908. * @param func defines the callback function to run
  90909. * @param condition defines the trigger related conditions
  90910. */
  90911. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90912. /**
  90913. * Execute the action and run the attached code.
  90914. */
  90915. execute(evt: ActionEvent): void;
  90916. }
  90917. /**
  90918. * This defines an action responsible to set the parent property of the target once triggered.
  90919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90920. */
  90921. export class SetParentAction extends Action {
  90922. private _parent;
  90923. private _target;
  90924. /**
  90925. * Instantiate the action
  90926. * @param triggerOptions defines the trigger options
  90927. * @param target defines the target containing the parent property
  90928. * @param parent defines from where the animation should start (animation frame)
  90929. * @param condition defines the trigger related conditions
  90930. */
  90931. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90932. /** @hidden */
  90933. _prepare(): void;
  90934. /**
  90935. * Execute the action and set the parent property.
  90936. */
  90937. execute(): void;
  90938. /**
  90939. * Serializes the actions and its related information.
  90940. * @param parent defines the object to serialize in
  90941. * @returns the serialized object
  90942. */
  90943. serialize(parent: any): any;
  90944. }
  90945. }
  90946. declare module BABYLON {
  90947. /**
  90948. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90949. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90951. */
  90952. export class ActionManager extends AbstractActionManager {
  90953. /**
  90954. * Nothing
  90955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90956. */
  90957. static readonly NothingTrigger: number;
  90958. /**
  90959. * On pick
  90960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90961. */
  90962. static readonly OnPickTrigger: number;
  90963. /**
  90964. * On left pick
  90965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90966. */
  90967. static readonly OnLeftPickTrigger: number;
  90968. /**
  90969. * On right pick
  90970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90971. */
  90972. static readonly OnRightPickTrigger: number;
  90973. /**
  90974. * On center pick
  90975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90976. */
  90977. static readonly OnCenterPickTrigger: number;
  90978. /**
  90979. * On pick down
  90980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90981. */
  90982. static readonly OnPickDownTrigger: number;
  90983. /**
  90984. * On double pick
  90985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90986. */
  90987. static readonly OnDoublePickTrigger: number;
  90988. /**
  90989. * On pick up
  90990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90991. */
  90992. static readonly OnPickUpTrigger: number;
  90993. /**
  90994. * On pick out.
  90995. * This trigger will only be raised if you also declared a OnPickDown
  90996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90997. */
  90998. static readonly OnPickOutTrigger: number;
  90999. /**
  91000. * On long press
  91001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91002. */
  91003. static readonly OnLongPressTrigger: number;
  91004. /**
  91005. * On pointer over
  91006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91007. */
  91008. static readonly OnPointerOverTrigger: number;
  91009. /**
  91010. * On pointer out
  91011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91012. */
  91013. static readonly OnPointerOutTrigger: number;
  91014. /**
  91015. * On every frame
  91016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91017. */
  91018. static readonly OnEveryFrameTrigger: number;
  91019. /**
  91020. * On intersection enter
  91021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91022. */
  91023. static readonly OnIntersectionEnterTrigger: number;
  91024. /**
  91025. * On intersection exit
  91026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91027. */
  91028. static readonly OnIntersectionExitTrigger: number;
  91029. /**
  91030. * On key down
  91031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91032. */
  91033. static readonly OnKeyDownTrigger: number;
  91034. /**
  91035. * On key up
  91036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91037. */
  91038. static readonly OnKeyUpTrigger: number;
  91039. private _scene;
  91040. /**
  91041. * Creates a new action manager
  91042. * @param scene defines the hosting scene
  91043. */
  91044. constructor(scene: Scene);
  91045. /**
  91046. * Releases all associated resources
  91047. */
  91048. dispose(): void;
  91049. /**
  91050. * Gets hosting scene
  91051. * @returns the hosting scene
  91052. */
  91053. getScene(): Scene;
  91054. /**
  91055. * Does this action manager handles actions of any of the given triggers
  91056. * @param triggers defines the triggers to be tested
  91057. * @return a boolean indicating whether one (or more) of the triggers is handled
  91058. */
  91059. hasSpecificTriggers(triggers: number[]): boolean;
  91060. /**
  91061. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91062. * speed.
  91063. * @param triggerA defines the trigger to be tested
  91064. * @param triggerB defines the trigger to be tested
  91065. * @return a boolean indicating whether one (or more) of the triggers is handled
  91066. */
  91067. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91068. /**
  91069. * Does this action manager handles actions of a given trigger
  91070. * @param trigger defines the trigger to be tested
  91071. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91072. * @return whether the trigger is handled
  91073. */
  91074. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91075. /**
  91076. * Does this action manager has pointer triggers
  91077. */
  91078. get hasPointerTriggers(): boolean;
  91079. /**
  91080. * Does this action manager has pick triggers
  91081. */
  91082. get hasPickTriggers(): boolean;
  91083. /**
  91084. * Registers an action to this action manager
  91085. * @param action defines the action to be registered
  91086. * @return the action amended (prepared) after registration
  91087. */
  91088. registerAction(action: IAction): Nullable<IAction>;
  91089. /**
  91090. * Unregisters an action to this action manager
  91091. * @param action defines the action to be unregistered
  91092. * @return a boolean indicating whether the action has been unregistered
  91093. */
  91094. unregisterAction(action: IAction): Boolean;
  91095. /**
  91096. * Process a specific trigger
  91097. * @param trigger defines the trigger to process
  91098. * @param evt defines the event details to be processed
  91099. */
  91100. processTrigger(trigger: number, evt?: IActionEvent): void;
  91101. /** @hidden */
  91102. _getEffectiveTarget(target: any, propertyPath: string): any;
  91103. /** @hidden */
  91104. _getProperty(propertyPath: string): string;
  91105. /**
  91106. * Serialize this manager to a JSON object
  91107. * @param name defines the property name to store this manager
  91108. * @returns a JSON representation of this manager
  91109. */
  91110. serialize(name: string): any;
  91111. /**
  91112. * Creates a new ActionManager from a JSON data
  91113. * @param parsedActions defines the JSON data to read from
  91114. * @param object defines the hosting mesh
  91115. * @param scene defines the hosting scene
  91116. */
  91117. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91118. /**
  91119. * Get a trigger name by index
  91120. * @param trigger defines the trigger index
  91121. * @returns a trigger name
  91122. */
  91123. static GetTriggerName(trigger: number): string;
  91124. }
  91125. }
  91126. declare module BABYLON {
  91127. /**
  91128. * Class used to represent a sprite
  91129. * @see http://doc.babylonjs.com/babylon101/sprites
  91130. */
  91131. export class Sprite {
  91132. /** defines the name */
  91133. name: string;
  91134. /** Gets or sets the current world position */
  91135. position: Vector3;
  91136. /** Gets or sets the main color */
  91137. color: Color4;
  91138. /** Gets or sets the width */
  91139. width: number;
  91140. /** Gets or sets the height */
  91141. height: number;
  91142. /** Gets or sets rotation angle */
  91143. angle: number;
  91144. /** Gets or sets the cell index in the sprite sheet */
  91145. cellIndex: number;
  91146. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91147. cellRef: string;
  91148. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91149. invertU: number;
  91150. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91151. invertV: number;
  91152. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91153. disposeWhenFinishedAnimating: boolean;
  91154. /** Gets the list of attached animations */
  91155. animations: Animation[];
  91156. /** Gets or sets a boolean indicating if the sprite can be picked */
  91157. isPickable: boolean;
  91158. /**
  91159. * Gets or sets the associated action manager
  91160. */
  91161. actionManager: Nullable<ActionManager>;
  91162. private _animationStarted;
  91163. private _loopAnimation;
  91164. private _fromIndex;
  91165. private _toIndex;
  91166. private _delay;
  91167. private _direction;
  91168. private _manager;
  91169. private _time;
  91170. private _onAnimationEnd;
  91171. /**
  91172. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91173. */
  91174. isVisible: boolean;
  91175. /**
  91176. * Gets or sets the sprite size
  91177. */
  91178. get size(): number;
  91179. set size(value: number);
  91180. /**
  91181. * Creates a new Sprite
  91182. * @param name defines the name
  91183. * @param manager defines the manager
  91184. */
  91185. constructor(
  91186. /** defines the name */
  91187. name: string, manager: ISpriteManager);
  91188. /**
  91189. * Starts an animation
  91190. * @param from defines the initial key
  91191. * @param to defines the end key
  91192. * @param loop defines if the animation must loop
  91193. * @param delay defines the start delay (in ms)
  91194. * @param onAnimationEnd defines a callback to call when animation ends
  91195. */
  91196. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91197. /** Stops current animation (if any) */
  91198. stopAnimation(): void;
  91199. /** @hidden */
  91200. _animate(deltaTime: number): void;
  91201. /** Release associated resources */
  91202. dispose(): void;
  91203. }
  91204. }
  91205. declare module BABYLON {
  91206. /**
  91207. * Information about the result of picking within a scene
  91208. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91209. */
  91210. export class PickingInfo {
  91211. /** @hidden */
  91212. _pickingUnavailable: boolean;
  91213. /**
  91214. * If the pick collided with an object
  91215. */
  91216. hit: boolean;
  91217. /**
  91218. * Distance away where the pick collided
  91219. */
  91220. distance: number;
  91221. /**
  91222. * The location of pick collision
  91223. */
  91224. pickedPoint: Nullable<Vector3>;
  91225. /**
  91226. * The mesh corresponding the the pick collision
  91227. */
  91228. pickedMesh: Nullable<AbstractMesh>;
  91229. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91230. bu: number;
  91231. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91232. bv: number;
  91233. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91234. faceId: number;
  91235. /** Id of the the submesh that was picked */
  91236. subMeshId: number;
  91237. /** If a sprite was picked, this will be the sprite the pick collided with */
  91238. pickedSprite: Nullable<Sprite>;
  91239. /**
  91240. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91241. */
  91242. originMesh: Nullable<AbstractMesh>;
  91243. /**
  91244. * The ray that was used to perform the picking.
  91245. */
  91246. ray: Nullable<Ray>;
  91247. /**
  91248. * Gets the normal correspodning to the face the pick collided with
  91249. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91250. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91251. * @returns The normal correspodning to the face the pick collided with
  91252. */
  91253. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91254. /**
  91255. * Gets the texture coordinates of where the pick occured
  91256. * @returns the vector containing the coordnates of the texture
  91257. */
  91258. getTextureCoordinates(): Nullable<Vector2>;
  91259. }
  91260. }
  91261. declare module BABYLON {
  91262. /**
  91263. * Gather the list of pointer event types as constants.
  91264. */
  91265. export class PointerEventTypes {
  91266. /**
  91267. * 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.
  91268. */
  91269. static readonly POINTERDOWN: number;
  91270. /**
  91271. * The pointerup event is fired when a pointer is no longer active.
  91272. */
  91273. static readonly POINTERUP: number;
  91274. /**
  91275. * The pointermove event is fired when a pointer changes coordinates.
  91276. */
  91277. static readonly POINTERMOVE: number;
  91278. /**
  91279. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91280. */
  91281. static readonly POINTERWHEEL: number;
  91282. /**
  91283. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91284. */
  91285. static readonly POINTERPICK: number;
  91286. /**
  91287. * The pointertap event is fired when a the object has been touched and released without drag.
  91288. */
  91289. static readonly POINTERTAP: number;
  91290. /**
  91291. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91292. */
  91293. static readonly POINTERDOUBLETAP: number;
  91294. }
  91295. /**
  91296. * Base class of pointer info types.
  91297. */
  91298. export class PointerInfoBase {
  91299. /**
  91300. * Defines the type of event (PointerEventTypes)
  91301. */
  91302. type: number;
  91303. /**
  91304. * Defines the related dom event
  91305. */
  91306. event: PointerEvent | MouseWheelEvent;
  91307. /**
  91308. * Instantiates the base class of pointers info.
  91309. * @param type Defines the type of event (PointerEventTypes)
  91310. * @param event Defines the related dom event
  91311. */
  91312. constructor(
  91313. /**
  91314. * Defines the type of event (PointerEventTypes)
  91315. */
  91316. type: number,
  91317. /**
  91318. * Defines the related dom event
  91319. */
  91320. event: PointerEvent | MouseWheelEvent);
  91321. }
  91322. /**
  91323. * This class is used to store pointer related info for the onPrePointerObservable event.
  91324. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91325. */
  91326. export class PointerInfoPre extends PointerInfoBase {
  91327. /**
  91328. * Ray from a pointer if availible (eg. 6dof controller)
  91329. */
  91330. ray: Nullable<Ray>;
  91331. /**
  91332. * Defines the local position of the pointer on the canvas.
  91333. */
  91334. localPosition: Vector2;
  91335. /**
  91336. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91337. */
  91338. skipOnPointerObservable: boolean;
  91339. /**
  91340. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91341. * @param type Defines the type of event (PointerEventTypes)
  91342. * @param event Defines the related dom event
  91343. * @param localX Defines the local x coordinates of the pointer when the event occured
  91344. * @param localY Defines the local y coordinates of the pointer when the event occured
  91345. */
  91346. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91347. }
  91348. /**
  91349. * This type contains all the data related to a pointer event in Babylon.js.
  91350. * 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.
  91351. */
  91352. export class PointerInfo extends PointerInfoBase {
  91353. /**
  91354. * Defines the picking info associated to the info (if any)\
  91355. */
  91356. pickInfo: Nullable<PickingInfo>;
  91357. /**
  91358. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91359. * @param type Defines the type of event (PointerEventTypes)
  91360. * @param event Defines the related dom event
  91361. * @param pickInfo Defines the picking info associated to the info (if any)\
  91362. */
  91363. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91364. /**
  91365. * Defines the picking info associated to the info (if any)\
  91366. */
  91367. pickInfo: Nullable<PickingInfo>);
  91368. }
  91369. /**
  91370. * Data relating to a touch event on the screen.
  91371. */
  91372. export interface PointerTouch {
  91373. /**
  91374. * X coordinate of touch.
  91375. */
  91376. x: number;
  91377. /**
  91378. * Y coordinate of touch.
  91379. */
  91380. y: number;
  91381. /**
  91382. * Id of touch. Unique for each finger.
  91383. */
  91384. pointerId: number;
  91385. /**
  91386. * Event type passed from DOM.
  91387. */
  91388. type: any;
  91389. }
  91390. }
  91391. declare module BABYLON {
  91392. /**
  91393. * Manage the mouse inputs to control the movement of a free camera.
  91394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91395. */
  91396. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91397. /**
  91398. * Define if touch is enabled in the mouse input
  91399. */
  91400. touchEnabled: boolean;
  91401. /**
  91402. * Defines the camera the input is attached to.
  91403. */
  91404. camera: FreeCamera;
  91405. /**
  91406. * Defines the buttons associated with the input to handle camera move.
  91407. */
  91408. buttons: number[];
  91409. /**
  91410. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91411. */
  91412. angularSensibility: number;
  91413. private _pointerInput;
  91414. private _onMouseMove;
  91415. private _observer;
  91416. private previousPosition;
  91417. /**
  91418. * Observable for when a pointer move event occurs containing the move offset
  91419. */
  91420. onPointerMovedObservable: Observable<{
  91421. offsetX: number;
  91422. offsetY: number;
  91423. }>;
  91424. /**
  91425. * @hidden
  91426. * If the camera should be rotated automatically based on pointer movement
  91427. */
  91428. _allowCameraRotation: boolean;
  91429. /**
  91430. * Manage the mouse inputs to control the movement of a free camera.
  91431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91432. * @param touchEnabled Defines if touch is enabled or not
  91433. */
  91434. constructor(
  91435. /**
  91436. * Define if touch is enabled in the mouse input
  91437. */
  91438. touchEnabled?: boolean);
  91439. /**
  91440. * Attach the input controls to a specific dom element to get the input from.
  91441. * @param element Defines the element the controls should be listened from
  91442. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91443. */
  91444. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91445. /**
  91446. * Called on JS contextmenu event.
  91447. * Override this method to provide functionality.
  91448. */
  91449. protected onContextMenu(evt: PointerEvent): void;
  91450. /**
  91451. * Detach the current controls from the specified dom element.
  91452. * @param element Defines the element to stop listening the inputs from
  91453. */
  91454. detachControl(element: Nullable<HTMLElement>): void;
  91455. /**
  91456. * Gets the class name of the current intput.
  91457. * @returns the class name
  91458. */
  91459. getClassName(): string;
  91460. /**
  91461. * Get the friendly name associated with the input class.
  91462. * @returns the input friendly name
  91463. */
  91464. getSimpleName(): string;
  91465. }
  91466. }
  91467. declare module BABYLON {
  91468. /**
  91469. * Manage the touch inputs to control the movement of a free camera.
  91470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91471. */
  91472. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91473. /**
  91474. * Defines the camera the input is attached to.
  91475. */
  91476. camera: FreeCamera;
  91477. /**
  91478. * Defines the touch sensibility for rotation.
  91479. * The higher the faster.
  91480. */
  91481. touchAngularSensibility: number;
  91482. /**
  91483. * Defines the touch sensibility for move.
  91484. * The higher the faster.
  91485. */
  91486. touchMoveSensibility: number;
  91487. private _offsetX;
  91488. private _offsetY;
  91489. private _pointerPressed;
  91490. private _pointerInput;
  91491. private _observer;
  91492. private _onLostFocus;
  91493. /**
  91494. * Attach the input controls to a specific dom element to get the input from.
  91495. * @param element Defines the element the controls should be listened from
  91496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91497. */
  91498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91499. /**
  91500. * Detach the current controls from the specified dom element.
  91501. * @param element Defines the element to stop listening the inputs from
  91502. */
  91503. detachControl(element: Nullable<HTMLElement>): void;
  91504. /**
  91505. * Update the current camera state depending on the inputs that have been used this frame.
  91506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91507. */
  91508. checkInputs(): void;
  91509. /**
  91510. * Gets the class name of the current intput.
  91511. * @returns the class name
  91512. */
  91513. getClassName(): string;
  91514. /**
  91515. * Get the friendly name associated with the input class.
  91516. * @returns the input friendly name
  91517. */
  91518. getSimpleName(): string;
  91519. }
  91520. }
  91521. declare module BABYLON {
  91522. /**
  91523. * Default Inputs manager for the FreeCamera.
  91524. * It groups all the default supported inputs for ease of use.
  91525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91526. */
  91527. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91528. /**
  91529. * @hidden
  91530. */
  91531. _mouseInput: Nullable<FreeCameraMouseInput>;
  91532. /**
  91533. * Instantiates a new FreeCameraInputsManager.
  91534. * @param camera Defines the camera the inputs belong to
  91535. */
  91536. constructor(camera: FreeCamera);
  91537. /**
  91538. * Add keyboard input support to the input manager.
  91539. * @returns the current input manager
  91540. */
  91541. addKeyboard(): FreeCameraInputsManager;
  91542. /**
  91543. * Add mouse input support to the input manager.
  91544. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91545. * @returns the current input manager
  91546. */
  91547. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91548. /**
  91549. * Removes the mouse input support from the manager
  91550. * @returns the current input manager
  91551. */
  91552. removeMouse(): FreeCameraInputsManager;
  91553. /**
  91554. * Add touch input support to the input manager.
  91555. * @returns the current input manager
  91556. */
  91557. addTouch(): FreeCameraInputsManager;
  91558. /**
  91559. * Remove all attached input methods from a camera
  91560. */
  91561. clear(): void;
  91562. }
  91563. }
  91564. declare module BABYLON {
  91565. /**
  91566. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91567. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91569. */
  91570. export class FreeCamera extends TargetCamera {
  91571. /**
  91572. * Define the collision ellipsoid of the camera.
  91573. * This is helpful to simulate a camera body like the player body around the camera
  91574. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91575. */
  91576. ellipsoid: Vector3;
  91577. /**
  91578. * Define an offset for the position of the ellipsoid around the camera.
  91579. * This can be helpful to determine the center of the body near the gravity center of the body
  91580. * instead of its head.
  91581. */
  91582. ellipsoidOffset: Vector3;
  91583. /**
  91584. * Enable or disable collisions of the camera with the rest of the scene objects.
  91585. */
  91586. checkCollisions: boolean;
  91587. /**
  91588. * Enable or disable gravity on the camera.
  91589. */
  91590. applyGravity: boolean;
  91591. /**
  91592. * Define the input manager associated to the camera.
  91593. */
  91594. inputs: FreeCameraInputsManager;
  91595. /**
  91596. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91597. * Higher values reduce sensitivity.
  91598. */
  91599. get angularSensibility(): number;
  91600. /**
  91601. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91602. * Higher values reduce sensitivity.
  91603. */
  91604. set angularSensibility(value: number);
  91605. /**
  91606. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91607. */
  91608. get keysUp(): number[];
  91609. set keysUp(value: number[]);
  91610. /**
  91611. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91612. */
  91613. get keysDown(): number[];
  91614. set keysDown(value: number[]);
  91615. /**
  91616. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91617. */
  91618. get keysLeft(): number[];
  91619. set keysLeft(value: number[]);
  91620. /**
  91621. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91622. */
  91623. get keysRight(): number[];
  91624. set keysRight(value: number[]);
  91625. /**
  91626. * Event raised when the camera collide with a mesh in the scene.
  91627. */
  91628. onCollide: (collidedMesh: AbstractMesh) => void;
  91629. private _collider;
  91630. private _needMoveForGravity;
  91631. private _oldPosition;
  91632. private _diffPosition;
  91633. private _newPosition;
  91634. /** @hidden */
  91635. _localDirection: Vector3;
  91636. /** @hidden */
  91637. _transformedDirection: Vector3;
  91638. /**
  91639. * Instantiates a Free Camera.
  91640. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91641. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91642. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91643. * @param name Define the name of the camera in the scene
  91644. * @param position Define the start position of the camera in the scene
  91645. * @param scene Define the scene the camera belongs to
  91646. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91647. */
  91648. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91649. /**
  91650. * Attached controls to the current camera.
  91651. * @param element Defines the element the controls should be listened from
  91652. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91653. */
  91654. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91655. /**
  91656. * Detach the current controls from the camera.
  91657. * The camera will stop reacting to inputs.
  91658. * @param element Defines the element to stop listening the inputs from
  91659. */
  91660. detachControl(element: HTMLElement): void;
  91661. private _collisionMask;
  91662. /**
  91663. * Define a collision mask to limit the list of object the camera can collide with
  91664. */
  91665. get collisionMask(): number;
  91666. set collisionMask(mask: number);
  91667. /** @hidden */
  91668. _collideWithWorld(displacement: Vector3): void;
  91669. private _onCollisionPositionChange;
  91670. /** @hidden */
  91671. _checkInputs(): void;
  91672. /** @hidden */
  91673. _decideIfNeedsToMove(): boolean;
  91674. /** @hidden */
  91675. _updatePosition(): void;
  91676. /**
  91677. * Destroy the camera and release the current resources hold by it.
  91678. */
  91679. dispose(): void;
  91680. /**
  91681. * Gets the current object class name.
  91682. * @return the class name
  91683. */
  91684. getClassName(): string;
  91685. }
  91686. }
  91687. declare module BABYLON {
  91688. /**
  91689. * Represents a gamepad control stick position
  91690. */
  91691. export class StickValues {
  91692. /**
  91693. * The x component of the control stick
  91694. */
  91695. x: number;
  91696. /**
  91697. * The y component of the control stick
  91698. */
  91699. y: number;
  91700. /**
  91701. * Initializes the gamepad x and y control stick values
  91702. * @param x The x component of the gamepad control stick value
  91703. * @param y The y component of the gamepad control stick value
  91704. */
  91705. constructor(
  91706. /**
  91707. * The x component of the control stick
  91708. */
  91709. x: number,
  91710. /**
  91711. * The y component of the control stick
  91712. */
  91713. y: number);
  91714. }
  91715. /**
  91716. * An interface which manages callbacks for gamepad button changes
  91717. */
  91718. export interface GamepadButtonChanges {
  91719. /**
  91720. * Called when a gamepad has been changed
  91721. */
  91722. changed: boolean;
  91723. /**
  91724. * Called when a gamepad press event has been triggered
  91725. */
  91726. pressChanged: boolean;
  91727. /**
  91728. * Called when a touch event has been triggered
  91729. */
  91730. touchChanged: boolean;
  91731. /**
  91732. * Called when a value has changed
  91733. */
  91734. valueChanged: boolean;
  91735. }
  91736. /**
  91737. * Represents a gamepad
  91738. */
  91739. export class Gamepad {
  91740. /**
  91741. * The id of the gamepad
  91742. */
  91743. id: string;
  91744. /**
  91745. * The index of the gamepad
  91746. */
  91747. index: number;
  91748. /**
  91749. * The browser gamepad
  91750. */
  91751. browserGamepad: any;
  91752. /**
  91753. * Specifies what type of gamepad this represents
  91754. */
  91755. type: number;
  91756. private _leftStick;
  91757. private _rightStick;
  91758. /** @hidden */
  91759. _isConnected: boolean;
  91760. private _leftStickAxisX;
  91761. private _leftStickAxisY;
  91762. private _rightStickAxisX;
  91763. private _rightStickAxisY;
  91764. /**
  91765. * Triggered when the left control stick has been changed
  91766. */
  91767. private _onleftstickchanged;
  91768. /**
  91769. * Triggered when the right control stick has been changed
  91770. */
  91771. private _onrightstickchanged;
  91772. /**
  91773. * Represents a gamepad controller
  91774. */
  91775. static GAMEPAD: number;
  91776. /**
  91777. * Represents a generic controller
  91778. */
  91779. static GENERIC: number;
  91780. /**
  91781. * Represents an XBox controller
  91782. */
  91783. static XBOX: number;
  91784. /**
  91785. * Represents a pose-enabled controller
  91786. */
  91787. static POSE_ENABLED: number;
  91788. /**
  91789. * Represents an Dual Shock controller
  91790. */
  91791. static DUALSHOCK: number;
  91792. /**
  91793. * Specifies whether the left control stick should be Y-inverted
  91794. */
  91795. protected _invertLeftStickY: boolean;
  91796. /**
  91797. * Specifies if the gamepad has been connected
  91798. */
  91799. get isConnected(): boolean;
  91800. /**
  91801. * Initializes the gamepad
  91802. * @param id The id of the gamepad
  91803. * @param index The index of the gamepad
  91804. * @param browserGamepad The browser gamepad
  91805. * @param leftStickX The x component of the left joystick
  91806. * @param leftStickY The y component of the left joystick
  91807. * @param rightStickX The x component of the right joystick
  91808. * @param rightStickY The y component of the right joystick
  91809. */
  91810. constructor(
  91811. /**
  91812. * The id of the gamepad
  91813. */
  91814. id: string,
  91815. /**
  91816. * The index of the gamepad
  91817. */
  91818. index: number,
  91819. /**
  91820. * The browser gamepad
  91821. */
  91822. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91823. /**
  91824. * Callback triggered when the left joystick has changed
  91825. * @param callback
  91826. */
  91827. onleftstickchanged(callback: (values: StickValues) => void): void;
  91828. /**
  91829. * Callback triggered when the right joystick has changed
  91830. * @param callback
  91831. */
  91832. onrightstickchanged(callback: (values: StickValues) => void): void;
  91833. /**
  91834. * Gets the left joystick
  91835. */
  91836. get leftStick(): StickValues;
  91837. /**
  91838. * Sets the left joystick values
  91839. */
  91840. set leftStick(newValues: StickValues);
  91841. /**
  91842. * Gets the right joystick
  91843. */
  91844. get rightStick(): StickValues;
  91845. /**
  91846. * Sets the right joystick value
  91847. */
  91848. set rightStick(newValues: StickValues);
  91849. /**
  91850. * Updates the gamepad joystick positions
  91851. */
  91852. update(): void;
  91853. /**
  91854. * Disposes the gamepad
  91855. */
  91856. dispose(): void;
  91857. }
  91858. /**
  91859. * Represents a generic gamepad
  91860. */
  91861. export class GenericPad extends Gamepad {
  91862. private _buttons;
  91863. private _onbuttondown;
  91864. private _onbuttonup;
  91865. /**
  91866. * Observable triggered when a button has been pressed
  91867. */
  91868. onButtonDownObservable: Observable<number>;
  91869. /**
  91870. * Observable triggered when a button has been released
  91871. */
  91872. onButtonUpObservable: Observable<number>;
  91873. /**
  91874. * Callback triggered when a button has been pressed
  91875. * @param callback Called when a button has been pressed
  91876. */
  91877. onbuttondown(callback: (buttonPressed: number) => void): void;
  91878. /**
  91879. * Callback triggered when a button has been released
  91880. * @param callback Called when a button has been released
  91881. */
  91882. onbuttonup(callback: (buttonReleased: number) => void): void;
  91883. /**
  91884. * Initializes the generic gamepad
  91885. * @param id The id of the generic gamepad
  91886. * @param index The index of the generic gamepad
  91887. * @param browserGamepad The browser gamepad
  91888. */
  91889. constructor(id: string, index: number, browserGamepad: any);
  91890. private _setButtonValue;
  91891. /**
  91892. * Updates the generic gamepad
  91893. */
  91894. update(): void;
  91895. /**
  91896. * Disposes the generic gamepad
  91897. */
  91898. dispose(): void;
  91899. }
  91900. }
  91901. declare module BABYLON {
  91902. /**
  91903. * Defines the types of pose enabled controllers that are supported
  91904. */
  91905. export enum PoseEnabledControllerType {
  91906. /**
  91907. * HTC Vive
  91908. */
  91909. VIVE = 0,
  91910. /**
  91911. * Oculus Rift
  91912. */
  91913. OCULUS = 1,
  91914. /**
  91915. * Windows mixed reality
  91916. */
  91917. WINDOWS = 2,
  91918. /**
  91919. * Samsung gear VR
  91920. */
  91921. GEAR_VR = 3,
  91922. /**
  91923. * Google Daydream
  91924. */
  91925. DAYDREAM = 4,
  91926. /**
  91927. * Generic
  91928. */
  91929. GENERIC = 5
  91930. }
  91931. /**
  91932. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91933. */
  91934. export interface MutableGamepadButton {
  91935. /**
  91936. * Value of the button/trigger
  91937. */
  91938. value: number;
  91939. /**
  91940. * If the button/trigger is currently touched
  91941. */
  91942. touched: boolean;
  91943. /**
  91944. * If the button/trigger is currently pressed
  91945. */
  91946. pressed: boolean;
  91947. }
  91948. /**
  91949. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91950. * @hidden
  91951. */
  91952. export interface ExtendedGamepadButton extends GamepadButton {
  91953. /**
  91954. * If the button/trigger is currently pressed
  91955. */
  91956. readonly pressed: boolean;
  91957. /**
  91958. * If the button/trigger is currently touched
  91959. */
  91960. readonly touched: boolean;
  91961. /**
  91962. * Value of the button/trigger
  91963. */
  91964. readonly value: number;
  91965. }
  91966. /** @hidden */
  91967. export interface _GamePadFactory {
  91968. /**
  91969. * Returns whether or not the current gamepad can be created for this type of controller.
  91970. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91971. * @returns true if it can be created, otherwise false
  91972. */
  91973. canCreate(gamepadInfo: any): boolean;
  91974. /**
  91975. * Creates a new instance of the Gamepad.
  91976. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91977. * @returns the new gamepad instance
  91978. */
  91979. create(gamepadInfo: any): Gamepad;
  91980. }
  91981. /**
  91982. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91983. */
  91984. export class PoseEnabledControllerHelper {
  91985. /** @hidden */
  91986. static _ControllerFactories: _GamePadFactory[];
  91987. /** @hidden */
  91988. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91989. /**
  91990. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91991. * @param vrGamepad the gamepad to initialized
  91992. * @returns a vr controller of the type the gamepad identified as
  91993. */
  91994. static InitiateController(vrGamepad: any): Gamepad;
  91995. }
  91996. /**
  91997. * Defines the PoseEnabledController object that contains state of a vr capable controller
  91998. */
  91999. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92000. /**
  92001. * If the controller is used in a webXR session
  92002. */
  92003. isXR: boolean;
  92004. private _deviceRoomPosition;
  92005. private _deviceRoomRotationQuaternion;
  92006. /**
  92007. * The device position in babylon space
  92008. */
  92009. devicePosition: Vector3;
  92010. /**
  92011. * The device rotation in babylon space
  92012. */
  92013. deviceRotationQuaternion: Quaternion;
  92014. /**
  92015. * The scale factor of the device in babylon space
  92016. */
  92017. deviceScaleFactor: number;
  92018. /**
  92019. * (Likely devicePosition should be used instead) The device position in its room space
  92020. */
  92021. position: Vector3;
  92022. /**
  92023. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92024. */
  92025. rotationQuaternion: Quaternion;
  92026. /**
  92027. * The type of controller (Eg. Windows mixed reality)
  92028. */
  92029. controllerType: PoseEnabledControllerType;
  92030. protected _calculatedPosition: Vector3;
  92031. private _calculatedRotation;
  92032. /**
  92033. * The raw pose from the device
  92034. */
  92035. rawPose: DevicePose;
  92036. private _trackPosition;
  92037. private _maxRotationDistFromHeadset;
  92038. private _draggedRoomRotation;
  92039. /**
  92040. * @hidden
  92041. */
  92042. _disableTrackPosition(fixedPosition: Vector3): void;
  92043. /**
  92044. * Internal, the mesh attached to the controller
  92045. * @hidden
  92046. */
  92047. _mesh: Nullable<AbstractMesh>;
  92048. private _poseControlledCamera;
  92049. private _leftHandSystemQuaternion;
  92050. /**
  92051. * Internal, matrix used to convert room space to babylon space
  92052. * @hidden
  92053. */
  92054. _deviceToWorld: Matrix;
  92055. /**
  92056. * Node to be used when casting a ray from the controller
  92057. * @hidden
  92058. */
  92059. _pointingPoseNode: Nullable<TransformNode>;
  92060. /**
  92061. * Name of the child mesh that can be used to cast a ray from the controller
  92062. */
  92063. static readonly POINTING_POSE: string;
  92064. /**
  92065. * Creates a new PoseEnabledController from a gamepad
  92066. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92067. */
  92068. constructor(browserGamepad: any);
  92069. private _workingMatrix;
  92070. /**
  92071. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92072. */
  92073. update(): void;
  92074. /**
  92075. * Updates only the pose device and mesh without doing any button event checking
  92076. */
  92077. protected _updatePoseAndMesh(): void;
  92078. /**
  92079. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92080. * @param poseData raw pose fromthe device
  92081. */
  92082. updateFromDevice(poseData: DevicePose): void;
  92083. /**
  92084. * @hidden
  92085. */
  92086. _meshAttachedObservable: Observable<AbstractMesh>;
  92087. /**
  92088. * Attaches a mesh to the controller
  92089. * @param mesh the mesh to be attached
  92090. */
  92091. attachToMesh(mesh: AbstractMesh): void;
  92092. /**
  92093. * Attaches the controllers mesh to a camera
  92094. * @param camera the camera the mesh should be attached to
  92095. */
  92096. attachToPoseControlledCamera(camera: TargetCamera): void;
  92097. /**
  92098. * Disposes of the controller
  92099. */
  92100. dispose(): void;
  92101. /**
  92102. * The mesh that is attached to the controller
  92103. */
  92104. get mesh(): Nullable<AbstractMesh>;
  92105. /**
  92106. * Gets the ray of the controller in the direction the controller is pointing
  92107. * @param length the length the resulting ray should be
  92108. * @returns a ray in the direction the controller is pointing
  92109. */
  92110. getForwardRay(length?: number): Ray;
  92111. }
  92112. }
  92113. declare module BABYLON {
  92114. /**
  92115. * Defines the WebVRController object that represents controllers tracked in 3D space
  92116. */
  92117. export abstract class WebVRController extends PoseEnabledController {
  92118. /**
  92119. * Internal, the default controller model for the controller
  92120. */
  92121. protected _defaultModel: Nullable<AbstractMesh>;
  92122. /**
  92123. * Fired when the trigger state has changed
  92124. */
  92125. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92126. /**
  92127. * Fired when the main button state has changed
  92128. */
  92129. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92130. /**
  92131. * Fired when the secondary button state has changed
  92132. */
  92133. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92134. /**
  92135. * Fired when the pad state has changed
  92136. */
  92137. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92138. /**
  92139. * Fired when controllers stick values have changed
  92140. */
  92141. onPadValuesChangedObservable: Observable<StickValues>;
  92142. /**
  92143. * Array of button availible on the controller
  92144. */
  92145. protected _buttons: Array<MutableGamepadButton>;
  92146. private _onButtonStateChange;
  92147. /**
  92148. * Fired when a controller button's state has changed
  92149. * @param callback the callback containing the button that was modified
  92150. */
  92151. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92152. /**
  92153. * X and Y axis corresponding to the controllers joystick
  92154. */
  92155. pad: StickValues;
  92156. /**
  92157. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92158. */
  92159. hand: string;
  92160. /**
  92161. * The default controller model for the controller
  92162. */
  92163. get defaultModel(): Nullable<AbstractMesh>;
  92164. /**
  92165. * Creates a new WebVRController from a gamepad
  92166. * @param vrGamepad the gamepad that the WebVRController should be created from
  92167. */
  92168. constructor(vrGamepad: any);
  92169. /**
  92170. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92171. */
  92172. update(): void;
  92173. /**
  92174. * Function to be called when a button is modified
  92175. */
  92176. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92177. /**
  92178. * Loads a mesh and attaches it to the controller
  92179. * @param scene the scene the mesh should be added to
  92180. * @param meshLoaded callback for when the mesh has been loaded
  92181. */
  92182. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92183. private _setButtonValue;
  92184. private _changes;
  92185. private _checkChanges;
  92186. /**
  92187. * Disposes of th webVRCOntroller
  92188. */
  92189. dispose(): void;
  92190. }
  92191. }
  92192. declare module BABYLON {
  92193. /**
  92194. * The HemisphericLight simulates the ambient environment light,
  92195. * so the passed direction is the light reflection direction, not the incoming direction.
  92196. */
  92197. export class HemisphericLight extends Light {
  92198. /**
  92199. * The groundColor is the light in the opposite direction to the one specified during creation.
  92200. * 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.
  92201. */
  92202. groundColor: Color3;
  92203. /**
  92204. * The light reflection direction, not the incoming direction.
  92205. */
  92206. direction: Vector3;
  92207. /**
  92208. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92209. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92210. * The HemisphericLight can't cast shadows.
  92211. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92212. * @param name The friendly name of the light
  92213. * @param direction The direction of the light reflection
  92214. * @param scene The scene the light belongs to
  92215. */
  92216. constructor(name: string, direction: Vector3, scene: Scene);
  92217. protected _buildUniformLayout(): void;
  92218. /**
  92219. * Returns the string "HemisphericLight".
  92220. * @return The class name
  92221. */
  92222. getClassName(): string;
  92223. /**
  92224. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92225. * Returns the updated direction.
  92226. * @param target The target the direction should point to
  92227. * @return The computed direction
  92228. */
  92229. setDirectionToTarget(target: Vector3): Vector3;
  92230. /**
  92231. * Returns the shadow generator associated to the light.
  92232. * @returns Always null for hemispheric lights because it does not support shadows.
  92233. */
  92234. getShadowGenerator(): Nullable<IShadowGenerator>;
  92235. /**
  92236. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92237. * @param effect The effect to update
  92238. * @param lightIndex The index of the light in the effect to update
  92239. * @returns The hemispheric light
  92240. */
  92241. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92242. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92243. /**
  92244. * Computes the world matrix of the node
  92245. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92246. * @param useWasUpdatedFlag defines a reserved property
  92247. * @returns the world matrix
  92248. */
  92249. computeWorldMatrix(): Matrix;
  92250. /**
  92251. * Returns the integer 3.
  92252. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92253. */
  92254. getTypeID(): number;
  92255. /**
  92256. * Prepares the list of defines specific to the light type.
  92257. * @param defines the list of defines
  92258. * @param lightIndex defines the index of the light for the effect
  92259. */
  92260. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92261. }
  92262. }
  92263. declare module BABYLON {
  92264. /** @hidden */
  92265. export var vrMultiviewToSingleviewPixelShader: {
  92266. name: string;
  92267. shader: string;
  92268. };
  92269. }
  92270. declare module BABYLON {
  92271. /**
  92272. * Renders to multiple views with a single draw call
  92273. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92274. */
  92275. export class MultiviewRenderTarget extends RenderTargetTexture {
  92276. /**
  92277. * Creates a multiview render target
  92278. * @param scene scene used with the render target
  92279. * @param size the size of the render target (used for each view)
  92280. */
  92281. constructor(scene: Scene, size?: number | {
  92282. width: number;
  92283. height: number;
  92284. } | {
  92285. ratio: number;
  92286. });
  92287. /**
  92288. * @hidden
  92289. * @param faceIndex the face index, if its a cube texture
  92290. */
  92291. _bindFrameBuffer(faceIndex?: number): void;
  92292. /**
  92293. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92294. * @returns the view count
  92295. */
  92296. getViewCount(): number;
  92297. }
  92298. }
  92299. declare module BABYLON {
  92300. /**
  92301. * Represents a camera frustum
  92302. */
  92303. export class Frustum {
  92304. /**
  92305. * Gets the planes representing the frustum
  92306. * @param transform matrix to be applied to the returned planes
  92307. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92308. */
  92309. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92310. /**
  92311. * Gets the near frustum plane transformed by the transform matrix
  92312. * @param transform transformation matrix to be applied to the resulting frustum plane
  92313. * @param frustumPlane the resuling frustum plane
  92314. */
  92315. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92316. /**
  92317. * Gets the far frustum plane transformed by the transform matrix
  92318. * @param transform transformation matrix to be applied to the resulting frustum plane
  92319. * @param frustumPlane the resuling frustum plane
  92320. */
  92321. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92322. /**
  92323. * Gets the left frustum plane transformed by the transform matrix
  92324. * @param transform transformation matrix to be applied to the resulting frustum plane
  92325. * @param frustumPlane the resuling frustum plane
  92326. */
  92327. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92328. /**
  92329. * Gets the right frustum plane transformed by the transform matrix
  92330. * @param transform transformation matrix to be applied to the resulting frustum plane
  92331. * @param frustumPlane the resuling frustum plane
  92332. */
  92333. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92334. /**
  92335. * Gets the top frustum plane transformed by the transform matrix
  92336. * @param transform transformation matrix to be applied to the resulting frustum plane
  92337. * @param frustumPlane the resuling frustum plane
  92338. */
  92339. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92340. /**
  92341. * Gets the bottom frustum plane transformed by the transform matrix
  92342. * @param transform transformation matrix to be applied to the resulting frustum plane
  92343. * @param frustumPlane the resuling frustum plane
  92344. */
  92345. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92346. /**
  92347. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92348. * @param transform transformation matrix to be applied to the resulting frustum planes
  92349. * @param frustumPlanes the resuling frustum planes
  92350. */
  92351. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92352. }
  92353. }
  92354. declare module BABYLON {
  92355. interface Engine {
  92356. /**
  92357. * Creates a new multiview render target
  92358. * @param width defines the width of the texture
  92359. * @param height defines the height of the texture
  92360. * @returns the created multiview texture
  92361. */
  92362. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92363. /**
  92364. * Binds a multiview framebuffer to be drawn to
  92365. * @param multiviewTexture texture to bind
  92366. */
  92367. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92368. }
  92369. interface Camera {
  92370. /**
  92371. * @hidden
  92372. * 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)
  92373. */
  92374. _useMultiviewToSingleView: boolean;
  92375. /**
  92376. * @hidden
  92377. * 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)
  92378. */
  92379. _multiviewTexture: Nullable<RenderTargetTexture>;
  92380. /**
  92381. * @hidden
  92382. * ensures the multiview texture of the camera exists and has the specified width/height
  92383. * @param width height to set on the multiview texture
  92384. * @param height width to set on the multiview texture
  92385. */
  92386. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92387. }
  92388. interface Scene {
  92389. /** @hidden */
  92390. _transformMatrixR: Matrix;
  92391. /** @hidden */
  92392. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92393. /** @hidden */
  92394. _createMultiviewUbo(): void;
  92395. /** @hidden */
  92396. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92397. /** @hidden */
  92398. _renderMultiviewToSingleView(camera: Camera): void;
  92399. }
  92400. }
  92401. declare module BABYLON {
  92402. /**
  92403. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92404. * This will not be used for webXR as it supports displaying texture arrays directly
  92405. */
  92406. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92407. /**
  92408. * Initializes a VRMultiviewToSingleview
  92409. * @param name name of the post process
  92410. * @param camera camera to be applied to
  92411. * @param scaleFactor scaling factor to the size of the output texture
  92412. */
  92413. constructor(name: string, camera: Camera, scaleFactor: number);
  92414. }
  92415. }
  92416. declare module BABYLON {
  92417. /**
  92418. * Interface used to define additional presentation attributes
  92419. */
  92420. export interface IVRPresentationAttributes {
  92421. /**
  92422. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92423. */
  92424. highRefreshRate: boolean;
  92425. /**
  92426. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92427. */
  92428. foveationLevel: number;
  92429. }
  92430. interface Engine {
  92431. /** @hidden */
  92432. _vrDisplay: any;
  92433. /** @hidden */
  92434. _vrSupported: boolean;
  92435. /** @hidden */
  92436. _oldSize: Size;
  92437. /** @hidden */
  92438. _oldHardwareScaleFactor: number;
  92439. /** @hidden */
  92440. _vrExclusivePointerMode: boolean;
  92441. /** @hidden */
  92442. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92443. /** @hidden */
  92444. _onVRDisplayPointerRestricted: () => void;
  92445. /** @hidden */
  92446. _onVRDisplayPointerUnrestricted: () => void;
  92447. /** @hidden */
  92448. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92449. /** @hidden */
  92450. _onVrDisplayDisconnect: Nullable<() => void>;
  92451. /** @hidden */
  92452. _onVrDisplayPresentChange: Nullable<() => void>;
  92453. /**
  92454. * Observable signaled when VR display mode changes
  92455. */
  92456. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92457. /**
  92458. * Observable signaled when VR request present is complete
  92459. */
  92460. onVRRequestPresentComplete: Observable<boolean>;
  92461. /**
  92462. * Observable signaled when VR request present starts
  92463. */
  92464. onVRRequestPresentStart: Observable<Engine>;
  92465. /**
  92466. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92467. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92468. */
  92469. isInVRExclusivePointerMode: boolean;
  92470. /**
  92471. * Gets a boolean indicating if a webVR device was detected
  92472. * @returns true if a webVR device was detected
  92473. */
  92474. isVRDevicePresent(): boolean;
  92475. /**
  92476. * Gets the current webVR device
  92477. * @returns the current webVR device (or null)
  92478. */
  92479. getVRDevice(): any;
  92480. /**
  92481. * Initializes a webVR display and starts listening to display change events
  92482. * The onVRDisplayChangedObservable will be notified upon these changes
  92483. * @returns A promise containing a VRDisplay and if vr is supported
  92484. */
  92485. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92486. /** @hidden */
  92487. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92488. /**
  92489. * Gets or sets the presentation attributes used to configure VR rendering
  92490. */
  92491. vrPresentationAttributes?: IVRPresentationAttributes;
  92492. /**
  92493. * Call this function to switch to webVR mode
  92494. * Will do nothing if webVR is not supported or if there is no webVR device
  92495. * @param options the webvr options provided to the camera. mainly used for multiview
  92496. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92497. */
  92498. enableVR(options: WebVROptions): void;
  92499. /** @hidden */
  92500. _onVRFullScreenTriggered(): void;
  92501. }
  92502. }
  92503. declare module BABYLON {
  92504. /**
  92505. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92506. * IMPORTANT!! The data is right-hand data.
  92507. * @export
  92508. * @interface DevicePose
  92509. */
  92510. export interface DevicePose {
  92511. /**
  92512. * The position of the device, values in array are [x,y,z].
  92513. */
  92514. readonly position: Nullable<Float32Array>;
  92515. /**
  92516. * The linearVelocity of the device, values in array are [x,y,z].
  92517. */
  92518. readonly linearVelocity: Nullable<Float32Array>;
  92519. /**
  92520. * The linearAcceleration of the device, values in array are [x,y,z].
  92521. */
  92522. readonly linearAcceleration: Nullable<Float32Array>;
  92523. /**
  92524. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92525. */
  92526. readonly orientation: Nullable<Float32Array>;
  92527. /**
  92528. * The angularVelocity of the device, values in array are [x,y,z].
  92529. */
  92530. readonly angularVelocity: Nullable<Float32Array>;
  92531. /**
  92532. * The angularAcceleration of the device, values in array are [x,y,z].
  92533. */
  92534. readonly angularAcceleration: Nullable<Float32Array>;
  92535. }
  92536. /**
  92537. * Interface representing a pose controlled object in Babylon.
  92538. * A pose controlled object has both regular pose values as well as pose values
  92539. * from an external device such as a VR head mounted display
  92540. */
  92541. export interface PoseControlled {
  92542. /**
  92543. * The position of the object in babylon space.
  92544. */
  92545. position: Vector3;
  92546. /**
  92547. * The rotation quaternion of the object in babylon space.
  92548. */
  92549. rotationQuaternion: Quaternion;
  92550. /**
  92551. * The position of the device in babylon space.
  92552. */
  92553. devicePosition?: Vector3;
  92554. /**
  92555. * The rotation quaternion of the device in babylon space.
  92556. */
  92557. deviceRotationQuaternion: Quaternion;
  92558. /**
  92559. * The raw pose coming from the device.
  92560. */
  92561. rawPose: Nullable<DevicePose>;
  92562. /**
  92563. * The scale of the device to be used when translating from device space to babylon space.
  92564. */
  92565. deviceScaleFactor: number;
  92566. /**
  92567. * Updates the poseControlled values based on the input device pose.
  92568. * @param poseData the pose data to update the object with
  92569. */
  92570. updateFromDevice(poseData: DevicePose): void;
  92571. }
  92572. /**
  92573. * Set of options to customize the webVRCamera
  92574. */
  92575. export interface WebVROptions {
  92576. /**
  92577. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92578. */
  92579. trackPosition?: boolean;
  92580. /**
  92581. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92582. */
  92583. positionScale?: number;
  92584. /**
  92585. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92586. */
  92587. displayName?: string;
  92588. /**
  92589. * Should the native controller meshes be initialized. (default: true)
  92590. */
  92591. controllerMeshes?: boolean;
  92592. /**
  92593. * Creating a default HemiLight only on controllers. (default: true)
  92594. */
  92595. defaultLightingOnControllers?: boolean;
  92596. /**
  92597. * If you don't want to use the default VR button of the helper. (default: false)
  92598. */
  92599. useCustomVRButton?: boolean;
  92600. /**
  92601. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92602. */
  92603. customVRButton?: HTMLButtonElement;
  92604. /**
  92605. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92606. */
  92607. rayLength?: number;
  92608. /**
  92609. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92610. */
  92611. defaultHeight?: number;
  92612. /**
  92613. * If multiview should be used if availible (default: false)
  92614. */
  92615. useMultiview?: boolean;
  92616. }
  92617. /**
  92618. * This represents a WebVR camera.
  92619. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92620. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92621. */
  92622. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92623. private webVROptions;
  92624. /**
  92625. * @hidden
  92626. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92627. */
  92628. _vrDevice: any;
  92629. /**
  92630. * The rawPose of the vrDevice.
  92631. */
  92632. rawPose: Nullable<DevicePose>;
  92633. private _onVREnabled;
  92634. private _specsVersion;
  92635. private _attached;
  92636. private _frameData;
  92637. protected _descendants: Array<Node>;
  92638. private _deviceRoomPosition;
  92639. /** @hidden */
  92640. _deviceRoomRotationQuaternion: Quaternion;
  92641. private _standingMatrix;
  92642. /**
  92643. * Represents device position in babylon space.
  92644. */
  92645. devicePosition: Vector3;
  92646. /**
  92647. * Represents device rotation in babylon space.
  92648. */
  92649. deviceRotationQuaternion: Quaternion;
  92650. /**
  92651. * The scale of the device to be used when translating from device space to babylon space.
  92652. */
  92653. deviceScaleFactor: number;
  92654. private _deviceToWorld;
  92655. private _worldToDevice;
  92656. /**
  92657. * References to the webVR controllers for the vrDevice.
  92658. */
  92659. controllers: Array<WebVRController>;
  92660. /**
  92661. * Emits an event when a controller is attached.
  92662. */
  92663. onControllersAttachedObservable: Observable<WebVRController[]>;
  92664. /**
  92665. * Emits an event when a controller's mesh has been loaded;
  92666. */
  92667. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92668. /**
  92669. * Emits an event when the HMD's pose has been updated.
  92670. */
  92671. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92672. private _poseSet;
  92673. /**
  92674. * If the rig cameras be used as parent instead of this camera.
  92675. */
  92676. rigParenting: boolean;
  92677. private _lightOnControllers;
  92678. private _defaultHeight?;
  92679. /**
  92680. * Instantiates a WebVRFreeCamera.
  92681. * @param name The name of the WebVRFreeCamera
  92682. * @param position The starting anchor position for the camera
  92683. * @param scene The scene the camera belongs to
  92684. * @param webVROptions a set of customizable options for the webVRCamera
  92685. */
  92686. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92687. /**
  92688. * Gets the device distance from the ground in meters.
  92689. * @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.
  92690. */
  92691. deviceDistanceToRoomGround(): number;
  92692. /**
  92693. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92694. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92695. */
  92696. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92697. /**
  92698. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92699. * @returns A promise with a boolean set to if the standing matrix is supported.
  92700. */
  92701. useStandingMatrixAsync(): Promise<boolean>;
  92702. /**
  92703. * Disposes the camera
  92704. */
  92705. dispose(): void;
  92706. /**
  92707. * Gets a vrController by name.
  92708. * @param name The name of the controller to retreive
  92709. * @returns the controller matching the name specified or null if not found
  92710. */
  92711. getControllerByName(name: string): Nullable<WebVRController>;
  92712. private _leftController;
  92713. /**
  92714. * The controller corresponding to the users left hand.
  92715. */
  92716. get leftController(): Nullable<WebVRController>;
  92717. private _rightController;
  92718. /**
  92719. * The controller corresponding to the users right hand.
  92720. */
  92721. get rightController(): Nullable<WebVRController>;
  92722. /**
  92723. * Casts a ray forward from the vrCamera's gaze.
  92724. * @param length Length of the ray (default: 100)
  92725. * @returns the ray corresponding to the gaze
  92726. */
  92727. getForwardRay(length?: number): Ray;
  92728. /**
  92729. * @hidden
  92730. * Updates the camera based on device's frame data
  92731. */
  92732. _checkInputs(): void;
  92733. /**
  92734. * Updates the poseControlled values based on the input device pose.
  92735. * @param poseData Pose coming from the device
  92736. */
  92737. updateFromDevice(poseData: DevicePose): void;
  92738. private _htmlElementAttached;
  92739. private _detachIfAttached;
  92740. /**
  92741. * WebVR's attach control will start broadcasting frames to the device.
  92742. * Note that in certain browsers (chrome for example) this function must be called
  92743. * within a user-interaction callback. Example:
  92744. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92745. *
  92746. * @param element html element to attach the vrDevice to
  92747. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92748. */
  92749. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92750. /**
  92751. * Detaches the camera from the html element and disables VR
  92752. *
  92753. * @param element html element to detach from
  92754. */
  92755. detachControl(element: HTMLElement): void;
  92756. /**
  92757. * @returns the name of this class
  92758. */
  92759. getClassName(): string;
  92760. /**
  92761. * Calls resetPose on the vrDisplay
  92762. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92763. */
  92764. resetToCurrentRotation(): void;
  92765. /**
  92766. * @hidden
  92767. * Updates the rig cameras (left and right eye)
  92768. */
  92769. _updateRigCameras(): void;
  92770. private _workingVector;
  92771. private _oneVector;
  92772. private _workingMatrix;
  92773. private updateCacheCalled;
  92774. private _correctPositionIfNotTrackPosition;
  92775. /**
  92776. * @hidden
  92777. * Updates the cached values of the camera
  92778. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92779. */
  92780. _updateCache(ignoreParentClass?: boolean): void;
  92781. /**
  92782. * @hidden
  92783. * Get current device position in babylon world
  92784. */
  92785. _computeDevicePosition(): void;
  92786. /**
  92787. * Updates the current device position and rotation in the babylon world
  92788. */
  92789. update(): void;
  92790. /**
  92791. * @hidden
  92792. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92793. * @returns an identity matrix
  92794. */
  92795. _getViewMatrix(): Matrix;
  92796. private _tmpMatrix;
  92797. /**
  92798. * This function is called by the two RIG cameras.
  92799. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92800. * @hidden
  92801. */
  92802. _getWebVRViewMatrix(): Matrix;
  92803. /** @hidden */
  92804. _getWebVRProjectionMatrix(): Matrix;
  92805. private _onGamepadConnectedObserver;
  92806. private _onGamepadDisconnectedObserver;
  92807. private _updateCacheWhenTrackingDisabledObserver;
  92808. /**
  92809. * Initializes the controllers and their meshes
  92810. */
  92811. initControllers(): void;
  92812. }
  92813. }
  92814. declare module BABYLON {
  92815. /**
  92816. * Size options for a post process
  92817. */
  92818. export type PostProcessOptions = {
  92819. width: number;
  92820. height: number;
  92821. };
  92822. /**
  92823. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92824. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92825. */
  92826. export class PostProcess {
  92827. /** Name of the PostProcess. */
  92828. name: string;
  92829. /**
  92830. * Gets or sets the unique id of the post process
  92831. */
  92832. uniqueId: number;
  92833. /**
  92834. * Width of the texture to apply the post process on
  92835. */
  92836. width: number;
  92837. /**
  92838. * Height of the texture to apply the post process on
  92839. */
  92840. height: number;
  92841. /**
  92842. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92843. * @hidden
  92844. */
  92845. _outputTexture: Nullable<InternalTexture>;
  92846. /**
  92847. * Sampling mode used by the shader
  92848. * See https://doc.babylonjs.com/classes/3.1/texture
  92849. */
  92850. renderTargetSamplingMode: number;
  92851. /**
  92852. * Clear color to use when screen clearing
  92853. */
  92854. clearColor: Color4;
  92855. /**
  92856. * If the buffer needs to be cleared before applying the post process. (default: true)
  92857. * Should be set to false if shader will overwrite all previous pixels.
  92858. */
  92859. autoClear: boolean;
  92860. /**
  92861. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92862. */
  92863. alphaMode: number;
  92864. /**
  92865. * Sets the setAlphaBlendConstants of the babylon engine
  92866. */
  92867. alphaConstants: Color4;
  92868. /**
  92869. * Animations to be used for the post processing
  92870. */
  92871. animations: Animation[];
  92872. /**
  92873. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92874. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92875. */
  92876. enablePixelPerfectMode: boolean;
  92877. /**
  92878. * Force the postprocess to be applied without taking in account viewport
  92879. */
  92880. forceFullscreenViewport: boolean;
  92881. /**
  92882. * List of inspectable custom properties (used by the Inspector)
  92883. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92884. */
  92885. inspectableCustomProperties: IInspectable[];
  92886. /**
  92887. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92888. *
  92889. * | Value | Type | Description |
  92890. * | ----- | ----------------------------------- | ----------- |
  92891. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92892. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92893. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92894. *
  92895. */
  92896. scaleMode: number;
  92897. /**
  92898. * Force textures to be a power of two (default: false)
  92899. */
  92900. alwaysForcePOT: boolean;
  92901. private _samples;
  92902. /**
  92903. * Number of sample textures (default: 1)
  92904. */
  92905. get samples(): number;
  92906. set samples(n: number);
  92907. /**
  92908. * Modify the scale of the post process to be the same as the viewport (default: false)
  92909. */
  92910. adaptScaleToCurrentViewport: boolean;
  92911. private _camera;
  92912. private _scene;
  92913. private _engine;
  92914. private _options;
  92915. private _reusable;
  92916. private _textureType;
  92917. private _textureFormat;
  92918. /**
  92919. * Smart array of input and output textures for the post process.
  92920. * @hidden
  92921. */
  92922. _textures: SmartArray<InternalTexture>;
  92923. /**
  92924. * The index in _textures that corresponds to the output texture.
  92925. * @hidden
  92926. */
  92927. _currentRenderTextureInd: number;
  92928. private _effect;
  92929. private _samplers;
  92930. private _fragmentUrl;
  92931. private _vertexUrl;
  92932. private _parameters;
  92933. private _scaleRatio;
  92934. protected _indexParameters: any;
  92935. private _shareOutputWithPostProcess;
  92936. private _texelSize;
  92937. private _forcedOutputTexture;
  92938. /**
  92939. * Returns the fragment url or shader name used in the post process.
  92940. * @returns the fragment url or name in the shader store.
  92941. */
  92942. getEffectName(): string;
  92943. /**
  92944. * An event triggered when the postprocess is activated.
  92945. */
  92946. onActivateObservable: Observable<Camera>;
  92947. private _onActivateObserver;
  92948. /**
  92949. * A function that is added to the onActivateObservable
  92950. */
  92951. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92952. /**
  92953. * An event triggered when the postprocess changes its size.
  92954. */
  92955. onSizeChangedObservable: Observable<PostProcess>;
  92956. private _onSizeChangedObserver;
  92957. /**
  92958. * A function that is added to the onSizeChangedObservable
  92959. */
  92960. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92961. /**
  92962. * An event triggered when the postprocess applies its effect.
  92963. */
  92964. onApplyObservable: Observable<Effect>;
  92965. private _onApplyObserver;
  92966. /**
  92967. * A function that is added to the onApplyObservable
  92968. */
  92969. set onApply(callback: (effect: Effect) => void);
  92970. /**
  92971. * An event triggered before rendering the postprocess
  92972. */
  92973. onBeforeRenderObservable: Observable<Effect>;
  92974. private _onBeforeRenderObserver;
  92975. /**
  92976. * A function that is added to the onBeforeRenderObservable
  92977. */
  92978. set onBeforeRender(callback: (effect: Effect) => void);
  92979. /**
  92980. * An event triggered after rendering the postprocess
  92981. */
  92982. onAfterRenderObservable: Observable<Effect>;
  92983. private _onAfterRenderObserver;
  92984. /**
  92985. * A function that is added to the onAfterRenderObservable
  92986. */
  92987. set onAfterRender(callback: (efect: Effect) => void);
  92988. /**
  92989. * 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
  92990. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92991. */
  92992. get inputTexture(): InternalTexture;
  92993. set inputTexture(value: InternalTexture);
  92994. /**
  92995. * Gets the camera which post process is applied to.
  92996. * @returns The camera the post process is applied to.
  92997. */
  92998. getCamera(): Camera;
  92999. /**
  93000. * Gets the texel size of the postprocess.
  93001. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93002. */
  93003. get texelSize(): Vector2;
  93004. /**
  93005. * Creates a new instance PostProcess
  93006. * @param name The name of the PostProcess.
  93007. * @param fragmentUrl The url of the fragment shader to be used.
  93008. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93009. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93010. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93011. * @param camera The camera to apply the render pass to.
  93012. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93013. * @param engine The engine which the post process will be applied. (default: current engine)
  93014. * @param reusable If the post process can be reused on the same frame. (default: false)
  93015. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93016. * @param textureType Type of textures used when performing the post process. (default: 0)
  93017. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93018. * @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
  93019. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93020. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93021. */
  93022. constructor(
  93023. /** Name of the PostProcess. */
  93024. 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);
  93025. /**
  93026. * Gets a string idenfifying the name of the class
  93027. * @returns "PostProcess" string
  93028. */
  93029. getClassName(): string;
  93030. /**
  93031. * Gets the engine which this post process belongs to.
  93032. * @returns The engine the post process was enabled with.
  93033. */
  93034. getEngine(): Engine;
  93035. /**
  93036. * The effect that is created when initializing the post process.
  93037. * @returns The created effect corresponding the the postprocess.
  93038. */
  93039. getEffect(): Effect;
  93040. /**
  93041. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93042. * @param postProcess The post process to share the output with.
  93043. * @returns This post process.
  93044. */
  93045. shareOutputWith(postProcess: PostProcess): PostProcess;
  93046. /**
  93047. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93048. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93049. */
  93050. useOwnOutput(): void;
  93051. /**
  93052. * Updates the effect with the current post process compile time values and recompiles the shader.
  93053. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93054. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93055. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93056. * @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
  93057. * @param onCompiled Called when the shader has been compiled.
  93058. * @param onError Called if there is an error when compiling a shader.
  93059. */
  93060. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93061. /**
  93062. * The post process is reusable if it can be used multiple times within one frame.
  93063. * @returns If the post process is reusable
  93064. */
  93065. isReusable(): boolean;
  93066. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93067. markTextureDirty(): void;
  93068. /**
  93069. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93070. * 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.
  93071. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93072. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93073. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93074. * @returns The target texture that was bound to be written to.
  93075. */
  93076. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93077. /**
  93078. * If the post process is supported.
  93079. */
  93080. get isSupported(): boolean;
  93081. /**
  93082. * The aspect ratio of the output texture.
  93083. */
  93084. get aspectRatio(): number;
  93085. /**
  93086. * Get a value indicating if the post-process is ready to be used
  93087. * @returns true if the post-process is ready (shader is compiled)
  93088. */
  93089. isReady(): boolean;
  93090. /**
  93091. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93092. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93093. */
  93094. apply(): Nullable<Effect>;
  93095. private _disposeTextures;
  93096. /**
  93097. * Disposes the post process.
  93098. * @param camera The camera to dispose the post process on.
  93099. */
  93100. dispose(camera?: Camera): void;
  93101. }
  93102. }
  93103. declare module BABYLON {
  93104. /** @hidden */
  93105. export var kernelBlurVaryingDeclaration: {
  93106. name: string;
  93107. shader: string;
  93108. };
  93109. }
  93110. declare module BABYLON {
  93111. /** @hidden */
  93112. export var kernelBlurFragment: {
  93113. name: string;
  93114. shader: string;
  93115. };
  93116. }
  93117. declare module BABYLON {
  93118. /** @hidden */
  93119. export var kernelBlurFragment2: {
  93120. name: string;
  93121. shader: string;
  93122. };
  93123. }
  93124. declare module BABYLON {
  93125. /** @hidden */
  93126. export var kernelBlurPixelShader: {
  93127. name: string;
  93128. shader: string;
  93129. };
  93130. }
  93131. declare module BABYLON {
  93132. /** @hidden */
  93133. export var kernelBlurVertex: {
  93134. name: string;
  93135. shader: string;
  93136. };
  93137. }
  93138. declare module BABYLON {
  93139. /** @hidden */
  93140. export var kernelBlurVertexShader: {
  93141. name: string;
  93142. shader: string;
  93143. };
  93144. }
  93145. declare module BABYLON {
  93146. /**
  93147. * The Blur Post Process which blurs an image based on a kernel and direction.
  93148. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93149. */
  93150. export class BlurPostProcess extends PostProcess {
  93151. /** The direction in which to blur the image. */
  93152. direction: Vector2;
  93153. private blockCompilation;
  93154. protected _kernel: number;
  93155. protected _idealKernel: number;
  93156. protected _packedFloat: boolean;
  93157. private _staticDefines;
  93158. /**
  93159. * Sets the length in pixels of the blur sample region
  93160. */
  93161. set kernel(v: number);
  93162. /**
  93163. * Gets the length in pixels of the blur sample region
  93164. */
  93165. get kernel(): number;
  93166. /**
  93167. * Sets wether or not the blur needs to unpack/repack floats
  93168. */
  93169. set packedFloat(v: boolean);
  93170. /**
  93171. * Gets wether or not the blur is unpacking/repacking floats
  93172. */
  93173. get packedFloat(): boolean;
  93174. /**
  93175. * Creates a new instance BlurPostProcess
  93176. * @param name The name of the effect.
  93177. * @param direction The direction in which to blur the image.
  93178. * @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.
  93179. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93180. * @param camera The camera to apply the render pass to.
  93181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93182. * @param engine The engine which the post process will be applied. (default: current engine)
  93183. * @param reusable If the post process can be reused on the same frame. (default: false)
  93184. * @param textureType Type of textures used when performing the post process. (default: 0)
  93185. * @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)
  93186. */
  93187. constructor(name: string,
  93188. /** The direction in which to blur the image. */
  93189. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93190. /**
  93191. * Updates the effect with the current post process compile time values and recompiles the shader.
  93192. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93193. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93194. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93195. * @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
  93196. * @param onCompiled Called when the shader has been compiled.
  93197. * @param onError Called if there is an error when compiling a shader.
  93198. */
  93199. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93200. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93201. /**
  93202. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93203. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93204. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93205. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93206. * The gaps between physical kernels are compensated for in the weighting of the samples
  93207. * @param idealKernel Ideal blur kernel.
  93208. * @return Nearest best kernel.
  93209. */
  93210. protected _nearestBestKernel(idealKernel: number): number;
  93211. /**
  93212. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93213. * @param x The point on the Gaussian distribution to sample.
  93214. * @return the value of the Gaussian function at x.
  93215. */
  93216. protected _gaussianWeight(x: number): number;
  93217. /**
  93218. * Generates a string that can be used as a floating point number in GLSL.
  93219. * @param x Value to print.
  93220. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93221. * @return GLSL float string.
  93222. */
  93223. protected _glslFloat(x: number, decimalFigures?: number): string;
  93224. }
  93225. }
  93226. declare module BABYLON {
  93227. /**
  93228. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93229. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93230. * You can then easily use it as a reflectionTexture on a flat surface.
  93231. * In case the surface is not a plane, please consider relying on reflection probes.
  93232. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93233. */
  93234. export class MirrorTexture extends RenderTargetTexture {
  93235. private scene;
  93236. /**
  93237. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93238. * 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.
  93239. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93240. */
  93241. mirrorPlane: Plane;
  93242. /**
  93243. * Define the blur ratio used to blur the reflection if needed.
  93244. */
  93245. set blurRatio(value: number);
  93246. get blurRatio(): number;
  93247. /**
  93248. * Define the adaptive blur kernel used to blur the reflection if needed.
  93249. * This will autocompute the closest best match for the `blurKernel`
  93250. */
  93251. set adaptiveBlurKernel(value: number);
  93252. /**
  93253. * Define the blur kernel used to blur the reflection if needed.
  93254. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93255. */
  93256. set blurKernel(value: number);
  93257. /**
  93258. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93259. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93260. */
  93261. set blurKernelX(value: number);
  93262. get blurKernelX(): number;
  93263. /**
  93264. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93265. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93266. */
  93267. set blurKernelY(value: number);
  93268. get blurKernelY(): number;
  93269. private _autoComputeBlurKernel;
  93270. protected _onRatioRescale(): void;
  93271. private _updateGammaSpace;
  93272. private _imageProcessingConfigChangeObserver;
  93273. private _transformMatrix;
  93274. private _mirrorMatrix;
  93275. private _savedViewMatrix;
  93276. private _blurX;
  93277. private _blurY;
  93278. private _adaptiveBlurKernel;
  93279. private _blurKernelX;
  93280. private _blurKernelY;
  93281. private _blurRatio;
  93282. /**
  93283. * Instantiates a Mirror Texture.
  93284. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93285. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93286. * You can then easily use it as a reflectionTexture on a flat surface.
  93287. * In case the surface is not a plane, please consider relying on reflection probes.
  93288. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93289. * @param name
  93290. * @param size
  93291. * @param scene
  93292. * @param generateMipMaps
  93293. * @param type
  93294. * @param samplingMode
  93295. * @param generateDepthBuffer
  93296. */
  93297. constructor(name: string, size: number | {
  93298. width: number;
  93299. height: number;
  93300. } | {
  93301. ratio: number;
  93302. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93303. private _preparePostProcesses;
  93304. /**
  93305. * Clone the mirror texture.
  93306. * @returns the cloned texture
  93307. */
  93308. clone(): MirrorTexture;
  93309. /**
  93310. * Serialize the texture to a JSON representation you could use in Parse later on
  93311. * @returns the serialized JSON representation
  93312. */
  93313. serialize(): any;
  93314. /**
  93315. * Dispose the texture and release its associated resources.
  93316. */
  93317. dispose(): void;
  93318. }
  93319. }
  93320. declare module BABYLON {
  93321. /**
  93322. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93323. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93324. */
  93325. export class Texture extends BaseTexture {
  93326. /**
  93327. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93328. */
  93329. static SerializeBuffers: boolean;
  93330. /** @hidden */
  93331. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93332. /** @hidden */
  93333. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93334. /** @hidden */
  93335. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93336. /** nearest is mag = nearest and min = nearest and mip = linear */
  93337. static readonly NEAREST_SAMPLINGMODE: number;
  93338. /** nearest is mag = nearest and min = nearest and mip = linear */
  93339. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93340. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93341. static readonly BILINEAR_SAMPLINGMODE: number;
  93342. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93343. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93344. /** Trilinear is mag = linear and min = linear and mip = linear */
  93345. static readonly TRILINEAR_SAMPLINGMODE: number;
  93346. /** Trilinear is mag = linear and min = linear and mip = linear */
  93347. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93348. /** mag = nearest and min = nearest and mip = nearest */
  93349. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93350. /** mag = nearest and min = linear and mip = nearest */
  93351. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93352. /** mag = nearest and min = linear and mip = linear */
  93353. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93354. /** mag = nearest and min = linear and mip = none */
  93355. static readonly NEAREST_LINEAR: number;
  93356. /** mag = nearest and min = nearest and mip = none */
  93357. static readonly NEAREST_NEAREST: number;
  93358. /** mag = linear and min = nearest and mip = nearest */
  93359. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93360. /** mag = linear and min = nearest and mip = linear */
  93361. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93362. /** mag = linear and min = linear and mip = none */
  93363. static readonly LINEAR_LINEAR: number;
  93364. /** mag = linear and min = nearest and mip = none */
  93365. static readonly LINEAR_NEAREST: number;
  93366. /** Explicit coordinates mode */
  93367. static readonly EXPLICIT_MODE: number;
  93368. /** Spherical coordinates mode */
  93369. static readonly SPHERICAL_MODE: number;
  93370. /** Planar coordinates mode */
  93371. static readonly PLANAR_MODE: number;
  93372. /** Cubic coordinates mode */
  93373. static readonly CUBIC_MODE: number;
  93374. /** Projection coordinates mode */
  93375. static readonly PROJECTION_MODE: number;
  93376. /** Inverse Cubic coordinates mode */
  93377. static readonly SKYBOX_MODE: number;
  93378. /** Inverse Cubic coordinates mode */
  93379. static readonly INVCUBIC_MODE: number;
  93380. /** Equirectangular coordinates mode */
  93381. static readonly EQUIRECTANGULAR_MODE: number;
  93382. /** Equirectangular Fixed coordinates mode */
  93383. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93384. /** Equirectangular Fixed Mirrored coordinates mode */
  93385. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93386. /** Texture is not repeating outside of 0..1 UVs */
  93387. static readonly CLAMP_ADDRESSMODE: number;
  93388. /** Texture is repeating outside of 0..1 UVs */
  93389. static readonly WRAP_ADDRESSMODE: number;
  93390. /** Texture is repeating and mirrored */
  93391. static readonly MIRROR_ADDRESSMODE: number;
  93392. /**
  93393. * 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
  93394. */
  93395. static UseSerializedUrlIfAny: boolean;
  93396. /**
  93397. * Define the url of the texture.
  93398. */
  93399. url: Nullable<string>;
  93400. /**
  93401. * Define an offset on the texture to offset the u coordinates of the UVs
  93402. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93403. */
  93404. uOffset: number;
  93405. /**
  93406. * Define an offset on the texture to offset the v coordinates of the UVs
  93407. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93408. */
  93409. vOffset: number;
  93410. /**
  93411. * Define an offset on the texture to scale the u coordinates of the UVs
  93412. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93413. */
  93414. uScale: number;
  93415. /**
  93416. * Define an offset on the texture to scale the v coordinates of the UVs
  93417. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93418. */
  93419. vScale: number;
  93420. /**
  93421. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93422. * @see http://doc.babylonjs.com/how_to/more_materials
  93423. */
  93424. uAng: number;
  93425. /**
  93426. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93427. * @see http://doc.babylonjs.com/how_to/more_materials
  93428. */
  93429. vAng: number;
  93430. /**
  93431. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93432. * @see http://doc.babylonjs.com/how_to/more_materials
  93433. */
  93434. wAng: number;
  93435. /**
  93436. * Defines the center of rotation (U)
  93437. */
  93438. uRotationCenter: number;
  93439. /**
  93440. * Defines the center of rotation (V)
  93441. */
  93442. vRotationCenter: number;
  93443. /**
  93444. * Defines the center of rotation (W)
  93445. */
  93446. wRotationCenter: number;
  93447. /**
  93448. * Are mip maps generated for this texture or not.
  93449. */
  93450. get noMipmap(): boolean;
  93451. /**
  93452. * List of inspectable custom properties (used by the Inspector)
  93453. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93454. */
  93455. inspectableCustomProperties: Nullable<IInspectable[]>;
  93456. private _noMipmap;
  93457. /** @hidden */
  93458. _invertY: boolean;
  93459. private _rowGenerationMatrix;
  93460. private _cachedTextureMatrix;
  93461. private _projectionModeMatrix;
  93462. private _t0;
  93463. private _t1;
  93464. private _t2;
  93465. private _cachedUOffset;
  93466. private _cachedVOffset;
  93467. private _cachedUScale;
  93468. private _cachedVScale;
  93469. private _cachedUAng;
  93470. private _cachedVAng;
  93471. private _cachedWAng;
  93472. private _cachedProjectionMatrixId;
  93473. private _cachedCoordinatesMode;
  93474. /** @hidden */
  93475. protected _initialSamplingMode: number;
  93476. /** @hidden */
  93477. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93478. private _deleteBuffer;
  93479. protected _format: Nullable<number>;
  93480. private _delayedOnLoad;
  93481. private _delayedOnError;
  93482. private _mimeType?;
  93483. /**
  93484. * Observable triggered once the texture has been loaded.
  93485. */
  93486. onLoadObservable: Observable<Texture>;
  93487. protected _isBlocking: boolean;
  93488. /**
  93489. * Is the texture preventing material to render while loading.
  93490. * If false, a default texture will be used instead of the loading one during the preparation step.
  93491. */
  93492. set isBlocking(value: boolean);
  93493. get isBlocking(): boolean;
  93494. /**
  93495. * Get the current sampling mode associated with the texture.
  93496. */
  93497. get samplingMode(): number;
  93498. /**
  93499. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93500. */
  93501. get invertY(): boolean;
  93502. /**
  93503. * Instantiates a new texture.
  93504. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93505. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93506. * @param url defines the url of the picture to load as a texture
  93507. * @param scene defines the scene or engine the texture will belong to
  93508. * @param noMipmap defines if the texture will require mip maps or not
  93509. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93510. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93511. * @param onLoad defines a callback triggered when the texture has been loaded
  93512. * @param onError defines a callback triggered when an error occurred during the loading session
  93513. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93514. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93515. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93516. * @param mimeType defines an optional mime type information
  93517. */
  93518. 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);
  93519. /**
  93520. * Update the url (and optional buffer) of this texture if url was null during construction.
  93521. * @param url the url of the texture
  93522. * @param buffer the buffer of the texture (defaults to null)
  93523. * @param onLoad callback called when the texture is loaded (defaults to null)
  93524. */
  93525. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93526. /**
  93527. * Finish the loading sequence of a texture flagged as delayed load.
  93528. * @hidden
  93529. */
  93530. delayLoad(): void;
  93531. private _prepareRowForTextureGeneration;
  93532. /**
  93533. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93534. * @returns the transform matrix of the texture.
  93535. */
  93536. getTextureMatrix(uBase?: number): Matrix;
  93537. /**
  93538. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93539. * @returns The reflection texture transform
  93540. */
  93541. getReflectionTextureMatrix(): Matrix;
  93542. /**
  93543. * Clones the texture.
  93544. * @returns the cloned texture
  93545. */
  93546. clone(): Texture;
  93547. /**
  93548. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93549. * @returns The JSON representation of the texture
  93550. */
  93551. serialize(): any;
  93552. /**
  93553. * Get the current class name of the texture useful for serialization or dynamic coding.
  93554. * @returns "Texture"
  93555. */
  93556. getClassName(): string;
  93557. /**
  93558. * Dispose the texture and release its associated resources.
  93559. */
  93560. dispose(): void;
  93561. /**
  93562. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93563. * @param parsedTexture Define the JSON representation of the texture
  93564. * @param scene Define the scene the parsed texture should be instantiated in
  93565. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93566. * @returns The parsed texture if successful
  93567. */
  93568. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93569. /**
  93570. * Creates a texture from its base 64 representation.
  93571. * @param data Define the base64 payload without the data: prefix
  93572. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93573. * @param scene Define the scene the texture should belong to
  93574. * @param noMipmap Forces the texture to not create mip map information if true
  93575. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93576. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93577. * @param onLoad define a callback triggered when the texture has been loaded
  93578. * @param onError define a callback triggered when an error occurred during the loading session
  93579. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93580. * @returns the created texture
  93581. */
  93582. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93583. /**
  93584. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93585. * @param data Define the base64 payload without the data: prefix
  93586. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93587. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93588. * @param scene Define the scene the texture should belong to
  93589. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93590. * @param noMipmap Forces the texture to not create mip map information if true
  93591. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93592. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93593. * @param onLoad define a callback triggered when the texture has been loaded
  93594. * @param onError define a callback triggered when an error occurred during the loading session
  93595. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93596. * @returns the created texture
  93597. */
  93598. 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;
  93599. }
  93600. }
  93601. declare module BABYLON {
  93602. /**
  93603. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93604. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93605. */
  93606. export class PostProcessManager {
  93607. private _scene;
  93608. private _indexBuffer;
  93609. private _vertexBuffers;
  93610. /**
  93611. * Creates a new instance PostProcess
  93612. * @param scene The scene that the post process is associated with.
  93613. */
  93614. constructor(scene: Scene);
  93615. private _prepareBuffers;
  93616. private _buildIndexBuffer;
  93617. /**
  93618. * Rebuilds the vertex buffers of the manager.
  93619. * @hidden
  93620. */
  93621. _rebuild(): void;
  93622. /**
  93623. * Prepares a frame to be run through a post process.
  93624. * @param sourceTexture The input texture to the post procesess. (default: null)
  93625. * @param postProcesses An array of post processes to be run. (default: null)
  93626. * @returns True if the post processes were able to be run.
  93627. * @hidden
  93628. */
  93629. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93630. /**
  93631. * Manually render a set of post processes to a texture.
  93632. * @param postProcesses An array of post processes to be run.
  93633. * @param targetTexture The target texture to render to.
  93634. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93635. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93636. * @param lodLevel defines which lod of the texture to render to
  93637. */
  93638. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93639. /**
  93640. * Finalize the result of the output of the postprocesses.
  93641. * @param doNotPresent If true the result will not be displayed to the screen.
  93642. * @param targetTexture The target texture to render to.
  93643. * @param faceIndex The index of the face to bind the target texture to.
  93644. * @param postProcesses The array of post processes to render.
  93645. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93646. * @hidden
  93647. */
  93648. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93649. /**
  93650. * Disposes of the post process manager.
  93651. */
  93652. dispose(): void;
  93653. }
  93654. }
  93655. declare module BABYLON {
  93656. /**
  93657. * This Helps creating a texture that will be created from a camera in your scene.
  93658. * It is basically a dynamic texture that could be used to create special effects for instance.
  93659. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93660. */
  93661. export class RenderTargetTexture extends Texture {
  93662. isCube: boolean;
  93663. /**
  93664. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93665. */
  93666. static readonly REFRESHRATE_RENDER_ONCE: number;
  93667. /**
  93668. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93669. */
  93670. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93671. /**
  93672. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93673. * the central point of your effect and can save a lot of performances.
  93674. */
  93675. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93676. /**
  93677. * Use this predicate to dynamically define the list of mesh you want to render.
  93678. * If set, the renderList property will be overwritten.
  93679. */
  93680. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93681. private _renderList;
  93682. /**
  93683. * Use this list to define the list of mesh you want to render.
  93684. */
  93685. get renderList(): Nullable<Array<AbstractMesh>>;
  93686. set renderList(value: Nullable<Array<AbstractMesh>>);
  93687. /**
  93688. * Use this function to overload the renderList array at rendering time.
  93689. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93690. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93691. * the cube (if the RTT is a cube, else layerOrFace=0).
  93692. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93693. */
  93694. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93695. private _hookArray;
  93696. /**
  93697. * Define if particles should be rendered in your texture.
  93698. */
  93699. renderParticles: boolean;
  93700. /**
  93701. * Define if sprites should be rendered in your texture.
  93702. */
  93703. renderSprites: boolean;
  93704. /**
  93705. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93706. */
  93707. coordinatesMode: number;
  93708. /**
  93709. * Define the camera used to render the texture.
  93710. */
  93711. activeCamera: Nullable<Camera>;
  93712. /**
  93713. * Override the render function of the texture with your own one.
  93714. */
  93715. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93716. /**
  93717. * Define if camera post processes should be use while rendering the texture.
  93718. */
  93719. useCameraPostProcesses: boolean;
  93720. /**
  93721. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93722. */
  93723. ignoreCameraViewport: boolean;
  93724. private _postProcessManager;
  93725. private _postProcesses;
  93726. private _resizeObserver;
  93727. /**
  93728. * An event triggered when the texture is unbind.
  93729. */
  93730. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93731. /**
  93732. * An event triggered when the texture is unbind.
  93733. */
  93734. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93735. private _onAfterUnbindObserver;
  93736. /**
  93737. * Set a after unbind callback in the texture.
  93738. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93739. */
  93740. set onAfterUnbind(callback: () => void);
  93741. /**
  93742. * An event triggered before rendering the texture
  93743. */
  93744. onBeforeRenderObservable: Observable<number>;
  93745. private _onBeforeRenderObserver;
  93746. /**
  93747. * Set a before render callback in the texture.
  93748. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93749. */
  93750. set onBeforeRender(callback: (faceIndex: number) => void);
  93751. /**
  93752. * An event triggered after rendering the texture
  93753. */
  93754. onAfterRenderObservable: Observable<number>;
  93755. private _onAfterRenderObserver;
  93756. /**
  93757. * Set a after render callback in the texture.
  93758. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93759. */
  93760. set onAfterRender(callback: (faceIndex: number) => void);
  93761. /**
  93762. * An event triggered after the texture clear
  93763. */
  93764. onClearObservable: Observable<Engine>;
  93765. private _onClearObserver;
  93766. /**
  93767. * Set a clear callback in the texture.
  93768. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93769. */
  93770. set onClear(callback: (Engine: Engine) => void);
  93771. /**
  93772. * An event triggered when the texture is resized.
  93773. */
  93774. onResizeObservable: Observable<RenderTargetTexture>;
  93775. /**
  93776. * Define the clear color of the Render Target if it should be different from the scene.
  93777. */
  93778. clearColor: Color4;
  93779. protected _size: number | {
  93780. width: number;
  93781. height: number;
  93782. layers?: number;
  93783. };
  93784. protected _initialSizeParameter: number | {
  93785. width: number;
  93786. height: number;
  93787. } | {
  93788. ratio: number;
  93789. };
  93790. protected _sizeRatio: Nullable<number>;
  93791. /** @hidden */
  93792. _generateMipMaps: boolean;
  93793. protected _renderingManager: RenderingManager;
  93794. /** @hidden */
  93795. _waitingRenderList: string[];
  93796. protected _doNotChangeAspectRatio: boolean;
  93797. protected _currentRefreshId: number;
  93798. protected _refreshRate: number;
  93799. protected _textureMatrix: Matrix;
  93800. protected _samples: number;
  93801. protected _renderTargetOptions: RenderTargetCreationOptions;
  93802. /**
  93803. * Gets render target creation options that were used.
  93804. */
  93805. get renderTargetOptions(): RenderTargetCreationOptions;
  93806. protected _engine: Engine;
  93807. protected _onRatioRescale(): void;
  93808. /**
  93809. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93810. * It must define where the camera used to render the texture is set
  93811. */
  93812. boundingBoxPosition: Vector3;
  93813. private _boundingBoxSize;
  93814. /**
  93815. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93816. * When defined, the cubemap will switch to local mode
  93817. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93818. * @example https://www.babylonjs-playground.com/#RNASML
  93819. */
  93820. set boundingBoxSize(value: Vector3);
  93821. get boundingBoxSize(): Vector3;
  93822. /**
  93823. * In case the RTT has been created with a depth texture, get the associated
  93824. * depth texture.
  93825. * Otherwise, return null.
  93826. */
  93827. get depthStencilTexture(): Nullable<InternalTexture>;
  93828. /**
  93829. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93830. * or used a shadow, depth texture...
  93831. * @param name The friendly name of the texture
  93832. * @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)
  93833. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93834. * @param generateMipMaps True if mip maps need to be generated after render.
  93835. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93836. * @param type The type of the buffer in the RTT (int, half float, float...)
  93837. * @param isCube True if a cube texture needs to be created
  93838. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93839. * @param generateDepthBuffer True to generate a depth buffer
  93840. * @param generateStencilBuffer True to generate a stencil buffer
  93841. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93842. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93844. */
  93845. constructor(name: string, size: number | {
  93846. width: number;
  93847. height: number;
  93848. layers?: number;
  93849. } | {
  93850. ratio: number;
  93851. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93852. /**
  93853. * Creates a depth stencil texture.
  93854. * This is only available in WebGL 2 or with the depth texture extension available.
  93855. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93856. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93857. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93858. */
  93859. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93860. private _processSizeParameter;
  93861. /**
  93862. * Define the number of samples to use in case of MSAA.
  93863. * It defaults to one meaning no MSAA has been enabled.
  93864. */
  93865. get samples(): number;
  93866. set samples(value: number);
  93867. /**
  93868. * Resets the refresh counter of the texture and start bak from scratch.
  93869. * Could be useful to regenerate the texture if it is setup to render only once.
  93870. */
  93871. resetRefreshCounter(): void;
  93872. /**
  93873. * Define the refresh rate of the texture or the rendering frequency.
  93874. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93875. */
  93876. get refreshRate(): number;
  93877. set refreshRate(value: number);
  93878. /**
  93879. * Adds a post process to the render target rendering passes.
  93880. * @param postProcess define the post process to add
  93881. */
  93882. addPostProcess(postProcess: PostProcess): void;
  93883. /**
  93884. * Clear all the post processes attached to the render target
  93885. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93886. */
  93887. clearPostProcesses(dispose?: boolean): void;
  93888. /**
  93889. * Remove one of the post process from the list of attached post processes to the texture
  93890. * @param postProcess define the post process to remove from the list
  93891. */
  93892. removePostProcess(postProcess: PostProcess): void;
  93893. /** @hidden */
  93894. _shouldRender(): boolean;
  93895. /**
  93896. * Gets the actual render size of the texture.
  93897. * @returns the width of the render size
  93898. */
  93899. getRenderSize(): number;
  93900. /**
  93901. * Gets the actual render width of the texture.
  93902. * @returns the width of the render size
  93903. */
  93904. getRenderWidth(): number;
  93905. /**
  93906. * Gets the actual render height of the texture.
  93907. * @returns the height of the render size
  93908. */
  93909. getRenderHeight(): number;
  93910. /**
  93911. * Gets the actual number of layers of the texture.
  93912. * @returns the number of layers
  93913. */
  93914. getRenderLayers(): number;
  93915. /**
  93916. * Get if the texture can be rescaled or not.
  93917. */
  93918. get canRescale(): boolean;
  93919. /**
  93920. * Resize the texture using a ratio.
  93921. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93922. */
  93923. scale(ratio: number): void;
  93924. /**
  93925. * Get the texture reflection matrix used to rotate/transform the reflection.
  93926. * @returns the reflection matrix
  93927. */
  93928. getReflectionTextureMatrix(): Matrix;
  93929. /**
  93930. * Resize the texture to a new desired size.
  93931. * Be carrefull as it will recreate all the data in the new texture.
  93932. * @param size Define the new size. It can be:
  93933. * - a number for squared texture,
  93934. * - an object containing { width: number, height: number }
  93935. * - or an object containing a ratio { ratio: number }
  93936. */
  93937. resize(size: number | {
  93938. width: number;
  93939. height: number;
  93940. } | {
  93941. ratio: number;
  93942. }): void;
  93943. private _defaultRenderListPrepared;
  93944. /**
  93945. * Renders all the objects from the render list into the texture.
  93946. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93947. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93948. */
  93949. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93950. private _bestReflectionRenderTargetDimension;
  93951. private _prepareRenderingManager;
  93952. /**
  93953. * @hidden
  93954. * @param faceIndex face index to bind to if this is a cubetexture
  93955. * @param layer defines the index of the texture to bind in the array
  93956. */
  93957. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93958. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93959. private renderToTarget;
  93960. /**
  93961. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93962. * This allowed control for front to back rendering or reversly depending of the special needs.
  93963. *
  93964. * @param renderingGroupId The rendering group id corresponding to its index
  93965. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93966. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93967. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93968. */
  93969. 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;
  93970. /**
  93971. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93972. *
  93973. * @param renderingGroupId The rendering group id corresponding to its index
  93974. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93975. */
  93976. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93977. /**
  93978. * Clones the texture.
  93979. * @returns the cloned texture
  93980. */
  93981. clone(): RenderTargetTexture;
  93982. /**
  93983. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93984. * @returns The JSON representation of the texture
  93985. */
  93986. serialize(): any;
  93987. /**
  93988. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93989. */
  93990. disposeFramebufferObjects(): void;
  93991. /**
  93992. * Dispose the texture and release its associated resources.
  93993. */
  93994. dispose(): void;
  93995. /** @hidden */
  93996. _rebuild(): void;
  93997. /**
  93998. * Clear the info related to rendering groups preventing retention point in material dispose.
  93999. */
  94000. freeRenderingGroups(): void;
  94001. /**
  94002. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94003. * @returns the view count
  94004. */
  94005. getViewCount(): number;
  94006. }
  94007. }
  94008. declare module BABYLON {
  94009. /**
  94010. * Options for compiling materials.
  94011. */
  94012. export interface IMaterialCompilationOptions {
  94013. /**
  94014. * Defines whether clip planes are enabled.
  94015. */
  94016. clipPlane: boolean;
  94017. /**
  94018. * Defines whether instances are enabled.
  94019. */
  94020. useInstances: boolean;
  94021. }
  94022. /**
  94023. * Base class for the main features of a material in Babylon.js
  94024. */
  94025. export class Material implements IAnimatable {
  94026. /**
  94027. * Returns the triangle fill mode
  94028. */
  94029. static readonly TriangleFillMode: number;
  94030. /**
  94031. * Returns the wireframe mode
  94032. */
  94033. static readonly WireFrameFillMode: number;
  94034. /**
  94035. * Returns the point fill mode
  94036. */
  94037. static readonly PointFillMode: number;
  94038. /**
  94039. * Returns the point list draw mode
  94040. */
  94041. static readonly PointListDrawMode: number;
  94042. /**
  94043. * Returns the line list draw mode
  94044. */
  94045. static readonly LineListDrawMode: number;
  94046. /**
  94047. * Returns the line loop draw mode
  94048. */
  94049. static readonly LineLoopDrawMode: number;
  94050. /**
  94051. * Returns the line strip draw mode
  94052. */
  94053. static readonly LineStripDrawMode: number;
  94054. /**
  94055. * Returns the triangle strip draw mode
  94056. */
  94057. static readonly TriangleStripDrawMode: number;
  94058. /**
  94059. * Returns the triangle fan draw mode
  94060. */
  94061. static readonly TriangleFanDrawMode: number;
  94062. /**
  94063. * Stores the clock-wise side orientation
  94064. */
  94065. static readonly ClockWiseSideOrientation: number;
  94066. /**
  94067. * Stores the counter clock-wise side orientation
  94068. */
  94069. static readonly CounterClockWiseSideOrientation: number;
  94070. /**
  94071. * The dirty texture flag value
  94072. */
  94073. static readonly TextureDirtyFlag: number;
  94074. /**
  94075. * The dirty light flag value
  94076. */
  94077. static readonly LightDirtyFlag: number;
  94078. /**
  94079. * The dirty fresnel flag value
  94080. */
  94081. static readonly FresnelDirtyFlag: number;
  94082. /**
  94083. * The dirty attribute flag value
  94084. */
  94085. static readonly AttributesDirtyFlag: number;
  94086. /**
  94087. * The dirty misc flag value
  94088. */
  94089. static readonly MiscDirtyFlag: number;
  94090. /**
  94091. * The all dirty flag value
  94092. */
  94093. static readonly AllDirtyFlag: number;
  94094. /**
  94095. * The ID of the material
  94096. */
  94097. id: string;
  94098. /**
  94099. * Gets or sets the unique id of the material
  94100. */
  94101. uniqueId: number;
  94102. /**
  94103. * The name of the material
  94104. */
  94105. name: string;
  94106. /**
  94107. * Gets or sets user defined metadata
  94108. */
  94109. metadata: any;
  94110. /**
  94111. * For internal use only. Please do not use.
  94112. */
  94113. reservedDataStore: any;
  94114. /**
  94115. * Specifies if the ready state should be checked on each call
  94116. */
  94117. checkReadyOnEveryCall: boolean;
  94118. /**
  94119. * Specifies if the ready state should be checked once
  94120. */
  94121. checkReadyOnlyOnce: boolean;
  94122. /**
  94123. * The state of the material
  94124. */
  94125. state: string;
  94126. /**
  94127. * The alpha value of the material
  94128. */
  94129. protected _alpha: number;
  94130. /**
  94131. * List of inspectable custom properties (used by the Inspector)
  94132. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94133. */
  94134. inspectableCustomProperties: IInspectable[];
  94135. /**
  94136. * Sets the alpha value of the material
  94137. */
  94138. set alpha(value: number);
  94139. /**
  94140. * Gets the alpha value of the material
  94141. */
  94142. get alpha(): number;
  94143. /**
  94144. * Specifies if back face culling is enabled
  94145. */
  94146. protected _backFaceCulling: boolean;
  94147. /**
  94148. * Sets the back-face culling state
  94149. */
  94150. set backFaceCulling(value: boolean);
  94151. /**
  94152. * Gets the back-face culling state
  94153. */
  94154. get backFaceCulling(): boolean;
  94155. /**
  94156. * Stores the value for side orientation
  94157. */
  94158. sideOrientation: number;
  94159. /**
  94160. * Callback triggered when the material is compiled
  94161. */
  94162. onCompiled: Nullable<(effect: Effect) => void>;
  94163. /**
  94164. * Callback triggered when an error occurs
  94165. */
  94166. onError: Nullable<(effect: Effect, errors: string) => void>;
  94167. /**
  94168. * Callback triggered to get the render target textures
  94169. */
  94170. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94171. /**
  94172. * Gets a boolean indicating that current material needs to register RTT
  94173. */
  94174. get hasRenderTargetTextures(): boolean;
  94175. /**
  94176. * Specifies if the material should be serialized
  94177. */
  94178. doNotSerialize: boolean;
  94179. /**
  94180. * @hidden
  94181. */
  94182. _storeEffectOnSubMeshes: boolean;
  94183. /**
  94184. * Stores the animations for the material
  94185. */
  94186. animations: Nullable<Array<Animation>>;
  94187. /**
  94188. * An event triggered when the material is disposed
  94189. */
  94190. onDisposeObservable: Observable<Material>;
  94191. /**
  94192. * An observer which watches for dispose events
  94193. */
  94194. private _onDisposeObserver;
  94195. private _onUnBindObservable;
  94196. /**
  94197. * Called during a dispose event
  94198. */
  94199. set onDispose(callback: () => void);
  94200. private _onBindObservable;
  94201. /**
  94202. * An event triggered when the material is bound
  94203. */
  94204. get onBindObservable(): Observable<AbstractMesh>;
  94205. /**
  94206. * An observer which watches for bind events
  94207. */
  94208. private _onBindObserver;
  94209. /**
  94210. * Called during a bind event
  94211. */
  94212. set onBind(callback: (Mesh: AbstractMesh) => void);
  94213. /**
  94214. * An event triggered when the material is unbound
  94215. */
  94216. get onUnBindObservable(): Observable<Material>;
  94217. /**
  94218. * Stores the value of the alpha mode
  94219. */
  94220. private _alphaMode;
  94221. /**
  94222. * Sets the value of the alpha mode.
  94223. *
  94224. * | Value | Type | Description |
  94225. * | --- | --- | --- |
  94226. * | 0 | ALPHA_DISABLE | |
  94227. * | 1 | ALPHA_ADD | |
  94228. * | 2 | ALPHA_COMBINE | |
  94229. * | 3 | ALPHA_SUBTRACT | |
  94230. * | 4 | ALPHA_MULTIPLY | |
  94231. * | 5 | ALPHA_MAXIMIZED | |
  94232. * | 6 | ALPHA_ONEONE | |
  94233. * | 7 | ALPHA_PREMULTIPLIED | |
  94234. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94235. * | 9 | ALPHA_INTERPOLATE | |
  94236. * | 10 | ALPHA_SCREENMODE | |
  94237. *
  94238. */
  94239. set alphaMode(value: number);
  94240. /**
  94241. * Gets the value of the alpha mode
  94242. */
  94243. get alphaMode(): number;
  94244. /**
  94245. * Stores the state of the need depth pre-pass value
  94246. */
  94247. private _needDepthPrePass;
  94248. /**
  94249. * Sets the need depth pre-pass value
  94250. */
  94251. set needDepthPrePass(value: boolean);
  94252. /**
  94253. * Gets the depth pre-pass value
  94254. */
  94255. get needDepthPrePass(): boolean;
  94256. /**
  94257. * Specifies if depth writing should be disabled
  94258. */
  94259. disableDepthWrite: boolean;
  94260. /**
  94261. * Specifies if depth writing should be forced
  94262. */
  94263. forceDepthWrite: boolean;
  94264. /**
  94265. * Specifies the depth function that should be used. 0 means the default engine function
  94266. */
  94267. depthFunction: number;
  94268. /**
  94269. * Specifies if there should be a separate pass for culling
  94270. */
  94271. separateCullingPass: boolean;
  94272. /**
  94273. * Stores the state specifing if fog should be enabled
  94274. */
  94275. private _fogEnabled;
  94276. /**
  94277. * Sets the state for enabling fog
  94278. */
  94279. set fogEnabled(value: boolean);
  94280. /**
  94281. * Gets the value of the fog enabled state
  94282. */
  94283. get fogEnabled(): boolean;
  94284. /**
  94285. * Stores the size of points
  94286. */
  94287. pointSize: number;
  94288. /**
  94289. * Stores the z offset value
  94290. */
  94291. zOffset: number;
  94292. /**
  94293. * Gets a value specifying if wireframe mode is enabled
  94294. */
  94295. get wireframe(): boolean;
  94296. /**
  94297. * Sets the state of wireframe mode
  94298. */
  94299. set wireframe(value: boolean);
  94300. /**
  94301. * Gets the value specifying if point clouds are enabled
  94302. */
  94303. get pointsCloud(): boolean;
  94304. /**
  94305. * Sets the state of point cloud mode
  94306. */
  94307. set pointsCloud(value: boolean);
  94308. /**
  94309. * Gets the material fill mode
  94310. */
  94311. get fillMode(): number;
  94312. /**
  94313. * Sets the material fill mode
  94314. */
  94315. set fillMode(value: number);
  94316. /**
  94317. * @hidden
  94318. * Stores the effects for the material
  94319. */
  94320. _effect: Nullable<Effect>;
  94321. /**
  94322. * Specifies if uniform buffers should be used
  94323. */
  94324. private _useUBO;
  94325. /**
  94326. * Stores a reference to the scene
  94327. */
  94328. private _scene;
  94329. /**
  94330. * Stores the fill mode state
  94331. */
  94332. private _fillMode;
  94333. /**
  94334. * Specifies if the depth write state should be cached
  94335. */
  94336. private _cachedDepthWriteState;
  94337. /**
  94338. * Specifies if the depth function state should be cached
  94339. */
  94340. private _cachedDepthFunctionState;
  94341. /**
  94342. * Stores the uniform buffer
  94343. */
  94344. protected _uniformBuffer: UniformBuffer;
  94345. /** @hidden */
  94346. _indexInSceneMaterialArray: number;
  94347. /** @hidden */
  94348. meshMap: Nullable<{
  94349. [id: string]: AbstractMesh | undefined;
  94350. }>;
  94351. /**
  94352. * Creates a material instance
  94353. * @param name defines the name of the material
  94354. * @param scene defines the scene to reference
  94355. * @param doNotAdd specifies if the material should be added to the scene
  94356. */
  94357. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94358. /**
  94359. * Returns a string representation of the current material
  94360. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94361. * @returns a string with material information
  94362. */
  94363. toString(fullDetails?: boolean): string;
  94364. /**
  94365. * Gets the class name of the material
  94366. * @returns a string with the class name of the material
  94367. */
  94368. getClassName(): string;
  94369. /**
  94370. * Specifies if updates for the material been locked
  94371. */
  94372. get isFrozen(): boolean;
  94373. /**
  94374. * Locks updates for the material
  94375. */
  94376. freeze(): void;
  94377. /**
  94378. * Unlocks updates for the material
  94379. */
  94380. unfreeze(): void;
  94381. /**
  94382. * Specifies if the material is ready to be used
  94383. * @param mesh defines the mesh to check
  94384. * @param useInstances specifies if instances should be used
  94385. * @returns a boolean indicating if the material is ready to be used
  94386. */
  94387. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94388. /**
  94389. * Specifies that the submesh is ready to be used
  94390. * @param mesh defines the mesh to check
  94391. * @param subMesh defines which submesh to check
  94392. * @param useInstances specifies that instances should be used
  94393. * @returns a boolean indicating that the submesh is ready or not
  94394. */
  94395. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94396. /**
  94397. * Returns the material effect
  94398. * @returns the effect associated with the material
  94399. */
  94400. getEffect(): Nullable<Effect>;
  94401. /**
  94402. * Returns the current scene
  94403. * @returns a Scene
  94404. */
  94405. getScene(): Scene;
  94406. /**
  94407. * Specifies if the material will require alpha blending
  94408. * @returns a boolean specifying if alpha blending is needed
  94409. */
  94410. needAlphaBlending(): boolean;
  94411. /**
  94412. * Specifies if the mesh will require alpha blending
  94413. * @param mesh defines the mesh to check
  94414. * @returns a boolean specifying if alpha blending is needed for the mesh
  94415. */
  94416. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94417. /**
  94418. * Specifies if this material should be rendered in alpha test mode
  94419. * @returns a boolean specifying if an alpha test is needed.
  94420. */
  94421. needAlphaTesting(): boolean;
  94422. /**
  94423. * Gets the texture used for the alpha test
  94424. * @returns the texture to use for alpha testing
  94425. */
  94426. getAlphaTestTexture(): Nullable<BaseTexture>;
  94427. /**
  94428. * Marks the material to indicate that it needs to be re-calculated
  94429. */
  94430. markDirty(): void;
  94431. /** @hidden */
  94432. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94433. /**
  94434. * Binds the material to the mesh
  94435. * @param world defines the world transformation matrix
  94436. * @param mesh defines the mesh to bind the material to
  94437. */
  94438. bind(world: Matrix, mesh?: Mesh): void;
  94439. /**
  94440. * Binds the submesh to the material
  94441. * @param world defines the world transformation matrix
  94442. * @param mesh defines the mesh containing the submesh
  94443. * @param subMesh defines the submesh to bind the material to
  94444. */
  94445. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94446. /**
  94447. * Binds the world matrix to the material
  94448. * @param world defines the world transformation matrix
  94449. */
  94450. bindOnlyWorldMatrix(world: Matrix): void;
  94451. /**
  94452. * Binds the scene's uniform buffer to the effect.
  94453. * @param effect defines the effect to bind to the scene uniform buffer
  94454. * @param sceneUbo defines the uniform buffer storing scene data
  94455. */
  94456. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94457. /**
  94458. * Binds the view matrix to the effect
  94459. * @param effect defines the effect to bind the view matrix to
  94460. */
  94461. bindView(effect: Effect): void;
  94462. /**
  94463. * Binds the view projection matrix to the effect
  94464. * @param effect defines the effect to bind the view projection matrix to
  94465. */
  94466. bindViewProjection(effect: Effect): void;
  94467. /**
  94468. * Specifies if material alpha testing should be turned on for the mesh
  94469. * @param mesh defines the mesh to check
  94470. */
  94471. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94472. /**
  94473. * Processes to execute after binding the material to a mesh
  94474. * @param mesh defines the rendered mesh
  94475. */
  94476. protected _afterBind(mesh?: Mesh): void;
  94477. /**
  94478. * Unbinds the material from the mesh
  94479. */
  94480. unbind(): void;
  94481. /**
  94482. * Gets the active textures from the material
  94483. * @returns an array of textures
  94484. */
  94485. getActiveTextures(): BaseTexture[];
  94486. /**
  94487. * Specifies if the material uses a texture
  94488. * @param texture defines the texture to check against the material
  94489. * @returns a boolean specifying if the material uses the texture
  94490. */
  94491. hasTexture(texture: BaseTexture): boolean;
  94492. /**
  94493. * Makes a duplicate of the material, and gives it a new name
  94494. * @param name defines the new name for the duplicated material
  94495. * @returns the cloned material
  94496. */
  94497. clone(name: string): Nullable<Material>;
  94498. /**
  94499. * Gets the meshes bound to the material
  94500. * @returns an array of meshes bound to the material
  94501. */
  94502. getBindedMeshes(): AbstractMesh[];
  94503. /**
  94504. * Force shader compilation
  94505. * @param mesh defines the mesh associated with this material
  94506. * @param onCompiled defines a function to execute once the material is compiled
  94507. * @param options defines the options to configure the compilation
  94508. * @param onError defines a function to execute if the material fails compiling
  94509. */
  94510. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94511. /**
  94512. * Force shader compilation
  94513. * @param mesh defines the mesh that will use this material
  94514. * @param options defines additional options for compiling the shaders
  94515. * @returns a promise that resolves when the compilation completes
  94516. */
  94517. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94518. private static readonly _AllDirtyCallBack;
  94519. private static readonly _ImageProcessingDirtyCallBack;
  94520. private static readonly _TextureDirtyCallBack;
  94521. private static readonly _FresnelDirtyCallBack;
  94522. private static readonly _MiscDirtyCallBack;
  94523. private static readonly _LightsDirtyCallBack;
  94524. private static readonly _AttributeDirtyCallBack;
  94525. private static _FresnelAndMiscDirtyCallBack;
  94526. private static _TextureAndMiscDirtyCallBack;
  94527. private static readonly _DirtyCallbackArray;
  94528. private static readonly _RunDirtyCallBacks;
  94529. /**
  94530. * Marks a define in the material to indicate that it needs to be re-computed
  94531. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94532. */
  94533. markAsDirty(flag: number): void;
  94534. /**
  94535. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94536. * @param func defines a function which checks material defines against the submeshes
  94537. */
  94538. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94539. /**
  94540. * Indicates that we need to re-calculated for all submeshes
  94541. */
  94542. protected _markAllSubMeshesAsAllDirty(): void;
  94543. /**
  94544. * Indicates that image processing needs to be re-calculated for all submeshes
  94545. */
  94546. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94547. /**
  94548. * Indicates that textures need to be re-calculated for all submeshes
  94549. */
  94550. protected _markAllSubMeshesAsTexturesDirty(): void;
  94551. /**
  94552. * Indicates that fresnel needs to be re-calculated for all submeshes
  94553. */
  94554. protected _markAllSubMeshesAsFresnelDirty(): void;
  94555. /**
  94556. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94557. */
  94558. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94559. /**
  94560. * Indicates that lights need to be re-calculated for all submeshes
  94561. */
  94562. protected _markAllSubMeshesAsLightsDirty(): void;
  94563. /**
  94564. * Indicates that attributes need to be re-calculated for all submeshes
  94565. */
  94566. protected _markAllSubMeshesAsAttributesDirty(): void;
  94567. /**
  94568. * Indicates that misc needs to be re-calculated for all submeshes
  94569. */
  94570. protected _markAllSubMeshesAsMiscDirty(): void;
  94571. /**
  94572. * Indicates that textures and misc need to be re-calculated for all submeshes
  94573. */
  94574. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94575. /**
  94576. * Disposes the material
  94577. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94578. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94579. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94580. */
  94581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94582. /** @hidden */
  94583. private releaseVertexArrayObject;
  94584. /**
  94585. * Serializes this material
  94586. * @returns the serialized material object
  94587. */
  94588. serialize(): any;
  94589. /**
  94590. * Creates a material from parsed material data
  94591. * @param parsedMaterial defines parsed material data
  94592. * @param scene defines the hosting scene
  94593. * @param rootUrl defines the root URL to use to load textures
  94594. * @returns a new material
  94595. */
  94596. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94597. }
  94598. }
  94599. declare module BABYLON {
  94600. /**
  94601. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94602. * separate meshes. This can be use to improve performances.
  94603. * @see http://doc.babylonjs.com/how_to/multi_materials
  94604. */
  94605. export class MultiMaterial extends Material {
  94606. private _subMaterials;
  94607. /**
  94608. * Gets or Sets the list of Materials used within the multi material.
  94609. * They need to be ordered according to the submeshes order in the associated mesh
  94610. */
  94611. get subMaterials(): Nullable<Material>[];
  94612. set subMaterials(value: Nullable<Material>[]);
  94613. /**
  94614. * Function used to align with Node.getChildren()
  94615. * @returns the list of Materials used within the multi material
  94616. */
  94617. getChildren(): Nullable<Material>[];
  94618. /**
  94619. * Instantiates a new Multi Material
  94620. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94621. * separate meshes. This can be use to improve performances.
  94622. * @see http://doc.babylonjs.com/how_to/multi_materials
  94623. * @param name Define the name in the scene
  94624. * @param scene Define the scene the material belongs to
  94625. */
  94626. constructor(name: string, scene: Scene);
  94627. private _hookArray;
  94628. /**
  94629. * Get one of the submaterial by its index in the submaterials array
  94630. * @param index The index to look the sub material at
  94631. * @returns The Material if the index has been defined
  94632. */
  94633. getSubMaterial(index: number): Nullable<Material>;
  94634. /**
  94635. * Get the list of active textures for the whole sub materials list.
  94636. * @returns All the textures that will be used during the rendering
  94637. */
  94638. getActiveTextures(): BaseTexture[];
  94639. /**
  94640. * Gets the current class name of the material e.g. "MultiMaterial"
  94641. * Mainly use in serialization.
  94642. * @returns the class name
  94643. */
  94644. getClassName(): string;
  94645. /**
  94646. * Checks if the material is ready to render the requested sub mesh
  94647. * @param mesh Define the mesh the submesh belongs to
  94648. * @param subMesh Define the sub mesh to look readyness for
  94649. * @param useInstances Define whether or not the material is used with instances
  94650. * @returns true if ready, otherwise false
  94651. */
  94652. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94653. /**
  94654. * Clones the current material and its related sub materials
  94655. * @param name Define the name of the newly cloned material
  94656. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94657. * @returns the cloned material
  94658. */
  94659. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94660. /**
  94661. * Serializes the materials into a JSON representation.
  94662. * @returns the JSON representation
  94663. */
  94664. serialize(): any;
  94665. /**
  94666. * Dispose the material and release its associated resources
  94667. * @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)
  94668. * @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)
  94669. * @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)
  94670. */
  94671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94672. /**
  94673. * Creates a MultiMaterial from parsed MultiMaterial data.
  94674. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94675. * @param scene defines the hosting scene
  94676. * @returns a new MultiMaterial
  94677. */
  94678. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94679. }
  94680. }
  94681. declare module BABYLON {
  94682. /**
  94683. * Base class for submeshes
  94684. */
  94685. export class BaseSubMesh {
  94686. /** @hidden */
  94687. _materialDefines: Nullable<MaterialDefines>;
  94688. /** @hidden */
  94689. _materialEffect: Nullable<Effect>;
  94690. /**
  94691. * Gets material defines used by the effect associated to the sub mesh
  94692. */
  94693. get materialDefines(): Nullable<MaterialDefines>;
  94694. /**
  94695. * Sets material defines used by the effect associated to the sub mesh
  94696. */
  94697. set materialDefines(defines: Nullable<MaterialDefines>);
  94698. /**
  94699. * Gets associated effect
  94700. */
  94701. get effect(): Nullable<Effect>;
  94702. /**
  94703. * Sets associated effect (effect used to render this submesh)
  94704. * @param effect defines the effect to associate with
  94705. * @param defines defines the set of defines used to compile this effect
  94706. */
  94707. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94708. }
  94709. /**
  94710. * Defines a subdivision inside a mesh
  94711. */
  94712. export class SubMesh extends BaseSubMesh implements ICullable {
  94713. /** the material index to use */
  94714. materialIndex: number;
  94715. /** vertex index start */
  94716. verticesStart: number;
  94717. /** vertices count */
  94718. verticesCount: number;
  94719. /** index start */
  94720. indexStart: number;
  94721. /** indices count */
  94722. indexCount: number;
  94723. /** @hidden */
  94724. _linesIndexCount: number;
  94725. private _mesh;
  94726. private _renderingMesh;
  94727. private _boundingInfo;
  94728. private _linesIndexBuffer;
  94729. /** @hidden */
  94730. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94731. /** @hidden */
  94732. _trianglePlanes: Plane[];
  94733. /** @hidden */
  94734. _lastColliderTransformMatrix: Nullable<Matrix>;
  94735. /** @hidden */
  94736. _renderId: number;
  94737. /** @hidden */
  94738. _alphaIndex: number;
  94739. /** @hidden */
  94740. _distanceToCamera: number;
  94741. /** @hidden */
  94742. _id: number;
  94743. private _currentMaterial;
  94744. /**
  94745. * Add a new submesh to a mesh
  94746. * @param materialIndex defines the material index to use
  94747. * @param verticesStart defines vertex index start
  94748. * @param verticesCount defines vertices count
  94749. * @param indexStart defines index start
  94750. * @param indexCount defines indices count
  94751. * @param mesh defines the parent mesh
  94752. * @param renderingMesh defines an optional rendering mesh
  94753. * @param createBoundingBox defines if bounding box should be created for this submesh
  94754. * @returns the new submesh
  94755. */
  94756. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94757. /**
  94758. * Creates a new submesh
  94759. * @param materialIndex defines the material index to use
  94760. * @param verticesStart defines vertex index start
  94761. * @param verticesCount defines vertices count
  94762. * @param indexStart defines index start
  94763. * @param indexCount defines indices count
  94764. * @param mesh defines the parent mesh
  94765. * @param renderingMesh defines an optional rendering mesh
  94766. * @param createBoundingBox defines if bounding box should be created for this submesh
  94767. */
  94768. constructor(
  94769. /** the material index to use */
  94770. materialIndex: number,
  94771. /** vertex index start */
  94772. verticesStart: number,
  94773. /** vertices count */
  94774. verticesCount: number,
  94775. /** index start */
  94776. indexStart: number,
  94777. /** indices count */
  94778. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94779. /**
  94780. * Returns true if this submesh covers the entire parent mesh
  94781. * @ignorenaming
  94782. */
  94783. get IsGlobal(): boolean;
  94784. /**
  94785. * Returns the submesh BoudingInfo object
  94786. * @returns current bounding info (or mesh's one if the submesh is global)
  94787. */
  94788. getBoundingInfo(): BoundingInfo;
  94789. /**
  94790. * Sets the submesh BoundingInfo
  94791. * @param boundingInfo defines the new bounding info to use
  94792. * @returns the SubMesh
  94793. */
  94794. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94795. /**
  94796. * Returns the mesh of the current submesh
  94797. * @return the parent mesh
  94798. */
  94799. getMesh(): AbstractMesh;
  94800. /**
  94801. * Returns the rendering mesh of the submesh
  94802. * @returns the rendering mesh (could be different from parent mesh)
  94803. */
  94804. getRenderingMesh(): Mesh;
  94805. /**
  94806. * Returns the submesh material
  94807. * @returns null or the current material
  94808. */
  94809. getMaterial(): Nullable<Material>;
  94810. /**
  94811. * Sets a new updated BoundingInfo object to the submesh
  94812. * @param data defines an optional position array to use to determine the bounding info
  94813. * @returns the SubMesh
  94814. */
  94815. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94816. /** @hidden */
  94817. _checkCollision(collider: Collider): boolean;
  94818. /**
  94819. * Updates the submesh BoundingInfo
  94820. * @param world defines the world matrix to use to update the bounding info
  94821. * @returns the submesh
  94822. */
  94823. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94824. /**
  94825. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94826. * @param frustumPlanes defines the frustum planes
  94827. * @returns true if the submesh is intersecting with the frustum
  94828. */
  94829. isInFrustum(frustumPlanes: Plane[]): boolean;
  94830. /**
  94831. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94832. * @param frustumPlanes defines the frustum planes
  94833. * @returns true if the submesh is inside the frustum
  94834. */
  94835. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94836. /**
  94837. * Renders the submesh
  94838. * @param enableAlphaMode defines if alpha needs to be used
  94839. * @returns the submesh
  94840. */
  94841. render(enableAlphaMode: boolean): SubMesh;
  94842. /**
  94843. * @hidden
  94844. */
  94845. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94846. /**
  94847. * Checks if the submesh intersects with a ray
  94848. * @param ray defines the ray to test
  94849. * @returns true is the passed ray intersects the submesh bounding box
  94850. */
  94851. canIntersects(ray: Ray): boolean;
  94852. /**
  94853. * Intersects current submesh with a ray
  94854. * @param ray defines the ray to test
  94855. * @param positions defines mesh's positions array
  94856. * @param indices defines mesh's indices array
  94857. * @param fastCheck defines if only bounding info should be used
  94858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94859. * @returns intersection info or null if no intersection
  94860. */
  94861. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94862. /** @hidden */
  94863. private _intersectLines;
  94864. /** @hidden */
  94865. private _intersectUnIndexedLines;
  94866. /** @hidden */
  94867. private _intersectTriangles;
  94868. /** @hidden */
  94869. private _intersectUnIndexedTriangles;
  94870. /** @hidden */
  94871. _rebuild(): void;
  94872. /**
  94873. * Creates a new submesh from the passed mesh
  94874. * @param newMesh defines the new hosting mesh
  94875. * @param newRenderingMesh defines an optional rendering mesh
  94876. * @returns the new submesh
  94877. */
  94878. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94879. /**
  94880. * Release associated resources
  94881. */
  94882. dispose(): void;
  94883. /**
  94884. * Gets the class name
  94885. * @returns the string "SubMesh".
  94886. */
  94887. getClassName(): string;
  94888. /**
  94889. * Creates a new submesh from indices data
  94890. * @param materialIndex the index of the main mesh material
  94891. * @param startIndex the index where to start the copy in the mesh indices array
  94892. * @param indexCount the number of indices to copy then from the startIndex
  94893. * @param mesh the main mesh to create the submesh from
  94894. * @param renderingMesh the optional rendering mesh
  94895. * @returns a new submesh
  94896. */
  94897. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94898. }
  94899. }
  94900. declare module BABYLON {
  94901. /**
  94902. * Class used to represent data loading progression
  94903. */
  94904. export class SceneLoaderFlags {
  94905. private static _ForceFullSceneLoadingForIncremental;
  94906. private static _ShowLoadingScreen;
  94907. private static _CleanBoneMatrixWeights;
  94908. private static _loggingLevel;
  94909. /**
  94910. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94911. */
  94912. static get ForceFullSceneLoadingForIncremental(): boolean;
  94913. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94914. /**
  94915. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94916. */
  94917. static get ShowLoadingScreen(): boolean;
  94918. static set ShowLoadingScreen(value: boolean);
  94919. /**
  94920. * Defines the current logging level (while loading the scene)
  94921. * @ignorenaming
  94922. */
  94923. static get loggingLevel(): number;
  94924. static set loggingLevel(value: number);
  94925. /**
  94926. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94927. */
  94928. static get CleanBoneMatrixWeights(): boolean;
  94929. static set CleanBoneMatrixWeights(value: boolean);
  94930. }
  94931. }
  94932. declare module BABYLON {
  94933. /**
  94934. * Class used to store geometry data (vertex buffers + index buffer)
  94935. */
  94936. export class Geometry implements IGetSetVerticesData {
  94937. /**
  94938. * Gets or sets the ID of the geometry
  94939. */
  94940. id: string;
  94941. /**
  94942. * Gets or sets the unique ID of the geometry
  94943. */
  94944. uniqueId: number;
  94945. /**
  94946. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94947. */
  94948. delayLoadState: number;
  94949. /**
  94950. * Gets the file containing the data to load when running in delay load state
  94951. */
  94952. delayLoadingFile: Nullable<string>;
  94953. /**
  94954. * Callback called when the geometry is updated
  94955. */
  94956. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94957. private _scene;
  94958. private _engine;
  94959. private _meshes;
  94960. private _totalVertices;
  94961. /** @hidden */
  94962. _indices: IndicesArray;
  94963. /** @hidden */
  94964. _vertexBuffers: {
  94965. [key: string]: VertexBuffer;
  94966. };
  94967. private _isDisposed;
  94968. private _extend;
  94969. private _boundingBias;
  94970. /** @hidden */
  94971. _delayInfo: Array<string>;
  94972. private _indexBuffer;
  94973. private _indexBufferIsUpdatable;
  94974. /** @hidden */
  94975. _boundingInfo: Nullable<BoundingInfo>;
  94976. /** @hidden */
  94977. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94978. /** @hidden */
  94979. _softwareSkinningFrameId: number;
  94980. private _vertexArrayObjects;
  94981. private _updatable;
  94982. /** @hidden */
  94983. _positions: Nullable<Vector3[]>;
  94984. /**
  94985. * 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
  94986. */
  94987. get boundingBias(): Vector2;
  94988. /**
  94989. * 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
  94990. */
  94991. set boundingBias(value: Vector2);
  94992. /**
  94993. * Static function used to attach a new empty geometry to a mesh
  94994. * @param mesh defines the mesh to attach the geometry to
  94995. * @returns the new Geometry
  94996. */
  94997. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94998. /**
  94999. * Creates a new geometry
  95000. * @param id defines the unique ID
  95001. * @param scene defines the hosting scene
  95002. * @param vertexData defines the VertexData used to get geometry data
  95003. * @param updatable defines if geometry must be updatable (false by default)
  95004. * @param mesh defines the mesh that will be associated with the geometry
  95005. */
  95006. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95007. /**
  95008. * Gets the current extend of the geometry
  95009. */
  95010. get extend(): {
  95011. minimum: Vector3;
  95012. maximum: Vector3;
  95013. };
  95014. /**
  95015. * Gets the hosting scene
  95016. * @returns the hosting Scene
  95017. */
  95018. getScene(): Scene;
  95019. /**
  95020. * Gets the hosting engine
  95021. * @returns the hosting Engine
  95022. */
  95023. getEngine(): Engine;
  95024. /**
  95025. * Defines if the geometry is ready to use
  95026. * @returns true if the geometry is ready to be used
  95027. */
  95028. isReady(): boolean;
  95029. /**
  95030. * Gets a value indicating that the geometry should not be serialized
  95031. */
  95032. get doNotSerialize(): boolean;
  95033. /** @hidden */
  95034. _rebuild(): void;
  95035. /**
  95036. * Affects all geometry data in one call
  95037. * @param vertexData defines the geometry data
  95038. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95039. */
  95040. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95041. /**
  95042. * Set specific vertex data
  95043. * @param kind defines the data kind (Position, normal, etc...)
  95044. * @param data defines the vertex data to use
  95045. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95046. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95047. */
  95048. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95049. /**
  95050. * Removes a specific vertex data
  95051. * @param kind defines the data kind (Position, normal, etc...)
  95052. */
  95053. removeVerticesData(kind: string): void;
  95054. /**
  95055. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95056. * @param buffer defines the vertex buffer to use
  95057. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95058. */
  95059. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95060. /**
  95061. * Update a specific vertex buffer
  95062. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95063. * It will do nothing if the buffer is not updatable
  95064. * @param kind defines the data kind (Position, normal, etc...)
  95065. * @param data defines the data to use
  95066. * @param offset defines the offset in the target buffer where to store the data
  95067. * @param useBytes set to true if the offset is in bytes
  95068. */
  95069. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95070. /**
  95071. * Update a specific vertex buffer
  95072. * This function will create a new buffer if the current one is not updatable
  95073. * @param kind defines the data kind (Position, normal, etc...)
  95074. * @param data defines the data to use
  95075. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95076. */
  95077. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95078. private _updateBoundingInfo;
  95079. /** @hidden */
  95080. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95081. /**
  95082. * Gets total number of vertices
  95083. * @returns the total number of vertices
  95084. */
  95085. getTotalVertices(): number;
  95086. /**
  95087. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95088. * @param kind defines the data kind (Position, normal, etc...)
  95089. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95090. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95091. * @returns a float array containing vertex data
  95092. */
  95093. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95094. /**
  95095. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95096. * @param kind defines the data kind (Position, normal, etc...)
  95097. * @returns true if the vertex buffer with the specified kind is updatable
  95098. */
  95099. isVertexBufferUpdatable(kind: string): boolean;
  95100. /**
  95101. * Gets a specific vertex buffer
  95102. * @param kind defines the data kind (Position, normal, etc...)
  95103. * @returns a VertexBuffer
  95104. */
  95105. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95106. /**
  95107. * Returns all vertex buffers
  95108. * @return an object holding all vertex buffers indexed by kind
  95109. */
  95110. getVertexBuffers(): Nullable<{
  95111. [key: string]: VertexBuffer;
  95112. }>;
  95113. /**
  95114. * Gets a boolean indicating if specific vertex buffer is present
  95115. * @param kind defines the data kind (Position, normal, etc...)
  95116. * @returns true if data is present
  95117. */
  95118. isVerticesDataPresent(kind: string): boolean;
  95119. /**
  95120. * Gets a list of all attached data kinds (Position, normal, etc...)
  95121. * @returns a list of string containing all kinds
  95122. */
  95123. getVerticesDataKinds(): string[];
  95124. /**
  95125. * Update index buffer
  95126. * @param indices defines the indices to store in the index buffer
  95127. * @param offset defines the offset in the target buffer where to store the data
  95128. * @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)
  95129. */
  95130. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95131. /**
  95132. * Creates a new index buffer
  95133. * @param indices defines the indices to store in the index buffer
  95134. * @param totalVertices defines the total number of vertices (could be null)
  95135. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95136. */
  95137. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95138. /**
  95139. * Return the total number of indices
  95140. * @returns the total number of indices
  95141. */
  95142. getTotalIndices(): number;
  95143. /**
  95144. * Gets the index buffer array
  95145. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95146. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95147. * @returns the index buffer array
  95148. */
  95149. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95150. /**
  95151. * Gets the index buffer
  95152. * @return the index buffer
  95153. */
  95154. getIndexBuffer(): Nullable<DataBuffer>;
  95155. /** @hidden */
  95156. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95157. /**
  95158. * Release the associated resources for a specific mesh
  95159. * @param mesh defines the source mesh
  95160. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95161. */
  95162. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95163. /**
  95164. * Apply current geometry to a given mesh
  95165. * @param mesh defines the mesh to apply geometry to
  95166. */
  95167. applyToMesh(mesh: Mesh): void;
  95168. private _updateExtend;
  95169. private _applyToMesh;
  95170. private notifyUpdate;
  95171. /**
  95172. * Load the geometry if it was flagged as delay loaded
  95173. * @param scene defines the hosting scene
  95174. * @param onLoaded defines a callback called when the geometry is loaded
  95175. */
  95176. load(scene: Scene, onLoaded?: () => void): void;
  95177. private _queueLoad;
  95178. /**
  95179. * Invert the geometry to move from a right handed system to a left handed one.
  95180. */
  95181. toLeftHanded(): void;
  95182. /** @hidden */
  95183. _resetPointsArrayCache(): void;
  95184. /** @hidden */
  95185. _generatePointsArray(): boolean;
  95186. /**
  95187. * Gets a value indicating if the geometry is disposed
  95188. * @returns true if the geometry was disposed
  95189. */
  95190. isDisposed(): boolean;
  95191. private _disposeVertexArrayObjects;
  95192. /**
  95193. * Free all associated resources
  95194. */
  95195. dispose(): void;
  95196. /**
  95197. * Clone the current geometry into a new geometry
  95198. * @param id defines the unique ID of the new geometry
  95199. * @returns a new geometry object
  95200. */
  95201. copy(id: string): Geometry;
  95202. /**
  95203. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95204. * @return a JSON representation of the current geometry data (without the vertices data)
  95205. */
  95206. serialize(): any;
  95207. private toNumberArray;
  95208. /**
  95209. * Serialize all vertices data into a JSON oject
  95210. * @returns a JSON representation of the current geometry data
  95211. */
  95212. serializeVerticeData(): any;
  95213. /**
  95214. * Extracts a clone of a mesh geometry
  95215. * @param mesh defines the source mesh
  95216. * @param id defines the unique ID of the new geometry object
  95217. * @returns the new geometry object
  95218. */
  95219. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95220. /**
  95221. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95222. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95223. * Be aware Math.random() could cause collisions, but:
  95224. * "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"
  95225. * @returns a string containing a new GUID
  95226. */
  95227. static RandomId(): string;
  95228. /** @hidden */
  95229. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95230. private static _CleanMatricesWeights;
  95231. /**
  95232. * Create a new geometry from persisted data (Using .babylon file format)
  95233. * @param parsedVertexData defines the persisted data
  95234. * @param scene defines the hosting scene
  95235. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95236. * @returns the new geometry object
  95237. */
  95238. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95239. }
  95240. }
  95241. declare module BABYLON {
  95242. /**
  95243. * Define an interface for all classes that will get and set the data on vertices
  95244. */
  95245. export interface IGetSetVerticesData {
  95246. /**
  95247. * Gets a boolean indicating if specific vertex data is present
  95248. * @param kind defines the vertex data kind to use
  95249. * @returns true is data kind is present
  95250. */
  95251. isVerticesDataPresent(kind: string): boolean;
  95252. /**
  95253. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95254. * @param kind defines the data kind (Position, normal, etc...)
  95255. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95256. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95257. * @returns a float array containing vertex data
  95258. */
  95259. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95260. /**
  95261. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95262. * @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.
  95263. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95264. * @returns the indices array or an empty array if the mesh has no geometry
  95265. */
  95266. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95267. /**
  95268. * Set specific vertex data
  95269. * @param kind defines the data kind (Position, normal, etc...)
  95270. * @param data defines the vertex data to use
  95271. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95272. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95273. */
  95274. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95275. /**
  95276. * Update a specific associated vertex buffer
  95277. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95278. * - VertexBuffer.PositionKind
  95279. * - VertexBuffer.UVKind
  95280. * - VertexBuffer.UV2Kind
  95281. * - VertexBuffer.UV3Kind
  95282. * - VertexBuffer.UV4Kind
  95283. * - VertexBuffer.UV5Kind
  95284. * - VertexBuffer.UV6Kind
  95285. * - VertexBuffer.ColorKind
  95286. * - VertexBuffer.MatricesIndicesKind
  95287. * - VertexBuffer.MatricesIndicesExtraKind
  95288. * - VertexBuffer.MatricesWeightsKind
  95289. * - VertexBuffer.MatricesWeightsExtraKind
  95290. * @param data defines the data source
  95291. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95292. * @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)
  95293. */
  95294. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95295. /**
  95296. * Creates a new index buffer
  95297. * @param indices defines the indices to store in the index buffer
  95298. * @param totalVertices defines the total number of vertices (could be null)
  95299. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95300. */
  95301. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95302. }
  95303. /**
  95304. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95305. */
  95306. export class VertexData {
  95307. /**
  95308. * Mesh side orientation : usually the external or front surface
  95309. */
  95310. static readonly FRONTSIDE: number;
  95311. /**
  95312. * Mesh side orientation : usually the internal or back surface
  95313. */
  95314. static readonly BACKSIDE: number;
  95315. /**
  95316. * Mesh side orientation : both internal and external or front and back surfaces
  95317. */
  95318. static readonly DOUBLESIDE: number;
  95319. /**
  95320. * Mesh side orientation : by default, `FRONTSIDE`
  95321. */
  95322. static readonly DEFAULTSIDE: number;
  95323. /**
  95324. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95325. */
  95326. positions: Nullable<FloatArray>;
  95327. /**
  95328. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95329. */
  95330. normals: Nullable<FloatArray>;
  95331. /**
  95332. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95333. */
  95334. tangents: Nullable<FloatArray>;
  95335. /**
  95336. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95337. */
  95338. uvs: Nullable<FloatArray>;
  95339. /**
  95340. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95341. */
  95342. uvs2: Nullable<FloatArray>;
  95343. /**
  95344. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95345. */
  95346. uvs3: Nullable<FloatArray>;
  95347. /**
  95348. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95349. */
  95350. uvs4: Nullable<FloatArray>;
  95351. /**
  95352. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95353. */
  95354. uvs5: Nullable<FloatArray>;
  95355. /**
  95356. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95357. */
  95358. uvs6: Nullable<FloatArray>;
  95359. /**
  95360. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95361. */
  95362. colors: Nullable<FloatArray>;
  95363. /**
  95364. * 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).
  95365. */
  95366. matricesIndices: Nullable<FloatArray>;
  95367. /**
  95368. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95369. */
  95370. matricesWeights: Nullable<FloatArray>;
  95371. /**
  95372. * An array extending the number of possible indices
  95373. */
  95374. matricesIndicesExtra: Nullable<FloatArray>;
  95375. /**
  95376. * An array extending the number of possible weights when the number of indices is extended
  95377. */
  95378. matricesWeightsExtra: Nullable<FloatArray>;
  95379. /**
  95380. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95381. */
  95382. indices: Nullable<IndicesArray>;
  95383. /**
  95384. * Uses the passed data array to set the set the values for the specified kind of data
  95385. * @param data a linear array of floating numbers
  95386. * @param kind the type of data that is being set, eg positions, colors etc
  95387. */
  95388. set(data: FloatArray, kind: string): void;
  95389. /**
  95390. * Associates the vertexData to the passed Mesh.
  95391. * Sets it as updatable or not (default `false`)
  95392. * @param mesh the mesh the vertexData is applied to
  95393. * @param updatable when used and having the value true allows new data to update the vertexData
  95394. * @returns the VertexData
  95395. */
  95396. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95397. /**
  95398. * Associates the vertexData to the passed Geometry.
  95399. * Sets it as updatable or not (default `false`)
  95400. * @param geometry the geometry the vertexData is applied to
  95401. * @param updatable when used and having the value true allows new data to update the vertexData
  95402. * @returns VertexData
  95403. */
  95404. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95405. /**
  95406. * Updates the associated mesh
  95407. * @param mesh the mesh to be updated
  95408. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95409. * @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
  95410. * @returns VertexData
  95411. */
  95412. updateMesh(mesh: Mesh): VertexData;
  95413. /**
  95414. * Updates the associated geometry
  95415. * @param geometry the geometry to be updated
  95416. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95417. * @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
  95418. * @returns VertexData.
  95419. */
  95420. updateGeometry(geometry: Geometry): VertexData;
  95421. private _applyTo;
  95422. private _update;
  95423. /**
  95424. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95425. * @param matrix the transforming matrix
  95426. * @returns the VertexData
  95427. */
  95428. transform(matrix: Matrix): VertexData;
  95429. /**
  95430. * Merges the passed VertexData into the current one
  95431. * @param other the VertexData to be merged into the current one
  95432. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95433. * @returns the modified VertexData
  95434. */
  95435. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95436. private _mergeElement;
  95437. private _validate;
  95438. /**
  95439. * Serializes the VertexData
  95440. * @returns a serialized object
  95441. */
  95442. serialize(): any;
  95443. /**
  95444. * Extracts the vertexData from a mesh
  95445. * @param mesh the mesh from which to extract the VertexData
  95446. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95447. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95448. * @returns the object VertexData associated to the passed mesh
  95449. */
  95450. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95451. /**
  95452. * Extracts the vertexData from the geometry
  95453. * @param geometry the geometry from which to extract the VertexData
  95454. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95455. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95456. * @returns the object VertexData associated to the passed mesh
  95457. */
  95458. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95459. private static _ExtractFrom;
  95460. /**
  95461. * Creates the VertexData for a Ribbon
  95462. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95463. * * pathArray array of paths, each of which an array of successive Vector3
  95464. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95465. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95466. * * 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
  95467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95468. * * 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)
  95469. * * 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)
  95470. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95471. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95472. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95473. * @returns the VertexData of the ribbon
  95474. */
  95475. static CreateRibbon(options: {
  95476. pathArray: Vector3[][];
  95477. closeArray?: boolean;
  95478. closePath?: boolean;
  95479. offset?: number;
  95480. sideOrientation?: number;
  95481. frontUVs?: Vector4;
  95482. backUVs?: Vector4;
  95483. invertUV?: boolean;
  95484. uvs?: Vector2[];
  95485. colors?: Color4[];
  95486. }): VertexData;
  95487. /**
  95488. * Creates the VertexData for a box
  95489. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95490. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95491. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95492. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95493. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95494. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95495. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95497. * * 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)
  95498. * * 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)
  95499. * @returns the VertexData of the box
  95500. */
  95501. static CreateBox(options: {
  95502. size?: number;
  95503. width?: number;
  95504. height?: number;
  95505. depth?: number;
  95506. faceUV?: Vector4[];
  95507. faceColors?: Color4[];
  95508. sideOrientation?: number;
  95509. frontUVs?: Vector4;
  95510. backUVs?: Vector4;
  95511. }): VertexData;
  95512. /**
  95513. * Creates the VertexData for a tiled box
  95514. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95515. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95516. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95517. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95519. * @returns the VertexData of the box
  95520. */
  95521. static CreateTiledBox(options: {
  95522. pattern?: number;
  95523. width?: number;
  95524. height?: number;
  95525. depth?: number;
  95526. tileSize?: number;
  95527. tileWidth?: number;
  95528. tileHeight?: number;
  95529. alignHorizontal?: number;
  95530. alignVertical?: number;
  95531. faceUV?: Vector4[];
  95532. faceColors?: Color4[];
  95533. sideOrientation?: number;
  95534. }): VertexData;
  95535. /**
  95536. * Creates the VertexData for a tiled plane
  95537. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95538. * * pattern a limited pattern arrangement depending on the number
  95539. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95540. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95541. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95543. * * 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)
  95544. * * 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)
  95545. * @returns the VertexData of the tiled plane
  95546. */
  95547. static CreateTiledPlane(options: {
  95548. pattern?: number;
  95549. tileSize?: number;
  95550. tileWidth?: number;
  95551. tileHeight?: number;
  95552. size?: number;
  95553. width?: number;
  95554. height?: number;
  95555. alignHorizontal?: number;
  95556. alignVertical?: number;
  95557. sideOrientation?: number;
  95558. frontUVs?: Vector4;
  95559. backUVs?: Vector4;
  95560. }): VertexData;
  95561. /**
  95562. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95563. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95564. * * segments sets the number of horizontal strips optional, default 32
  95565. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95566. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95567. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95568. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95569. * * 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
  95570. * * 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
  95571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95572. * * 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)
  95573. * * 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)
  95574. * @returns the VertexData of the ellipsoid
  95575. */
  95576. static CreateSphere(options: {
  95577. segments?: number;
  95578. diameter?: number;
  95579. diameterX?: number;
  95580. diameterY?: number;
  95581. diameterZ?: number;
  95582. arc?: number;
  95583. slice?: number;
  95584. sideOrientation?: number;
  95585. frontUVs?: Vector4;
  95586. backUVs?: Vector4;
  95587. }): VertexData;
  95588. /**
  95589. * Creates the VertexData for a cylinder, cone or prism
  95590. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95591. * * height sets the height (y direction) of the cylinder, optional, default 2
  95592. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95593. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95594. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95595. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95596. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95597. * * 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
  95598. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95599. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95600. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95601. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95603. * * 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)
  95604. * * 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)
  95605. * @returns the VertexData of the cylinder, cone or prism
  95606. */
  95607. static CreateCylinder(options: {
  95608. height?: number;
  95609. diameterTop?: number;
  95610. diameterBottom?: number;
  95611. diameter?: number;
  95612. tessellation?: number;
  95613. subdivisions?: number;
  95614. arc?: number;
  95615. faceColors?: Color4[];
  95616. faceUV?: Vector4[];
  95617. hasRings?: boolean;
  95618. enclose?: boolean;
  95619. sideOrientation?: number;
  95620. frontUVs?: Vector4;
  95621. backUVs?: Vector4;
  95622. }): VertexData;
  95623. /**
  95624. * Creates the VertexData for a torus
  95625. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95626. * * diameter the diameter of the torus, optional default 1
  95627. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95628. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95629. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95630. * * 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)
  95631. * * 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)
  95632. * @returns the VertexData of the torus
  95633. */
  95634. static CreateTorus(options: {
  95635. diameter?: number;
  95636. thickness?: number;
  95637. tessellation?: number;
  95638. sideOrientation?: number;
  95639. frontUVs?: Vector4;
  95640. backUVs?: Vector4;
  95641. }): VertexData;
  95642. /**
  95643. * Creates the VertexData of the LineSystem
  95644. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95645. * - lines an array of lines, each line being an array of successive Vector3
  95646. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95647. * @returns the VertexData of the LineSystem
  95648. */
  95649. static CreateLineSystem(options: {
  95650. lines: Vector3[][];
  95651. colors?: Nullable<Color4[][]>;
  95652. }): VertexData;
  95653. /**
  95654. * Create the VertexData for a DashedLines
  95655. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95656. * - points an array successive Vector3
  95657. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95658. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95659. * - dashNb the intended total number of dashes, optional, default 200
  95660. * @returns the VertexData for the DashedLines
  95661. */
  95662. static CreateDashedLines(options: {
  95663. points: Vector3[];
  95664. dashSize?: number;
  95665. gapSize?: number;
  95666. dashNb?: number;
  95667. }): VertexData;
  95668. /**
  95669. * Creates the VertexData for a Ground
  95670. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95671. * - width the width (x direction) of the ground, optional, default 1
  95672. * - height the height (z direction) of the ground, optional, default 1
  95673. * - subdivisions the number of subdivisions per side, optional, default 1
  95674. * @returns the VertexData of the Ground
  95675. */
  95676. static CreateGround(options: {
  95677. width?: number;
  95678. height?: number;
  95679. subdivisions?: number;
  95680. subdivisionsX?: number;
  95681. subdivisionsY?: number;
  95682. }): VertexData;
  95683. /**
  95684. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95685. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95686. * * xmin the ground minimum X coordinate, optional, default -1
  95687. * * zmin the ground minimum Z coordinate, optional, default -1
  95688. * * xmax the ground maximum X coordinate, optional, default 1
  95689. * * zmax the ground maximum Z coordinate, optional, default 1
  95690. * * 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}
  95691. * * 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}
  95692. * @returns the VertexData of the TiledGround
  95693. */
  95694. static CreateTiledGround(options: {
  95695. xmin: number;
  95696. zmin: number;
  95697. xmax: number;
  95698. zmax: number;
  95699. subdivisions?: {
  95700. w: number;
  95701. h: number;
  95702. };
  95703. precision?: {
  95704. w: number;
  95705. h: number;
  95706. };
  95707. }): VertexData;
  95708. /**
  95709. * Creates the VertexData of the Ground designed from a heightmap
  95710. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95711. * * width the width (x direction) of the ground
  95712. * * height the height (z direction) of the ground
  95713. * * subdivisions the number of subdivisions per side
  95714. * * minHeight the minimum altitude on the ground, optional, default 0
  95715. * * maxHeight the maximum altitude on the ground, optional default 1
  95716. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95717. * * buffer the array holding the image color data
  95718. * * bufferWidth the width of image
  95719. * * bufferHeight the height of image
  95720. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95721. * @returns the VertexData of the Ground designed from a heightmap
  95722. */
  95723. static CreateGroundFromHeightMap(options: {
  95724. width: number;
  95725. height: number;
  95726. subdivisions: number;
  95727. minHeight: number;
  95728. maxHeight: number;
  95729. colorFilter: Color3;
  95730. buffer: Uint8Array;
  95731. bufferWidth: number;
  95732. bufferHeight: number;
  95733. alphaFilter: number;
  95734. }): VertexData;
  95735. /**
  95736. * Creates the VertexData for a Plane
  95737. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95738. * * size sets the width and height of the plane to the value of size, optional default 1
  95739. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95740. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95742. * * 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)
  95743. * * 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)
  95744. * @returns the VertexData of the box
  95745. */
  95746. static CreatePlane(options: {
  95747. size?: number;
  95748. width?: number;
  95749. height?: number;
  95750. sideOrientation?: number;
  95751. frontUVs?: Vector4;
  95752. backUVs?: Vector4;
  95753. }): VertexData;
  95754. /**
  95755. * Creates the VertexData of the Disc or regular Polygon
  95756. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95757. * * radius the radius of the disc, optional default 0.5
  95758. * * tessellation the number of polygon sides, optional, default 64
  95759. * * 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
  95760. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95761. * * 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)
  95762. * * 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)
  95763. * @returns the VertexData of the box
  95764. */
  95765. static CreateDisc(options: {
  95766. radius?: number;
  95767. tessellation?: number;
  95768. arc?: number;
  95769. sideOrientation?: number;
  95770. frontUVs?: Vector4;
  95771. backUVs?: Vector4;
  95772. }): VertexData;
  95773. /**
  95774. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95775. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95776. * @param polygon a mesh built from polygonTriangulation.build()
  95777. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95778. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95779. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95780. * @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)
  95781. * @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)
  95782. * @returns the VertexData of the Polygon
  95783. */
  95784. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95785. /**
  95786. * Creates the VertexData of the IcoSphere
  95787. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95788. * * radius the radius of the IcoSphere, optional default 1
  95789. * * radiusX allows stretching in the x direction, optional, default radius
  95790. * * radiusY allows stretching in the y direction, optional, default radius
  95791. * * radiusZ allows stretching in the z direction, optional, default radius
  95792. * * flat when true creates a flat shaded mesh, optional, default true
  95793. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95794. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95795. * * 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)
  95796. * * 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)
  95797. * @returns the VertexData of the IcoSphere
  95798. */
  95799. static CreateIcoSphere(options: {
  95800. radius?: number;
  95801. radiusX?: number;
  95802. radiusY?: number;
  95803. radiusZ?: number;
  95804. flat?: boolean;
  95805. subdivisions?: number;
  95806. sideOrientation?: number;
  95807. frontUVs?: Vector4;
  95808. backUVs?: Vector4;
  95809. }): VertexData;
  95810. /**
  95811. * Creates the VertexData for a Polyhedron
  95812. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95813. * * type provided types are:
  95814. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95815. * * 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)
  95816. * * size the size of the IcoSphere, optional default 1
  95817. * * sizeX allows stretching in the x direction, optional, default size
  95818. * * sizeY allows stretching in the y direction, optional, default size
  95819. * * sizeZ allows stretching in the z direction, optional, default size
  95820. * * 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
  95821. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95822. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95823. * * flat when true creates a flat shaded mesh, optional, default true
  95824. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95825. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95826. * * 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)
  95827. * * 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)
  95828. * @returns the VertexData of the Polyhedron
  95829. */
  95830. static CreatePolyhedron(options: {
  95831. type?: number;
  95832. size?: number;
  95833. sizeX?: number;
  95834. sizeY?: number;
  95835. sizeZ?: number;
  95836. custom?: any;
  95837. faceUV?: Vector4[];
  95838. faceColors?: Color4[];
  95839. flat?: boolean;
  95840. sideOrientation?: number;
  95841. frontUVs?: Vector4;
  95842. backUVs?: Vector4;
  95843. }): VertexData;
  95844. /**
  95845. * Creates the VertexData for a TorusKnot
  95846. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95847. * * radius the radius of the torus knot, optional, default 2
  95848. * * tube the thickness of the tube, optional, default 0.5
  95849. * * radialSegments the number of sides on each tube segments, optional, default 32
  95850. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95851. * * p the number of windings around the z axis, optional, default 2
  95852. * * q the number of windings around the x axis, optional, default 3
  95853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95854. * * 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)
  95855. * * 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)
  95856. * @returns the VertexData of the Torus Knot
  95857. */
  95858. static CreateTorusKnot(options: {
  95859. radius?: number;
  95860. tube?: number;
  95861. radialSegments?: number;
  95862. tubularSegments?: number;
  95863. p?: number;
  95864. q?: number;
  95865. sideOrientation?: number;
  95866. frontUVs?: Vector4;
  95867. backUVs?: Vector4;
  95868. }): VertexData;
  95869. /**
  95870. * Compute normals for given positions and indices
  95871. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95872. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95873. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95874. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95875. * * facetNormals : optional array of facet normals (vector3)
  95876. * * facetPositions : optional array of facet positions (vector3)
  95877. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95878. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95879. * * bInfo : optional bounding info, required for facetPartitioning computation
  95880. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95881. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95882. * * useRightHandedSystem: optional boolean to for right handed system computation
  95883. * * depthSort : optional boolean to enable the facet depth sort computation
  95884. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95885. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95886. */
  95887. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95888. facetNormals?: any;
  95889. facetPositions?: any;
  95890. facetPartitioning?: any;
  95891. ratio?: number;
  95892. bInfo?: any;
  95893. bbSize?: Vector3;
  95894. subDiv?: any;
  95895. useRightHandedSystem?: boolean;
  95896. depthSort?: boolean;
  95897. distanceTo?: Vector3;
  95898. depthSortedFacets?: any;
  95899. }): void;
  95900. /** @hidden */
  95901. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95902. /**
  95903. * Applies VertexData created from the imported parameters to the geometry
  95904. * @param parsedVertexData the parsed data from an imported file
  95905. * @param geometry the geometry to apply the VertexData to
  95906. */
  95907. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95908. }
  95909. }
  95910. declare module BABYLON {
  95911. /**
  95912. * Defines a target to use with MorphTargetManager
  95913. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95914. */
  95915. export class MorphTarget implements IAnimatable {
  95916. /** defines the name of the target */
  95917. name: string;
  95918. /**
  95919. * Gets or sets the list of animations
  95920. */
  95921. animations: Animation[];
  95922. private _scene;
  95923. private _positions;
  95924. private _normals;
  95925. private _tangents;
  95926. private _uvs;
  95927. private _influence;
  95928. private _uniqueId;
  95929. /**
  95930. * Observable raised when the influence changes
  95931. */
  95932. onInfluenceChanged: Observable<boolean>;
  95933. /** @hidden */
  95934. _onDataLayoutChanged: Observable<void>;
  95935. /**
  95936. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95937. */
  95938. get influence(): number;
  95939. set influence(influence: number);
  95940. /**
  95941. * Gets or sets the id of the morph Target
  95942. */
  95943. id: string;
  95944. private _animationPropertiesOverride;
  95945. /**
  95946. * Gets or sets the animation properties override
  95947. */
  95948. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95949. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95950. /**
  95951. * Creates a new MorphTarget
  95952. * @param name defines the name of the target
  95953. * @param influence defines the influence to use
  95954. * @param scene defines the scene the morphtarget belongs to
  95955. */
  95956. constructor(
  95957. /** defines the name of the target */
  95958. name: string, influence?: number, scene?: Nullable<Scene>);
  95959. /**
  95960. * Gets the unique ID of this manager
  95961. */
  95962. get uniqueId(): number;
  95963. /**
  95964. * Gets a boolean defining if the target contains position data
  95965. */
  95966. get hasPositions(): boolean;
  95967. /**
  95968. * Gets a boolean defining if the target contains normal data
  95969. */
  95970. get hasNormals(): boolean;
  95971. /**
  95972. * Gets a boolean defining if the target contains tangent data
  95973. */
  95974. get hasTangents(): boolean;
  95975. /**
  95976. * Gets a boolean defining if the target contains texture coordinates data
  95977. */
  95978. get hasUVs(): boolean;
  95979. /**
  95980. * Affects position data to this target
  95981. * @param data defines the position data to use
  95982. */
  95983. setPositions(data: Nullable<FloatArray>): void;
  95984. /**
  95985. * Gets the position data stored in this target
  95986. * @returns a FloatArray containing the position data (or null if not present)
  95987. */
  95988. getPositions(): Nullable<FloatArray>;
  95989. /**
  95990. * Affects normal data to this target
  95991. * @param data defines the normal data to use
  95992. */
  95993. setNormals(data: Nullable<FloatArray>): void;
  95994. /**
  95995. * Gets the normal data stored in this target
  95996. * @returns a FloatArray containing the normal data (or null if not present)
  95997. */
  95998. getNormals(): Nullable<FloatArray>;
  95999. /**
  96000. * Affects tangent data to this target
  96001. * @param data defines the tangent data to use
  96002. */
  96003. setTangents(data: Nullable<FloatArray>): void;
  96004. /**
  96005. * Gets the tangent data stored in this target
  96006. * @returns a FloatArray containing the tangent data (or null if not present)
  96007. */
  96008. getTangents(): Nullable<FloatArray>;
  96009. /**
  96010. * Affects texture coordinates data to this target
  96011. * @param data defines the texture coordinates data to use
  96012. */
  96013. setUVs(data: Nullable<FloatArray>): void;
  96014. /**
  96015. * Gets the texture coordinates data stored in this target
  96016. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96017. */
  96018. getUVs(): Nullable<FloatArray>;
  96019. /**
  96020. * Clone the current target
  96021. * @returns a new MorphTarget
  96022. */
  96023. clone(): MorphTarget;
  96024. /**
  96025. * Serializes the current target into a Serialization object
  96026. * @returns the serialized object
  96027. */
  96028. serialize(): any;
  96029. /**
  96030. * Returns the string "MorphTarget"
  96031. * @returns "MorphTarget"
  96032. */
  96033. getClassName(): string;
  96034. /**
  96035. * Creates a new target from serialized data
  96036. * @param serializationObject defines the serialized data to use
  96037. * @returns a new MorphTarget
  96038. */
  96039. static Parse(serializationObject: any): MorphTarget;
  96040. /**
  96041. * Creates a MorphTarget from mesh data
  96042. * @param mesh defines the source mesh
  96043. * @param name defines the name to use for the new target
  96044. * @param influence defines the influence to attach to the target
  96045. * @returns a new MorphTarget
  96046. */
  96047. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96048. }
  96049. }
  96050. declare module BABYLON {
  96051. /**
  96052. * This class is used to deform meshes using morphing between different targets
  96053. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96054. */
  96055. export class MorphTargetManager {
  96056. private _targets;
  96057. private _targetInfluenceChangedObservers;
  96058. private _targetDataLayoutChangedObservers;
  96059. private _activeTargets;
  96060. private _scene;
  96061. private _influences;
  96062. private _supportsNormals;
  96063. private _supportsTangents;
  96064. private _supportsUVs;
  96065. private _vertexCount;
  96066. private _uniqueId;
  96067. private _tempInfluences;
  96068. /**
  96069. * Gets or sets a boolean indicating if normals must be morphed
  96070. */
  96071. enableNormalMorphing: boolean;
  96072. /**
  96073. * Gets or sets a boolean indicating if tangents must be morphed
  96074. */
  96075. enableTangentMorphing: boolean;
  96076. /**
  96077. * Gets or sets a boolean indicating if UV must be morphed
  96078. */
  96079. enableUVMorphing: boolean;
  96080. /**
  96081. * Creates a new MorphTargetManager
  96082. * @param scene defines the current scene
  96083. */
  96084. constructor(scene?: Nullable<Scene>);
  96085. /**
  96086. * Gets the unique ID of this manager
  96087. */
  96088. get uniqueId(): number;
  96089. /**
  96090. * Gets the number of vertices handled by this manager
  96091. */
  96092. get vertexCount(): number;
  96093. /**
  96094. * Gets a boolean indicating if this manager supports morphing of normals
  96095. */
  96096. get supportsNormals(): boolean;
  96097. /**
  96098. * Gets a boolean indicating if this manager supports morphing of tangents
  96099. */
  96100. get supportsTangents(): boolean;
  96101. /**
  96102. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96103. */
  96104. get supportsUVs(): boolean;
  96105. /**
  96106. * Gets the number of targets stored in this manager
  96107. */
  96108. get numTargets(): number;
  96109. /**
  96110. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96111. */
  96112. get numInfluencers(): number;
  96113. /**
  96114. * Gets the list of influences (one per target)
  96115. */
  96116. get influences(): Float32Array;
  96117. /**
  96118. * Gets the active target at specified index. An active target is a target with an influence > 0
  96119. * @param index defines the index to check
  96120. * @returns the requested target
  96121. */
  96122. getActiveTarget(index: number): MorphTarget;
  96123. /**
  96124. * Gets the target at specified index
  96125. * @param index defines the index to check
  96126. * @returns the requested target
  96127. */
  96128. getTarget(index: number): MorphTarget;
  96129. /**
  96130. * Add a new target to this manager
  96131. * @param target defines the target to add
  96132. */
  96133. addTarget(target: MorphTarget): void;
  96134. /**
  96135. * Removes a target from the manager
  96136. * @param target defines the target to remove
  96137. */
  96138. removeTarget(target: MorphTarget): void;
  96139. /**
  96140. * Clone the current manager
  96141. * @returns a new MorphTargetManager
  96142. */
  96143. clone(): MorphTargetManager;
  96144. /**
  96145. * Serializes the current manager into a Serialization object
  96146. * @returns the serialized object
  96147. */
  96148. serialize(): any;
  96149. private _syncActiveTargets;
  96150. /**
  96151. * Syncrhonize the targets with all the meshes using this morph target manager
  96152. */
  96153. synchronize(): void;
  96154. /**
  96155. * Creates a new MorphTargetManager from serialized data
  96156. * @param serializationObject defines the serialized data
  96157. * @param scene defines the hosting scene
  96158. * @returns the new MorphTargetManager
  96159. */
  96160. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96161. }
  96162. }
  96163. declare module BABYLON {
  96164. /**
  96165. * Class used to represent a specific level of detail of a mesh
  96166. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96167. */
  96168. export class MeshLODLevel {
  96169. /** Defines the distance where this level should start being displayed */
  96170. distance: number;
  96171. /** Defines the mesh to use to render this level */
  96172. mesh: Nullable<Mesh>;
  96173. /**
  96174. * Creates a new LOD level
  96175. * @param distance defines the distance where this level should star being displayed
  96176. * @param mesh defines the mesh to use to render this level
  96177. */
  96178. constructor(
  96179. /** Defines the distance where this level should start being displayed */
  96180. distance: number,
  96181. /** Defines the mesh to use to render this level */
  96182. mesh: Nullable<Mesh>);
  96183. }
  96184. }
  96185. declare module BABYLON {
  96186. /**
  96187. * Mesh representing the gorund
  96188. */
  96189. export class GroundMesh extends Mesh {
  96190. /** If octree should be generated */
  96191. generateOctree: boolean;
  96192. private _heightQuads;
  96193. /** @hidden */
  96194. _subdivisionsX: number;
  96195. /** @hidden */
  96196. _subdivisionsY: number;
  96197. /** @hidden */
  96198. _width: number;
  96199. /** @hidden */
  96200. _height: number;
  96201. /** @hidden */
  96202. _minX: number;
  96203. /** @hidden */
  96204. _maxX: number;
  96205. /** @hidden */
  96206. _minZ: number;
  96207. /** @hidden */
  96208. _maxZ: number;
  96209. constructor(name: string, scene: Scene);
  96210. /**
  96211. * "GroundMesh"
  96212. * @returns "GroundMesh"
  96213. */
  96214. getClassName(): string;
  96215. /**
  96216. * The minimum of x and y subdivisions
  96217. */
  96218. get subdivisions(): number;
  96219. /**
  96220. * X subdivisions
  96221. */
  96222. get subdivisionsX(): number;
  96223. /**
  96224. * Y subdivisions
  96225. */
  96226. get subdivisionsY(): number;
  96227. /**
  96228. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96229. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96230. * @param chunksCount the number of subdivisions for x and y
  96231. * @param octreeBlocksSize (Default: 32)
  96232. */
  96233. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96234. /**
  96235. * Returns a height (y) value in the Worl system :
  96236. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96237. * @param x x coordinate
  96238. * @param z z coordinate
  96239. * @returns the ground y position if (x, z) are outside the ground surface.
  96240. */
  96241. getHeightAtCoordinates(x: number, z: number): number;
  96242. /**
  96243. * Returns a normalized vector (Vector3) orthogonal to the ground
  96244. * at the ground coordinates (x, z) expressed in the World system.
  96245. * @param x x coordinate
  96246. * @param z z coordinate
  96247. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96248. */
  96249. getNormalAtCoordinates(x: number, z: number): Vector3;
  96250. /**
  96251. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96252. * at the ground coordinates (x, z) expressed in the World system.
  96253. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96254. * @param x x coordinate
  96255. * @param z z coordinate
  96256. * @param ref vector to store the result
  96257. * @returns the GroundMesh.
  96258. */
  96259. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96260. /**
  96261. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96262. * if the ground has been updated.
  96263. * This can be used in the render loop.
  96264. * @returns the GroundMesh.
  96265. */
  96266. updateCoordinateHeights(): GroundMesh;
  96267. private _getFacetAt;
  96268. private _initHeightQuads;
  96269. private _computeHeightQuads;
  96270. /**
  96271. * Serializes this ground mesh
  96272. * @param serializationObject object to write serialization to
  96273. */
  96274. serialize(serializationObject: any): void;
  96275. /**
  96276. * Parses a serialized ground mesh
  96277. * @param parsedMesh the serialized mesh
  96278. * @param scene the scene to create the ground mesh in
  96279. * @returns the created ground mesh
  96280. */
  96281. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96282. }
  96283. }
  96284. declare module BABYLON {
  96285. /**
  96286. * Interface for Physics-Joint data
  96287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96288. */
  96289. export interface PhysicsJointData {
  96290. /**
  96291. * The main pivot of the joint
  96292. */
  96293. mainPivot?: Vector3;
  96294. /**
  96295. * The connected pivot of the joint
  96296. */
  96297. connectedPivot?: Vector3;
  96298. /**
  96299. * The main axis of the joint
  96300. */
  96301. mainAxis?: Vector3;
  96302. /**
  96303. * The connected axis of the joint
  96304. */
  96305. connectedAxis?: Vector3;
  96306. /**
  96307. * The collision of the joint
  96308. */
  96309. collision?: boolean;
  96310. /**
  96311. * Native Oimo/Cannon/Energy data
  96312. */
  96313. nativeParams?: any;
  96314. }
  96315. /**
  96316. * This is a holder class for the physics joint created by the physics plugin
  96317. * It holds a set of functions to control the underlying joint
  96318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96319. */
  96320. export class PhysicsJoint {
  96321. /**
  96322. * The type of the physics joint
  96323. */
  96324. type: number;
  96325. /**
  96326. * The data for the physics joint
  96327. */
  96328. jointData: PhysicsJointData;
  96329. private _physicsJoint;
  96330. protected _physicsPlugin: IPhysicsEnginePlugin;
  96331. /**
  96332. * Initializes the physics joint
  96333. * @param type The type of the physics joint
  96334. * @param jointData The data for the physics joint
  96335. */
  96336. constructor(
  96337. /**
  96338. * The type of the physics joint
  96339. */
  96340. type: number,
  96341. /**
  96342. * The data for the physics joint
  96343. */
  96344. jointData: PhysicsJointData);
  96345. /**
  96346. * Gets the physics joint
  96347. */
  96348. get physicsJoint(): any;
  96349. /**
  96350. * Sets the physics joint
  96351. */
  96352. set physicsJoint(newJoint: any);
  96353. /**
  96354. * Sets the physics plugin
  96355. */
  96356. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96357. /**
  96358. * Execute a function that is physics-plugin specific.
  96359. * @param {Function} func the function that will be executed.
  96360. * It accepts two parameters: the physics world and the physics joint
  96361. */
  96362. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96363. /**
  96364. * Distance-Joint type
  96365. */
  96366. static DistanceJoint: number;
  96367. /**
  96368. * Hinge-Joint type
  96369. */
  96370. static HingeJoint: number;
  96371. /**
  96372. * Ball-and-Socket joint type
  96373. */
  96374. static BallAndSocketJoint: number;
  96375. /**
  96376. * Wheel-Joint type
  96377. */
  96378. static WheelJoint: number;
  96379. /**
  96380. * Slider-Joint type
  96381. */
  96382. static SliderJoint: number;
  96383. /**
  96384. * Prismatic-Joint type
  96385. */
  96386. static PrismaticJoint: number;
  96387. /**
  96388. * Universal-Joint type
  96389. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96390. */
  96391. static UniversalJoint: number;
  96392. /**
  96393. * Hinge-Joint 2 type
  96394. */
  96395. static Hinge2Joint: number;
  96396. /**
  96397. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96398. */
  96399. static PointToPointJoint: number;
  96400. /**
  96401. * Spring-Joint type
  96402. */
  96403. static SpringJoint: number;
  96404. /**
  96405. * Lock-Joint type
  96406. */
  96407. static LockJoint: number;
  96408. }
  96409. /**
  96410. * A class representing a physics distance joint
  96411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96412. */
  96413. export class DistanceJoint extends PhysicsJoint {
  96414. /**
  96415. *
  96416. * @param jointData The data for the Distance-Joint
  96417. */
  96418. constructor(jointData: DistanceJointData);
  96419. /**
  96420. * Update the predefined distance.
  96421. * @param maxDistance The maximum preferred distance
  96422. * @param minDistance The minimum preferred distance
  96423. */
  96424. updateDistance(maxDistance: number, minDistance?: number): void;
  96425. }
  96426. /**
  96427. * Represents a Motor-Enabled Joint
  96428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96429. */
  96430. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96431. /**
  96432. * Initializes the Motor-Enabled Joint
  96433. * @param type The type of the joint
  96434. * @param jointData The physica joint data for the joint
  96435. */
  96436. constructor(type: number, jointData: PhysicsJointData);
  96437. /**
  96438. * Set the motor values.
  96439. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96440. * @param force the force to apply
  96441. * @param maxForce max force for this motor.
  96442. */
  96443. setMotor(force?: number, maxForce?: number): void;
  96444. /**
  96445. * Set the motor's limits.
  96446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96447. * @param upperLimit The upper limit of the motor
  96448. * @param lowerLimit The lower limit of the motor
  96449. */
  96450. setLimit(upperLimit: number, lowerLimit?: number): void;
  96451. }
  96452. /**
  96453. * This class represents a single physics Hinge-Joint
  96454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96455. */
  96456. export class HingeJoint extends MotorEnabledJoint {
  96457. /**
  96458. * Initializes the Hinge-Joint
  96459. * @param jointData The joint data for the Hinge-Joint
  96460. */
  96461. constructor(jointData: PhysicsJointData);
  96462. /**
  96463. * Set the motor values.
  96464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96465. * @param {number} force the force to apply
  96466. * @param {number} maxForce max force for this motor.
  96467. */
  96468. setMotor(force?: number, maxForce?: number): void;
  96469. /**
  96470. * Set the motor's limits.
  96471. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96472. * @param upperLimit The upper limit of the motor
  96473. * @param lowerLimit The lower limit of the motor
  96474. */
  96475. setLimit(upperLimit: number, lowerLimit?: number): void;
  96476. }
  96477. /**
  96478. * This class represents a dual hinge physics joint (same as wheel joint)
  96479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96480. */
  96481. export class Hinge2Joint extends MotorEnabledJoint {
  96482. /**
  96483. * Initializes the Hinge2-Joint
  96484. * @param jointData The joint data for the Hinge2-Joint
  96485. */
  96486. constructor(jointData: PhysicsJointData);
  96487. /**
  96488. * Set the motor values.
  96489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96490. * @param {number} targetSpeed the speed the motor is to reach
  96491. * @param {number} maxForce max force for this motor.
  96492. * @param {motorIndex} the motor's index, 0 or 1.
  96493. */
  96494. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96495. /**
  96496. * Set the motor limits.
  96497. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96498. * @param {number} upperLimit the upper limit
  96499. * @param {number} lowerLimit lower limit
  96500. * @param {motorIndex} the motor's index, 0 or 1.
  96501. */
  96502. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96503. }
  96504. /**
  96505. * Interface for a motor enabled joint
  96506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96507. */
  96508. export interface IMotorEnabledJoint {
  96509. /**
  96510. * Physics joint
  96511. */
  96512. physicsJoint: any;
  96513. /**
  96514. * Sets the motor of the motor-enabled joint
  96515. * @param force The force of the motor
  96516. * @param maxForce The maximum force of the motor
  96517. * @param motorIndex The index of the motor
  96518. */
  96519. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96520. /**
  96521. * Sets the limit of the motor
  96522. * @param upperLimit The upper limit of the motor
  96523. * @param lowerLimit The lower limit of the motor
  96524. * @param motorIndex The index of the motor
  96525. */
  96526. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96527. }
  96528. /**
  96529. * Joint data for a Distance-Joint
  96530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96531. */
  96532. export interface DistanceJointData extends PhysicsJointData {
  96533. /**
  96534. * Max distance the 2 joint objects can be apart
  96535. */
  96536. maxDistance: number;
  96537. }
  96538. /**
  96539. * Joint data from a spring joint
  96540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96541. */
  96542. export interface SpringJointData extends PhysicsJointData {
  96543. /**
  96544. * Length of the spring
  96545. */
  96546. length: number;
  96547. /**
  96548. * Stiffness of the spring
  96549. */
  96550. stiffness: number;
  96551. /**
  96552. * Damping of the spring
  96553. */
  96554. damping: number;
  96555. /** this callback will be called when applying the force to the impostors. */
  96556. forceApplicationCallback: () => void;
  96557. }
  96558. }
  96559. declare module BABYLON {
  96560. /**
  96561. * Holds the data for the raycast result
  96562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96563. */
  96564. export class PhysicsRaycastResult {
  96565. private _hasHit;
  96566. private _hitDistance;
  96567. private _hitNormalWorld;
  96568. private _hitPointWorld;
  96569. private _rayFromWorld;
  96570. private _rayToWorld;
  96571. /**
  96572. * Gets if there was a hit
  96573. */
  96574. get hasHit(): boolean;
  96575. /**
  96576. * Gets the distance from the hit
  96577. */
  96578. get hitDistance(): number;
  96579. /**
  96580. * Gets the hit normal/direction in the world
  96581. */
  96582. get hitNormalWorld(): Vector3;
  96583. /**
  96584. * Gets the hit point in the world
  96585. */
  96586. get hitPointWorld(): Vector3;
  96587. /**
  96588. * Gets the ray "start point" of the ray in the world
  96589. */
  96590. get rayFromWorld(): Vector3;
  96591. /**
  96592. * Gets the ray "end point" of the ray in the world
  96593. */
  96594. get rayToWorld(): Vector3;
  96595. /**
  96596. * Sets the hit data (normal & point in world space)
  96597. * @param hitNormalWorld defines the normal in world space
  96598. * @param hitPointWorld defines the point in world space
  96599. */
  96600. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96601. /**
  96602. * Sets the distance from the start point to the hit point
  96603. * @param distance
  96604. */
  96605. setHitDistance(distance: number): void;
  96606. /**
  96607. * Calculates the distance manually
  96608. */
  96609. calculateHitDistance(): void;
  96610. /**
  96611. * Resets all the values to default
  96612. * @param from The from point on world space
  96613. * @param to The to point on world space
  96614. */
  96615. reset(from?: Vector3, to?: Vector3): void;
  96616. }
  96617. /**
  96618. * Interface for the size containing width and height
  96619. */
  96620. interface IXYZ {
  96621. /**
  96622. * X
  96623. */
  96624. x: number;
  96625. /**
  96626. * Y
  96627. */
  96628. y: number;
  96629. /**
  96630. * Z
  96631. */
  96632. z: number;
  96633. }
  96634. }
  96635. declare module BABYLON {
  96636. /**
  96637. * Interface used to describe a physics joint
  96638. */
  96639. export interface PhysicsImpostorJoint {
  96640. /** Defines the main impostor to which the joint is linked */
  96641. mainImpostor: PhysicsImpostor;
  96642. /** Defines the impostor that is connected to the main impostor using this joint */
  96643. connectedImpostor: PhysicsImpostor;
  96644. /** Defines the joint itself */
  96645. joint: PhysicsJoint;
  96646. }
  96647. /** @hidden */
  96648. export interface IPhysicsEnginePlugin {
  96649. world: any;
  96650. name: string;
  96651. setGravity(gravity: Vector3): void;
  96652. setTimeStep(timeStep: number): void;
  96653. getTimeStep(): number;
  96654. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96655. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96656. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96657. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96658. removePhysicsBody(impostor: PhysicsImpostor): void;
  96659. generateJoint(joint: PhysicsImpostorJoint): void;
  96660. removeJoint(joint: PhysicsImpostorJoint): void;
  96661. isSupported(): boolean;
  96662. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96663. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96664. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96665. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96666. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96667. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96668. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96669. getBodyMass(impostor: PhysicsImpostor): number;
  96670. getBodyFriction(impostor: PhysicsImpostor): number;
  96671. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96672. getBodyRestitution(impostor: PhysicsImpostor): number;
  96673. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96674. getBodyPressure?(impostor: PhysicsImpostor): number;
  96675. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96676. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96677. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96678. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96679. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96680. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96681. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96682. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96683. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96684. sleepBody(impostor: PhysicsImpostor): void;
  96685. wakeUpBody(impostor: PhysicsImpostor): void;
  96686. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96687. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96688. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96689. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96690. getRadius(impostor: PhysicsImpostor): number;
  96691. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96692. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96693. dispose(): void;
  96694. }
  96695. /**
  96696. * Interface used to define a physics engine
  96697. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96698. */
  96699. export interface IPhysicsEngine {
  96700. /**
  96701. * Gets the gravity vector used by the simulation
  96702. */
  96703. gravity: Vector3;
  96704. /**
  96705. * Sets the gravity vector used by the simulation
  96706. * @param gravity defines the gravity vector to use
  96707. */
  96708. setGravity(gravity: Vector3): void;
  96709. /**
  96710. * Set the time step of the physics engine.
  96711. * Default is 1/60.
  96712. * To slow it down, enter 1/600 for example.
  96713. * To speed it up, 1/30
  96714. * @param newTimeStep the new timestep to apply to this world.
  96715. */
  96716. setTimeStep(newTimeStep: number): void;
  96717. /**
  96718. * Get the time step of the physics engine.
  96719. * @returns the current time step
  96720. */
  96721. getTimeStep(): number;
  96722. /**
  96723. * Set the sub time step of the physics engine.
  96724. * Default is 0 meaning there is no sub steps
  96725. * To increase physics resolution precision, set a small value (like 1 ms)
  96726. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96727. */
  96728. setSubTimeStep(subTimeStep: number): void;
  96729. /**
  96730. * Get the sub time step of the physics engine.
  96731. * @returns the current sub time step
  96732. */
  96733. getSubTimeStep(): number;
  96734. /**
  96735. * Release all resources
  96736. */
  96737. dispose(): void;
  96738. /**
  96739. * Gets the name of the current physics plugin
  96740. * @returns the name of the plugin
  96741. */
  96742. getPhysicsPluginName(): string;
  96743. /**
  96744. * Adding a new impostor for the impostor tracking.
  96745. * This will be done by the impostor itself.
  96746. * @param impostor the impostor to add
  96747. */
  96748. addImpostor(impostor: PhysicsImpostor): void;
  96749. /**
  96750. * Remove an impostor from the engine.
  96751. * This impostor and its mesh will not longer be updated by the physics engine.
  96752. * @param impostor the impostor to remove
  96753. */
  96754. removeImpostor(impostor: PhysicsImpostor): void;
  96755. /**
  96756. * Add a joint to the physics engine
  96757. * @param mainImpostor defines the main impostor to which the joint is added.
  96758. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96759. * @param joint defines the joint that will connect both impostors.
  96760. */
  96761. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96762. /**
  96763. * Removes a joint from the simulation
  96764. * @param mainImpostor defines the impostor used with the joint
  96765. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96766. * @param joint defines the joint to remove
  96767. */
  96768. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96769. /**
  96770. * Gets the current plugin used to run the simulation
  96771. * @returns current plugin
  96772. */
  96773. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96774. /**
  96775. * Gets the list of physic impostors
  96776. * @returns an array of PhysicsImpostor
  96777. */
  96778. getImpostors(): Array<PhysicsImpostor>;
  96779. /**
  96780. * Gets the impostor for a physics enabled object
  96781. * @param object defines the object impersonated by the impostor
  96782. * @returns the PhysicsImpostor or null if not found
  96783. */
  96784. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96785. /**
  96786. * Gets the impostor for a physics body object
  96787. * @param body defines physics body used by the impostor
  96788. * @returns the PhysicsImpostor or null if not found
  96789. */
  96790. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96791. /**
  96792. * Does a raycast in the physics world
  96793. * @param from when should the ray start?
  96794. * @param to when should the ray end?
  96795. * @returns PhysicsRaycastResult
  96796. */
  96797. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96798. /**
  96799. * Called by the scene. No need to call it.
  96800. * @param delta defines the timespam between frames
  96801. */
  96802. _step(delta: number): void;
  96803. }
  96804. }
  96805. declare module BABYLON {
  96806. /**
  96807. * The interface for the physics imposter parameters
  96808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96809. */
  96810. export interface PhysicsImpostorParameters {
  96811. /**
  96812. * The mass of the physics imposter
  96813. */
  96814. mass: number;
  96815. /**
  96816. * The friction of the physics imposter
  96817. */
  96818. friction?: number;
  96819. /**
  96820. * The coefficient of restitution of the physics imposter
  96821. */
  96822. restitution?: number;
  96823. /**
  96824. * The native options of the physics imposter
  96825. */
  96826. nativeOptions?: any;
  96827. /**
  96828. * Specifies if the parent should be ignored
  96829. */
  96830. ignoreParent?: boolean;
  96831. /**
  96832. * Specifies if bi-directional transformations should be disabled
  96833. */
  96834. disableBidirectionalTransformation?: boolean;
  96835. /**
  96836. * The pressure inside the physics imposter, soft object only
  96837. */
  96838. pressure?: number;
  96839. /**
  96840. * The stiffness the physics imposter, soft object only
  96841. */
  96842. stiffness?: number;
  96843. /**
  96844. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96845. */
  96846. velocityIterations?: number;
  96847. /**
  96848. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96849. */
  96850. positionIterations?: number;
  96851. /**
  96852. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96853. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96854. * Add to fix multiple points
  96855. */
  96856. fixedPoints?: number;
  96857. /**
  96858. * The collision margin around a soft object
  96859. */
  96860. margin?: number;
  96861. /**
  96862. * The collision margin around a soft object
  96863. */
  96864. damping?: number;
  96865. /**
  96866. * The path for a rope based on an extrusion
  96867. */
  96868. path?: any;
  96869. /**
  96870. * The shape of an extrusion used for a rope based on an extrusion
  96871. */
  96872. shape?: any;
  96873. }
  96874. /**
  96875. * Interface for a physics-enabled object
  96876. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96877. */
  96878. export interface IPhysicsEnabledObject {
  96879. /**
  96880. * The position of the physics-enabled object
  96881. */
  96882. position: Vector3;
  96883. /**
  96884. * The rotation of the physics-enabled object
  96885. */
  96886. rotationQuaternion: Nullable<Quaternion>;
  96887. /**
  96888. * The scale of the physics-enabled object
  96889. */
  96890. scaling: Vector3;
  96891. /**
  96892. * The rotation of the physics-enabled object
  96893. */
  96894. rotation?: Vector3;
  96895. /**
  96896. * The parent of the physics-enabled object
  96897. */
  96898. parent?: any;
  96899. /**
  96900. * The bounding info of the physics-enabled object
  96901. * @returns The bounding info of the physics-enabled object
  96902. */
  96903. getBoundingInfo(): BoundingInfo;
  96904. /**
  96905. * Computes the world matrix
  96906. * @param force Specifies if the world matrix should be computed by force
  96907. * @returns A world matrix
  96908. */
  96909. computeWorldMatrix(force: boolean): Matrix;
  96910. /**
  96911. * Gets the world matrix
  96912. * @returns A world matrix
  96913. */
  96914. getWorldMatrix?(): Matrix;
  96915. /**
  96916. * Gets the child meshes
  96917. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96918. * @returns An array of abstract meshes
  96919. */
  96920. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96921. /**
  96922. * Gets the vertex data
  96923. * @param kind The type of vertex data
  96924. * @returns A nullable array of numbers, or a float32 array
  96925. */
  96926. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96927. /**
  96928. * Gets the indices from the mesh
  96929. * @returns A nullable array of index arrays
  96930. */
  96931. getIndices?(): Nullable<IndicesArray>;
  96932. /**
  96933. * Gets the scene from the mesh
  96934. * @returns the indices array or null
  96935. */
  96936. getScene?(): Scene;
  96937. /**
  96938. * Gets the absolute position from the mesh
  96939. * @returns the absolute position
  96940. */
  96941. getAbsolutePosition(): Vector3;
  96942. /**
  96943. * Gets the absolute pivot point from the mesh
  96944. * @returns the absolute pivot point
  96945. */
  96946. getAbsolutePivotPoint(): Vector3;
  96947. /**
  96948. * Rotates the mesh
  96949. * @param axis The axis of rotation
  96950. * @param amount The amount of rotation
  96951. * @param space The space of the rotation
  96952. * @returns The rotation transform node
  96953. */
  96954. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96955. /**
  96956. * Translates the mesh
  96957. * @param axis The axis of translation
  96958. * @param distance The distance of translation
  96959. * @param space The space of the translation
  96960. * @returns The transform node
  96961. */
  96962. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96963. /**
  96964. * Sets the absolute position of the mesh
  96965. * @param absolutePosition The absolute position of the mesh
  96966. * @returns The transform node
  96967. */
  96968. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96969. /**
  96970. * Gets the class name of the mesh
  96971. * @returns The class name
  96972. */
  96973. getClassName(): string;
  96974. }
  96975. /**
  96976. * Represents a physics imposter
  96977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96978. */
  96979. export class PhysicsImpostor {
  96980. /**
  96981. * The physics-enabled object used as the physics imposter
  96982. */
  96983. object: IPhysicsEnabledObject;
  96984. /**
  96985. * The type of the physics imposter
  96986. */
  96987. type: number;
  96988. private _options;
  96989. private _scene?;
  96990. /**
  96991. * The default object size of the imposter
  96992. */
  96993. static DEFAULT_OBJECT_SIZE: Vector3;
  96994. /**
  96995. * The identity quaternion of the imposter
  96996. */
  96997. static IDENTITY_QUATERNION: Quaternion;
  96998. /** @hidden */
  96999. _pluginData: any;
  97000. private _physicsEngine;
  97001. private _physicsBody;
  97002. private _bodyUpdateRequired;
  97003. private _onBeforePhysicsStepCallbacks;
  97004. private _onAfterPhysicsStepCallbacks;
  97005. /** @hidden */
  97006. _onPhysicsCollideCallbacks: Array<{
  97007. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97008. otherImpostors: Array<PhysicsImpostor>;
  97009. }>;
  97010. private _deltaPosition;
  97011. private _deltaRotation;
  97012. private _deltaRotationConjugated;
  97013. /** @hidden */
  97014. _isFromLine: boolean;
  97015. private _parent;
  97016. private _isDisposed;
  97017. private static _tmpVecs;
  97018. private static _tmpQuat;
  97019. /**
  97020. * Specifies if the physics imposter is disposed
  97021. */
  97022. get isDisposed(): boolean;
  97023. /**
  97024. * Gets the mass of the physics imposter
  97025. */
  97026. get mass(): number;
  97027. set mass(value: number);
  97028. /**
  97029. * Gets the coefficient of friction
  97030. */
  97031. get friction(): number;
  97032. /**
  97033. * Sets the coefficient of friction
  97034. */
  97035. set friction(value: number);
  97036. /**
  97037. * Gets the coefficient of restitution
  97038. */
  97039. get restitution(): number;
  97040. /**
  97041. * Sets the coefficient of restitution
  97042. */
  97043. set restitution(value: number);
  97044. /**
  97045. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97046. */
  97047. get pressure(): number;
  97048. /**
  97049. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97050. */
  97051. set pressure(value: number);
  97052. /**
  97053. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97054. */
  97055. get stiffness(): number;
  97056. /**
  97057. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97058. */
  97059. set stiffness(value: number);
  97060. /**
  97061. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97062. */
  97063. get velocityIterations(): number;
  97064. /**
  97065. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97066. */
  97067. set velocityIterations(value: number);
  97068. /**
  97069. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97070. */
  97071. get positionIterations(): number;
  97072. /**
  97073. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97074. */
  97075. set positionIterations(value: number);
  97076. /**
  97077. * The unique id of the physics imposter
  97078. * set by the physics engine when adding this impostor to the array
  97079. */
  97080. uniqueId: number;
  97081. /**
  97082. * @hidden
  97083. */
  97084. soft: boolean;
  97085. /**
  97086. * @hidden
  97087. */
  97088. segments: number;
  97089. private _joints;
  97090. /**
  97091. * Initializes the physics imposter
  97092. * @param object The physics-enabled object used as the physics imposter
  97093. * @param type The type of the physics imposter
  97094. * @param _options The options for the physics imposter
  97095. * @param _scene The Babylon scene
  97096. */
  97097. constructor(
  97098. /**
  97099. * The physics-enabled object used as the physics imposter
  97100. */
  97101. object: IPhysicsEnabledObject,
  97102. /**
  97103. * The type of the physics imposter
  97104. */
  97105. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97106. /**
  97107. * This function will completly initialize this impostor.
  97108. * It will create a new body - but only if this mesh has no parent.
  97109. * If it has, this impostor will not be used other than to define the impostor
  97110. * of the child mesh.
  97111. * @hidden
  97112. */
  97113. _init(): void;
  97114. private _getPhysicsParent;
  97115. /**
  97116. * Should a new body be generated.
  97117. * @returns boolean specifying if body initialization is required
  97118. */
  97119. isBodyInitRequired(): boolean;
  97120. /**
  97121. * Sets the updated scaling
  97122. * @param updated Specifies if the scaling is updated
  97123. */
  97124. setScalingUpdated(): void;
  97125. /**
  97126. * Force a regeneration of this or the parent's impostor's body.
  97127. * Use under cautious - This will remove all joints already implemented.
  97128. */
  97129. forceUpdate(): void;
  97130. /**
  97131. * Gets the body that holds this impostor. Either its own, or its parent.
  97132. */
  97133. get physicsBody(): any;
  97134. /**
  97135. * Get the parent of the physics imposter
  97136. * @returns Physics imposter or null
  97137. */
  97138. get parent(): Nullable<PhysicsImpostor>;
  97139. /**
  97140. * Sets the parent of the physics imposter
  97141. */
  97142. set parent(value: Nullable<PhysicsImpostor>);
  97143. /**
  97144. * Set the physics body. Used mainly by the physics engine/plugin
  97145. */
  97146. set physicsBody(physicsBody: any);
  97147. /**
  97148. * Resets the update flags
  97149. */
  97150. resetUpdateFlags(): void;
  97151. /**
  97152. * Gets the object extend size
  97153. * @returns the object extend size
  97154. */
  97155. getObjectExtendSize(): Vector3;
  97156. /**
  97157. * Gets the object center
  97158. * @returns The object center
  97159. */
  97160. getObjectCenter(): Vector3;
  97161. /**
  97162. * Get a specific parameter from the options parameters
  97163. * @param paramName The object parameter name
  97164. * @returns The object parameter
  97165. */
  97166. getParam(paramName: string): any;
  97167. /**
  97168. * Sets a specific parameter in the options given to the physics plugin
  97169. * @param paramName The parameter name
  97170. * @param value The value of the parameter
  97171. */
  97172. setParam(paramName: string, value: number): void;
  97173. /**
  97174. * Specifically change the body's mass option. Won't recreate the physics body object
  97175. * @param mass The mass of the physics imposter
  97176. */
  97177. setMass(mass: number): void;
  97178. /**
  97179. * Gets the linear velocity
  97180. * @returns linear velocity or null
  97181. */
  97182. getLinearVelocity(): Nullable<Vector3>;
  97183. /**
  97184. * Sets the linear velocity
  97185. * @param velocity linear velocity or null
  97186. */
  97187. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97188. /**
  97189. * Gets the angular velocity
  97190. * @returns angular velocity or null
  97191. */
  97192. getAngularVelocity(): Nullable<Vector3>;
  97193. /**
  97194. * Sets the angular velocity
  97195. * @param velocity The velocity or null
  97196. */
  97197. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97198. /**
  97199. * Execute a function with the physics plugin native code
  97200. * Provide a function the will have two variables - the world object and the physics body object
  97201. * @param func The function to execute with the physics plugin native code
  97202. */
  97203. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97204. /**
  97205. * Register a function that will be executed before the physics world is stepping forward
  97206. * @param func The function to execute before the physics world is stepped forward
  97207. */
  97208. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97209. /**
  97210. * Unregister a function that will be executed before the physics world is stepping forward
  97211. * @param func The function to execute before the physics world is stepped forward
  97212. */
  97213. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97214. /**
  97215. * Register a function that will be executed after the physics step
  97216. * @param func The function to execute after physics step
  97217. */
  97218. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97219. /**
  97220. * Unregisters a function that will be executed after the physics step
  97221. * @param func The function to execute after physics step
  97222. */
  97223. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97224. /**
  97225. * register a function that will be executed when this impostor collides against a different body
  97226. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97227. * @param func Callback that is executed on collision
  97228. */
  97229. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97230. /**
  97231. * Unregisters the physics imposter on contact
  97232. * @param collideAgainst The physics object to collide against
  97233. * @param func Callback to execute on collision
  97234. */
  97235. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97236. private _tmpQuat;
  97237. private _tmpQuat2;
  97238. /**
  97239. * Get the parent rotation
  97240. * @returns The parent rotation
  97241. */
  97242. getParentsRotation(): Quaternion;
  97243. /**
  97244. * this function is executed by the physics engine.
  97245. */
  97246. beforeStep: () => void;
  97247. /**
  97248. * this function is executed by the physics engine
  97249. */
  97250. afterStep: () => void;
  97251. /**
  97252. * Legacy collision detection event support
  97253. */
  97254. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97255. /**
  97256. * event and body object due to cannon's event-based architecture.
  97257. */
  97258. onCollide: (e: {
  97259. body: any;
  97260. }) => void;
  97261. /**
  97262. * Apply a force
  97263. * @param force The force to apply
  97264. * @param contactPoint The contact point for the force
  97265. * @returns The physics imposter
  97266. */
  97267. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97268. /**
  97269. * Apply an impulse
  97270. * @param force The impulse force
  97271. * @param contactPoint The contact point for the impulse force
  97272. * @returns The physics imposter
  97273. */
  97274. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97275. /**
  97276. * A help function to create a joint
  97277. * @param otherImpostor A physics imposter used to create a joint
  97278. * @param jointType The type of joint
  97279. * @param jointData The data for the joint
  97280. * @returns The physics imposter
  97281. */
  97282. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97283. /**
  97284. * Add a joint to this impostor with a different impostor
  97285. * @param otherImpostor A physics imposter used to add a joint
  97286. * @param joint The joint to add
  97287. * @returns The physics imposter
  97288. */
  97289. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97290. /**
  97291. * Add an anchor to a cloth impostor
  97292. * @param otherImpostor rigid impostor to anchor to
  97293. * @param width ratio across width from 0 to 1
  97294. * @param height ratio up height from 0 to 1
  97295. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97296. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97297. * @returns impostor the soft imposter
  97298. */
  97299. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97300. /**
  97301. * Add a hook to a rope impostor
  97302. * @param otherImpostor rigid impostor to anchor to
  97303. * @param length ratio across rope from 0 to 1
  97304. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97305. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97306. * @returns impostor the rope imposter
  97307. */
  97308. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97309. /**
  97310. * Will keep this body still, in a sleep mode.
  97311. * @returns the physics imposter
  97312. */
  97313. sleep(): PhysicsImpostor;
  97314. /**
  97315. * Wake the body up.
  97316. * @returns The physics imposter
  97317. */
  97318. wakeUp(): PhysicsImpostor;
  97319. /**
  97320. * Clones the physics imposter
  97321. * @param newObject The physics imposter clones to this physics-enabled object
  97322. * @returns A nullable physics imposter
  97323. */
  97324. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97325. /**
  97326. * Disposes the physics imposter
  97327. */
  97328. dispose(): void;
  97329. /**
  97330. * Sets the delta position
  97331. * @param position The delta position amount
  97332. */
  97333. setDeltaPosition(position: Vector3): void;
  97334. /**
  97335. * Sets the delta rotation
  97336. * @param rotation The delta rotation amount
  97337. */
  97338. setDeltaRotation(rotation: Quaternion): void;
  97339. /**
  97340. * Gets the box size of the physics imposter and stores the result in the input parameter
  97341. * @param result Stores the box size
  97342. * @returns The physics imposter
  97343. */
  97344. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97345. /**
  97346. * Gets the radius of the physics imposter
  97347. * @returns Radius of the physics imposter
  97348. */
  97349. getRadius(): number;
  97350. /**
  97351. * Sync a bone with this impostor
  97352. * @param bone The bone to sync to the impostor.
  97353. * @param boneMesh The mesh that the bone is influencing.
  97354. * @param jointPivot The pivot of the joint / bone in local space.
  97355. * @param distToJoint Optional distance from the impostor to the joint.
  97356. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97357. */
  97358. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97359. /**
  97360. * Sync impostor to a bone
  97361. * @param bone The bone that the impostor will be synced to.
  97362. * @param boneMesh The mesh that the bone is influencing.
  97363. * @param jointPivot The pivot of the joint / bone in local space.
  97364. * @param distToJoint Optional distance from the impostor to the joint.
  97365. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97366. * @param boneAxis Optional vector3 axis the bone is aligned with
  97367. */
  97368. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97369. /**
  97370. * No-Imposter type
  97371. */
  97372. static NoImpostor: number;
  97373. /**
  97374. * Sphere-Imposter type
  97375. */
  97376. static SphereImpostor: number;
  97377. /**
  97378. * Box-Imposter type
  97379. */
  97380. static BoxImpostor: number;
  97381. /**
  97382. * Plane-Imposter type
  97383. */
  97384. static PlaneImpostor: number;
  97385. /**
  97386. * Mesh-imposter type
  97387. */
  97388. static MeshImpostor: number;
  97389. /**
  97390. * Capsule-Impostor type (Ammo.js plugin only)
  97391. */
  97392. static CapsuleImpostor: number;
  97393. /**
  97394. * Cylinder-Imposter type
  97395. */
  97396. static CylinderImpostor: number;
  97397. /**
  97398. * Particle-Imposter type
  97399. */
  97400. static ParticleImpostor: number;
  97401. /**
  97402. * Heightmap-Imposter type
  97403. */
  97404. static HeightmapImpostor: number;
  97405. /**
  97406. * ConvexHull-Impostor type (Ammo.js plugin only)
  97407. */
  97408. static ConvexHullImpostor: number;
  97409. /**
  97410. * Custom-Imposter type (Ammo.js plugin only)
  97411. */
  97412. static CustomImpostor: number;
  97413. /**
  97414. * Rope-Imposter type
  97415. */
  97416. static RopeImpostor: number;
  97417. /**
  97418. * Cloth-Imposter type
  97419. */
  97420. static ClothImpostor: number;
  97421. /**
  97422. * Softbody-Imposter type
  97423. */
  97424. static SoftbodyImpostor: number;
  97425. }
  97426. }
  97427. declare module BABYLON {
  97428. /**
  97429. * @hidden
  97430. **/
  97431. export class _CreationDataStorage {
  97432. closePath?: boolean;
  97433. closeArray?: boolean;
  97434. idx: number[];
  97435. dashSize: number;
  97436. gapSize: number;
  97437. path3D: Path3D;
  97438. pathArray: Vector3[][];
  97439. arc: number;
  97440. radius: number;
  97441. cap: number;
  97442. tessellation: number;
  97443. }
  97444. /**
  97445. * @hidden
  97446. **/
  97447. class _InstanceDataStorage {
  97448. visibleInstances: any;
  97449. batchCache: _InstancesBatch;
  97450. instancesBufferSize: number;
  97451. instancesBuffer: Nullable<Buffer>;
  97452. instancesData: Float32Array;
  97453. overridenInstanceCount: number;
  97454. isFrozen: boolean;
  97455. previousBatch: Nullable<_InstancesBatch>;
  97456. hardwareInstancedRendering: boolean;
  97457. sideOrientation: number;
  97458. manualUpdate: boolean;
  97459. }
  97460. /**
  97461. * @hidden
  97462. **/
  97463. export class _InstancesBatch {
  97464. mustReturn: boolean;
  97465. visibleInstances: Nullable<InstancedMesh[]>[];
  97466. renderSelf: boolean[];
  97467. hardwareInstancedRendering: boolean[];
  97468. }
  97469. /**
  97470. * Class used to represent renderable models
  97471. */
  97472. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97473. /**
  97474. * Mesh side orientation : usually the external or front surface
  97475. */
  97476. static readonly FRONTSIDE: number;
  97477. /**
  97478. * Mesh side orientation : usually the internal or back surface
  97479. */
  97480. static readonly BACKSIDE: number;
  97481. /**
  97482. * Mesh side orientation : both internal and external or front and back surfaces
  97483. */
  97484. static readonly DOUBLESIDE: number;
  97485. /**
  97486. * Mesh side orientation : by default, `FRONTSIDE`
  97487. */
  97488. static readonly DEFAULTSIDE: number;
  97489. /**
  97490. * Mesh cap setting : no cap
  97491. */
  97492. static readonly NO_CAP: number;
  97493. /**
  97494. * Mesh cap setting : one cap at the beginning of the mesh
  97495. */
  97496. static readonly CAP_START: number;
  97497. /**
  97498. * Mesh cap setting : one cap at the end of the mesh
  97499. */
  97500. static readonly CAP_END: number;
  97501. /**
  97502. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97503. */
  97504. static readonly CAP_ALL: number;
  97505. /**
  97506. * Mesh pattern setting : no flip or rotate
  97507. */
  97508. static readonly NO_FLIP: number;
  97509. /**
  97510. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97511. */
  97512. static readonly FLIP_TILE: number;
  97513. /**
  97514. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97515. */
  97516. static readonly ROTATE_TILE: number;
  97517. /**
  97518. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97519. */
  97520. static readonly FLIP_ROW: number;
  97521. /**
  97522. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97523. */
  97524. static readonly ROTATE_ROW: number;
  97525. /**
  97526. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97527. */
  97528. static readonly FLIP_N_ROTATE_TILE: number;
  97529. /**
  97530. * Mesh pattern setting : rotate pattern and rotate
  97531. */
  97532. static readonly FLIP_N_ROTATE_ROW: number;
  97533. /**
  97534. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97535. */
  97536. static readonly CENTER: number;
  97537. /**
  97538. * Mesh tile positioning : part tiles on left
  97539. */
  97540. static readonly LEFT: number;
  97541. /**
  97542. * Mesh tile positioning : part tiles on right
  97543. */
  97544. static readonly RIGHT: number;
  97545. /**
  97546. * Mesh tile positioning : part tiles on top
  97547. */
  97548. static readonly TOP: number;
  97549. /**
  97550. * Mesh tile positioning : part tiles on bottom
  97551. */
  97552. static readonly BOTTOM: number;
  97553. /**
  97554. * Gets the default side orientation.
  97555. * @param orientation the orientation to value to attempt to get
  97556. * @returns the default orientation
  97557. * @hidden
  97558. */
  97559. static _GetDefaultSideOrientation(orientation?: number): number;
  97560. private _internalMeshDataInfo;
  97561. /**
  97562. * An event triggered before rendering the mesh
  97563. */
  97564. get onBeforeRenderObservable(): Observable<Mesh>;
  97565. /**
  97566. * An event triggered before binding the mesh
  97567. */
  97568. get onBeforeBindObservable(): Observable<Mesh>;
  97569. /**
  97570. * An event triggered after rendering the mesh
  97571. */
  97572. get onAfterRenderObservable(): Observable<Mesh>;
  97573. /**
  97574. * An event triggered before drawing the mesh
  97575. */
  97576. get onBeforeDrawObservable(): Observable<Mesh>;
  97577. private _onBeforeDrawObserver;
  97578. /**
  97579. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97580. */
  97581. set onBeforeDraw(callback: () => void);
  97582. get hasInstances(): boolean;
  97583. /**
  97584. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97585. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97586. */
  97587. delayLoadState: number;
  97588. /**
  97589. * Gets the list of instances created from this mesh
  97590. * it is not supposed to be modified manually.
  97591. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97592. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97593. */
  97594. instances: InstancedMesh[];
  97595. /**
  97596. * Gets the file containing delay loading data for this mesh
  97597. */
  97598. delayLoadingFile: string;
  97599. /** @hidden */
  97600. _binaryInfo: any;
  97601. /**
  97602. * User defined function used to change how LOD level selection is done
  97603. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97604. */
  97605. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97606. /**
  97607. * Gets or sets the morph target manager
  97608. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97609. */
  97610. get morphTargetManager(): Nullable<MorphTargetManager>;
  97611. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97612. /** @hidden */
  97613. _creationDataStorage: Nullable<_CreationDataStorage>;
  97614. /** @hidden */
  97615. _geometry: Nullable<Geometry>;
  97616. /** @hidden */
  97617. _delayInfo: Array<string>;
  97618. /** @hidden */
  97619. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97620. /** @hidden */
  97621. _instanceDataStorage: _InstanceDataStorage;
  97622. private _effectiveMaterial;
  97623. /** @hidden */
  97624. _shouldGenerateFlatShading: boolean;
  97625. /** @hidden */
  97626. _originalBuilderSideOrientation: number;
  97627. /**
  97628. * Use this property to change the original side orientation defined at construction time
  97629. */
  97630. overrideMaterialSideOrientation: Nullable<number>;
  97631. /**
  97632. * Gets the source mesh (the one used to clone this one from)
  97633. */
  97634. get source(): Nullable<Mesh>;
  97635. /**
  97636. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97637. */
  97638. get isUnIndexed(): boolean;
  97639. set isUnIndexed(value: boolean);
  97640. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97641. get worldMatrixInstancedBuffer(): Float32Array;
  97642. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97643. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97644. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97645. /**
  97646. * @constructor
  97647. * @param name The value used by scene.getMeshByName() to do a lookup.
  97648. * @param scene The scene to add this mesh to.
  97649. * @param parent The parent of this mesh, if it has one
  97650. * @param source An optional Mesh from which geometry is shared, cloned.
  97651. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97652. * When false, achieved by calling a clone(), also passing False.
  97653. * This will make creation of children, recursive.
  97654. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97655. */
  97656. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97657. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97658. doNotInstantiate: boolean;
  97659. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97660. /**
  97661. * Gets the class name
  97662. * @returns the string "Mesh".
  97663. */
  97664. getClassName(): string;
  97665. /** @hidden */
  97666. get _isMesh(): boolean;
  97667. /**
  97668. * Returns a description of this mesh
  97669. * @param fullDetails define if full details about this mesh must be used
  97670. * @returns a descriptive string representing this mesh
  97671. */
  97672. toString(fullDetails?: boolean): string;
  97673. /** @hidden */
  97674. _unBindEffect(): void;
  97675. /**
  97676. * Gets a boolean indicating if this mesh has LOD
  97677. */
  97678. get hasLODLevels(): boolean;
  97679. /**
  97680. * Gets the list of MeshLODLevel associated with the current mesh
  97681. * @returns an array of MeshLODLevel
  97682. */
  97683. getLODLevels(): MeshLODLevel[];
  97684. private _sortLODLevels;
  97685. /**
  97686. * Add a mesh as LOD level triggered at the given distance.
  97687. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97688. * @param distance The distance from the center of the object to show this level
  97689. * @param mesh The mesh to be added as LOD level (can be null)
  97690. * @return This mesh (for chaining)
  97691. */
  97692. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97693. /**
  97694. * Returns the LOD level mesh at the passed distance or null if not found.
  97695. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97696. * @param distance The distance from the center of the object to show this level
  97697. * @returns a Mesh or `null`
  97698. */
  97699. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97700. /**
  97701. * Remove a mesh from the LOD array
  97702. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97703. * @param mesh defines the mesh to be removed
  97704. * @return This mesh (for chaining)
  97705. */
  97706. removeLODLevel(mesh: Mesh): Mesh;
  97707. /**
  97708. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97709. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97710. * @param camera defines the camera to use to compute distance
  97711. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97712. * @return This mesh (for chaining)
  97713. */
  97714. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97715. /**
  97716. * Gets the mesh internal Geometry object
  97717. */
  97718. get geometry(): Nullable<Geometry>;
  97719. /**
  97720. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97721. * @returns the total number of vertices
  97722. */
  97723. getTotalVertices(): number;
  97724. /**
  97725. * Returns the content of an associated vertex buffer
  97726. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97727. * - VertexBuffer.PositionKind
  97728. * - VertexBuffer.UVKind
  97729. * - VertexBuffer.UV2Kind
  97730. * - VertexBuffer.UV3Kind
  97731. * - VertexBuffer.UV4Kind
  97732. * - VertexBuffer.UV5Kind
  97733. * - VertexBuffer.UV6Kind
  97734. * - VertexBuffer.ColorKind
  97735. * - VertexBuffer.MatricesIndicesKind
  97736. * - VertexBuffer.MatricesIndicesExtraKind
  97737. * - VertexBuffer.MatricesWeightsKind
  97738. * - VertexBuffer.MatricesWeightsExtraKind
  97739. * @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
  97740. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97741. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97742. */
  97743. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97744. /**
  97745. * Returns the mesh VertexBuffer object from the requested `kind`
  97746. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97747. * - VertexBuffer.PositionKind
  97748. * - VertexBuffer.NormalKind
  97749. * - VertexBuffer.UVKind
  97750. * - VertexBuffer.UV2Kind
  97751. * - VertexBuffer.UV3Kind
  97752. * - VertexBuffer.UV4Kind
  97753. * - VertexBuffer.UV5Kind
  97754. * - VertexBuffer.UV6Kind
  97755. * - VertexBuffer.ColorKind
  97756. * - VertexBuffer.MatricesIndicesKind
  97757. * - VertexBuffer.MatricesIndicesExtraKind
  97758. * - VertexBuffer.MatricesWeightsKind
  97759. * - VertexBuffer.MatricesWeightsExtraKind
  97760. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97761. */
  97762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97763. /**
  97764. * Tests if a specific vertex buffer is associated with this mesh
  97765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97766. * - VertexBuffer.PositionKind
  97767. * - VertexBuffer.NormalKind
  97768. * - VertexBuffer.UVKind
  97769. * - VertexBuffer.UV2Kind
  97770. * - VertexBuffer.UV3Kind
  97771. * - VertexBuffer.UV4Kind
  97772. * - VertexBuffer.UV5Kind
  97773. * - VertexBuffer.UV6Kind
  97774. * - VertexBuffer.ColorKind
  97775. * - VertexBuffer.MatricesIndicesKind
  97776. * - VertexBuffer.MatricesIndicesExtraKind
  97777. * - VertexBuffer.MatricesWeightsKind
  97778. * - VertexBuffer.MatricesWeightsExtraKind
  97779. * @returns a boolean
  97780. */
  97781. isVerticesDataPresent(kind: string): boolean;
  97782. /**
  97783. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97784. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97785. * - VertexBuffer.PositionKind
  97786. * - VertexBuffer.UVKind
  97787. * - VertexBuffer.UV2Kind
  97788. * - VertexBuffer.UV3Kind
  97789. * - VertexBuffer.UV4Kind
  97790. * - VertexBuffer.UV5Kind
  97791. * - VertexBuffer.UV6Kind
  97792. * - VertexBuffer.ColorKind
  97793. * - VertexBuffer.MatricesIndicesKind
  97794. * - VertexBuffer.MatricesIndicesExtraKind
  97795. * - VertexBuffer.MatricesWeightsKind
  97796. * - VertexBuffer.MatricesWeightsExtraKind
  97797. * @returns a boolean
  97798. */
  97799. isVertexBufferUpdatable(kind: string): boolean;
  97800. /**
  97801. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97802. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97803. * - VertexBuffer.PositionKind
  97804. * - VertexBuffer.NormalKind
  97805. * - VertexBuffer.UVKind
  97806. * - VertexBuffer.UV2Kind
  97807. * - VertexBuffer.UV3Kind
  97808. * - VertexBuffer.UV4Kind
  97809. * - VertexBuffer.UV5Kind
  97810. * - VertexBuffer.UV6Kind
  97811. * - VertexBuffer.ColorKind
  97812. * - VertexBuffer.MatricesIndicesKind
  97813. * - VertexBuffer.MatricesIndicesExtraKind
  97814. * - VertexBuffer.MatricesWeightsKind
  97815. * - VertexBuffer.MatricesWeightsExtraKind
  97816. * @returns an array of strings
  97817. */
  97818. getVerticesDataKinds(): string[];
  97819. /**
  97820. * Returns a positive integer : the total number of indices in this mesh geometry.
  97821. * @returns the numner of indices or zero if the mesh has no geometry.
  97822. */
  97823. getTotalIndices(): number;
  97824. /**
  97825. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97826. * @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.
  97827. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97828. * @returns the indices array or an empty array if the mesh has no geometry
  97829. */
  97830. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97831. get isBlocked(): boolean;
  97832. /**
  97833. * Determine if the current mesh is ready to be rendered
  97834. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97835. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97836. * @returns true if all associated assets are ready (material, textures, shaders)
  97837. */
  97838. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97839. /**
  97840. * 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.
  97841. */
  97842. get areNormalsFrozen(): boolean;
  97843. /**
  97844. * 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.
  97845. * @returns the current mesh
  97846. */
  97847. freezeNormals(): Mesh;
  97848. /**
  97849. * 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
  97850. * @returns the current mesh
  97851. */
  97852. unfreezeNormals(): Mesh;
  97853. /**
  97854. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97855. */
  97856. set overridenInstanceCount(count: number);
  97857. /** @hidden */
  97858. _preActivate(): Mesh;
  97859. /** @hidden */
  97860. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97861. /** @hidden */
  97862. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97863. /**
  97864. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97865. * This means the mesh underlying bounding box and sphere are recomputed.
  97866. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97867. * @returns the current mesh
  97868. */
  97869. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97870. /** @hidden */
  97871. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97872. /**
  97873. * This function will subdivide the mesh into multiple submeshes
  97874. * @param count defines the expected number of submeshes
  97875. */
  97876. subdivide(count: number): void;
  97877. /**
  97878. * Copy a FloatArray into a specific associated vertex buffer
  97879. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97880. * - VertexBuffer.PositionKind
  97881. * - VertexBuffer.UVKind
  97882. * - VertexBuffer.UV2Kind
  97883. * - VertexBuffer.UV3Kind
  97884. * - VertexBuffer.UV4Kind
  97885. * - VertexBuffer.UV5Kind
  97886. * - VertexBuffer.UV6Kind
  97887. * - VertexBuffer.ColorKind
  97888. * - VertexBuffer.MatricesIndicesKind
  97889. * - VertexBuffer.MatricesIndicesExtraKind
  97890. * - VertexBuffer.MatricesWeightsKind
  97891. * - VertexBuffer.MatricesWeightsExtraKind
  97892. * @param data defines the data source
  97893. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97894. * @param stride defines the data stride size (can be null)
  97895. * @returns the current mesh
  97896. */
  97897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97898. /**
  97899. * Delete a vertex buffer associated with this mesh
  97900. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97901. * - VertexBuffer.PositionKind
  97902. * - VertexBuffer.UVKind
  97903. * - VertexBuffer.UV2Kind
  97904. * - VertexBuffer.UV3Kind
  97905. * - VertexBuffer.UV4Kind
  97906. * - VertexBuffer.UV5Kind
  97907. * - VertexBuffer.UV6Kind
  97908. * - VertexBuffer.ColorKind
  97909. * - VertexBuffer.MatricesIndicesKind
  97910. * - VertexBuffer.MatricesIndicesExtraKind
  97911. * - VertexBuffer.MatricesWeightsKind
  97912. * - VertexBuffer.MatricesWeightsExtraKind
  97913. */
  97914. removeVerticesData(kind: string): void;
  97915. /**
  97916. * Flags an associated vertex buffer as updatable
  97917. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97918. * - VertexBuffer.PositionKind
  97919. * - VertexBuffer.UVKind
  97920. * - VertexBuffer.UV2Kind
  97921. * - VertexBuffer.UV3Kind
  97922. * - VertexBuffer.UV4Kind
  97923. * - VertexBuffer.UV5Kind
  97924. * - VertexBuffer.UV6Kind
  97925. * - VertexBuffer.ColorKind
  97926. * - VertexBuffer.MatricesIndicesKind
  97927. * - VertexBuffer.MatricesIndicesExtraKind
  97928. * - VertexBuffer.MatricesWeightsKind
  97929. * - VertexBuffer.MatricesWeightsExtraKind
  97930. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97931. */
  97932. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97933. /**
  97934. * Sets the mesh global Vertex Buffer
  97935. * @param buffer defines the buffer to use
  97936. * @returns the current mesh
  97937. */
  97938. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97939. /**
  97940. * Update a specific associated vertex buffer
  97941. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97942. * - VertexBuffer.PositionKind
  97943. * - VertexBuffer.UVKind
  97944. * - VertexBuffer.UV2Kind
  97945. * - VertexBuffer.UV3Kind
  97946. * - VertexBuffer.UV4Kind
  97947. * - VertexBuffer.UV5Kind
  97948. * - VertexBuffer.UV6Kind
  97949. * - VertexBuffer.ColorKind
  97950. * - VertexBuffer.MatricesIndicesKind
  97951. * - VertexBuffer.MatricesIndicesExtraKind
  97952. * - VertexBuffer.MatricesWeightsKind
  97953. * - VertexBuffer.MatricesWeightsExtraKind
  97954. * @param data defines the data source
  97955. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97956. * @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)
  97957. * @returns the current mesh
  97958. */
  97959. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97960. /**
  97961. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97962. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97963. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97964. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97965. * @returns the current mesh
  97966. */
  97967. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97968. /**
  97969. * Creates a un-shared specific occurence of the geometry for the mesh.
  97970. * @returns the current mesh
  97971. */
  97972. makeGeometryUnique(): Mesh;
  97973. /**
  97974. * Set the index buffer of this mesh
  97975. * @param indices defines the source data
  97976. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97977. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97978. * @returns the current mesh
  97979. */
  97980. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97981. /**
  97982. * Update the current index buffer
  97983. * @param indices defines the source data
  97984. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97985. * @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)
  97986. * @returns the current mesh
  97987. */
  97988. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97989. /**
  97990. * Invert the geometry to move from a right handed system to a left handed one.
  97991. * @returns the current mesh
  97992. */
  97993. toLeftHanded(): Mesh;
  97994. /** @hidden */
  97995. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97996. /** @hidden */
  97997. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97998. /**
  97999. * Registers for this mesh a javascript function called just before the rendering process
  98000. * @param func defines the function to call before rendering this mesh
  98001. * @returns the current mesh
  98002. */
  98003. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98004. /**
  98005. * Disposes a previously registered javascript function called before the rendering
  98006. * @param func defines the function to remove
  98007. * @returns the current mesh
  98008. */
  98009. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98010. /**
  98011. * Registers for this mesh a javascript function called just after the rendering is complete
  98012. * @param func defines the function to call after rendering this mesh
  98013. * @returns the current mesh
  98014. */
  98015. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98016. /**
  98017. * Disposes a previously registered javascript function called after the rendering.
  98018. * @param func defines the function to remove
  98019. * @returns the current mesh
  98020. */
  98021. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98022. /** @hidden */
  98023. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98024. /** @hidden */
  98025. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98026. /** @hidden */
  98027. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98028. /** @hidden */
  98029. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98030. /** @hidden */
  98031. _rebuild(): void;
  98032. /** @hidden */
  98033. _freeze(): void;
  98034. /** @hidden */
  98035. _unFreeze(): void;
  98036. /**
  98037. * 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
  98038. * @param subMesh defines the subMesh to render
  98039. * @param enableAlphaMode defines if alpha mode can be changed
  98040. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98041. * @returns the current mesh
  98042. */
  98043. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98044. private _onBeforeDraw;
  98045. /**
  98046. * Renormalize the mesh and patch it up if there are no weights
  98047. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98048. * However in the case of zero weights then we set just a single influence to 1.
  98049. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98050. */
  98051. cleanMatrixWeights(): void;
  98052. private normalizeSkinFourWeights;
  98053. private normalizeSkinWeightsAndExtra;
  98054. /**
  98055. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98056. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98057. * the user know there was an issue with importing the mesh
  98058. * @returns a validation object with skinned, valid and report string
  98059. */
  98060. validateSkinning(): {
  98061. skinned: boolean;
  98062. valid: boolean;
  98063. report: string;
  98064. };
  98065. /** @hidden */
  98066. _checkDelayState(): Mesh;
  98067. private _queueLoad;
  98068. /**
  98069. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98070. * A mesh is in the frustum if its bounding box intersects the frustum
  98071. * @param frustumPlanes defines the frustum to test
  98072. * @returns true if the mesh is in the frustum planes
  98073. */
  98074. isInFrustum(frustumPlanes: Plane[]): boolean;
  98075. /**
  98076. * Sets the mesh material by the material or multiMaterial `id` property
  98077. * @param id is a string identifying the material or the multiMaterial
  98078. * @returns the current mesh
  98079. */
  98080. setMaterialByID(id: string): Mesh;
  98081. /**
  98082. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98083. * @returns an array of IAnimatable
  98084. */
  98085. getAnimatables(): IAnimatable[];
  98086. /**
  98087. * Modifies the mesh geometry according to the passed transformation matrix.
  98088. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98089. * The mesh normals are modified using the same transformation.
  98090. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98091. * @param transform defines the transform matrix to use
  98092. * @see http://doc.babylonjs.com/resources/baking_transformations
  98093. * @returns the current mesh
  98094. */
  98095. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98096. /**
  98097. * Modifies the mesh geometry according to its own current World Matrix.
  98098. * The mesh World Matrix is then reset.
  98099. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98100. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98101. * @see http://doc.babylonjs.com/resources/baking_transformations
  98102. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98103. * @returns the current mesh
  98104. */
  98105. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98106. /** @hidden */
  98107. get _positions(): Nullable<Vector3[]>;
  98108. /** @hidden */
  98109. _resetPointsArrayCache(): Mesh;
  98110. /** @hidden */
  98111. _generatePointsArray(): boolean;
  98112. /**
  98113. * Returns a new Mesh object generated from the current mesh properties.
  98114. * This method must not get confused with createInstance()
  98115. * @param name is a string, the name given to the new mesh
  98116. * @param newParent can be any Node object (default `null`)
  98117. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98118. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98119. * @returns a new mesh
  98120. */
  98121. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98122. /**
  98123. * Releases resources associated with this mesh.
  98124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98126. */
  98127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98128. /** @hidden */
  98129. _disposeInstanceSpecificData(): void;
  98130. /**
  98131. * Modifies the mesh geometry according to a displacement map.
  98132. * 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.
  98133. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98134. * @param url is a string, the URL from the image file is to be downloaded.
  98135. * @param minHeight is the lower limit of the displacement.
  98136. * @param maxHeight is the upper limit of the displacement.
  98137. * @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.
  98138. * @param uvOffset is an optional vector2 used to offset UV.
  98139. * @param uvScale is an optional vector2 used to scale UV.
  98140. * @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.
  98141. * @returns the Mesh.
  98142. */
  98143. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98144. /**
  98145. * Modifies the mesh geometry according to a displacementMap buffer.
  98146. * 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.
  98147. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98148. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98149. * @param heightMapWidth is the width of the buffer image.
  98150. * @param heightMapHeight is the height of the buffer image.
  98151. * @param minHeight is the lower limit of the displacement.
  98152. * @param maxHeight is the upper limit of the displacement.
  98153. * @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.
  98154. * @param uvOffset is an optional vector2 used to offset UV.
  98155. * @param uvScale is an optional vector2 used to scale UV.
  98156. * @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.
  98157. * @returns the Mesh.
  98158. */
  98159. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98160. /**
  98161. * Modify the mesh to get a flat shading rendering.
  98162. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98163. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98164. * @returns current mesh
  98165. */
  98166. convertToFlatShadedMesh(): Mesh;
  98167. /**
  98168. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98169. * In other words, more vertices, no more indices and a single bigger VBO.
  98170. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98171. * @returns current mesh
  98172. */
  98173. convertToUnIndexedMesh(): Mesh;
  98174. /**
  98175. * Inverses facet orientations.
  98176. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98177. * @param flipNormals will also inverts the normals
  98178. * @returns current mesh
  98179. */
  98180. flipFaces(flipNormals?: boolean): Mesh;
  98181. /**
  98182. * Increase the number of facets and hence vertices in a mesh
  98183. * Vertex normals are interpolated from existing vertex normals
  98184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98185. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98186. */
  98187. increaseVertices(numberPerEdge: number): void;
  98188. /**
  98189. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98190. * This will undo any application of covertToFlatShadedMesh
  98191. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98192. */
  98193. forceSharedVertices(): void;
  98194. /** @hidden */
  98195. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98196. /** @hidden */
  98197. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98198. /**
  98199. * Creates a new InstancedMesh object from the mesh model.
  98200. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98201. * @param name defines the name of the new instance
  98202. * @returns a new InstancedMesh
  98203. */
  98204. createInstance(name: string): InstancedMesh;
  98205. /**
  98206. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98207. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98208. * @returns the current mesh
  98209. */
  98210. synchronizeInstances(): Mesh;
  98211. /**
  98212. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98213. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98214. * This should be used together with the simplification to avoid disappearing triangles.
  98215. * @param successCallback an optional success callback to be called after the optimization finished.
  98216. * @returns the current mesh
  98217. */
  98218. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98219. /**
  98220. * Serialize current mesh
  98221. * @param serializationObject defines the object which will receive the serialization data
  98222. */
  98223. serialize(serializationObject: any): void;
  98224. /** @hidden */
  98225. _syncGeometryWithMorphTargetManager(): void;
  98226. /** @hidden */
  98227. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98228. /**
  98229. * Returns a new Mesh object parsed from the source provided.
  98230. * @param parsedMesh is the source
  98231. * @param scene defines the hosting scene
  98232. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98233. * @returns a new Mesh
  98234. */
  98235. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98236. /**
  98237. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98238. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98239. * @param name defines the name of the mesh to create
  98240. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98241. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98242. * @param closePath creates a seam between the first and the last points of each path of the path array
  98243. * @param offset is taken in account only if the `pathArray` is containing a single path
  98244. * @param scene defines the hosting scene
  98245. * @param updatable defines if the mesh must be flagged as updatable
  98246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98247. * @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)
  98248. * @returns a new Mesh
  98249. */
  98250. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98251. /**
  98252. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98253. * @param name defines the name of the mesh to create
  98254. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98255. * @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
  98256. * @param scene defines the hosting scene
  98257. * @param updatable defines if the mesh must be flagged as updatable
  98258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98259. * @returns a new Mesh
  98260. */
  98261. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98262. /**
  98263. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98264. * @param name defines the name of the mesh to create
  98265. * @param size sets the size (float) of each box side (default 1)
  98266. * @param scene defines the hosting scene
  98267. * @param updatable defines if the mesh must be flagged as updatable
  98268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98269. * @returns a new Mesh
  98270. */
  98271. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98272. /**
  98273. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98274. * @param name defines the name of the mesh to create
  98275. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98276. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98277. * @param scene defines the hosting scene
  98278. * @param updatable defines if the mesh must be flagged as updatable
  98279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98280. * @returns a new Mesh
  98281. */
  98282. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98283. /**
  98284. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98285. * @param name defines the name of the mesh to create
  98286. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98287. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98288. * @param scene defines the hosting scene
  98289. * @returns a new Mesh
  98290. */
  98291. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98292. /**
  98293. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98294. * @param name defines the name of the mesh to create
  98295. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98296. * @param diameterTop set the top cap diameter (floats, default 1)
  98297. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98298. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98299. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98300. * @param scene defines the hosting scene
  98301. * @param updatable defines if the mesh must be flagged as updatable
  98302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98303. * @returns a new Mesh
  98304. */
  98305. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98306. /**
  98307. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98308. * @param name defines the name of the mesh to create
  98309. * @param diameter sets the diameter size (float) of the torus (default 1)
  98310. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98311. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98312. * @param scene defines the hosting scene
  98313. * @param updatable defines if the mesh must be flagged as updatable
  98314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98315. * @returns a new Mesh
  98316. */
  98317. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98318. /**
  98319. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98320. * @param name defines the name of the mesh to create
  98321. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98322. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98323. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98324. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98325. * @param p the number of windings on X axis (positive integers, default 2)
  98326. * @param q the number of windings on Y axis (positive integers, default 3)
  98327. * @param scene defines the hosting scene
  98328. * @param updatable defines if the mesh must be flagged as updatable
  98329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98330. * @returns a new Mesh
  98331. */
  98332. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98333. /**
  98334. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98335. * @param name defines the name of the mesh to create
  98336. * @param points is an array successive Vector3
  98337. * @param scene defines the hosting scene
  98338. * @param updatable defines if the mesh must be flagged as updatable
  98339. * @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).
  98340. * @returns a new Mesh
  98341. */
  98342. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98343. /**
  98344. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98345. * @param name defines the name of the mesh to create
  98346. * @param points is an array successive Vector3
  98347. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98348. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98349. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98350. * @param scene defines the hosting scene
  98351. * @param updatable defines if the mesh must be flagged as updatable
  98352. * @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)
  98353. * @returns a new Mesh
  98354. */
  98355. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98356. /**
  98357. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98358. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98359. * 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.
  98360. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98361. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98362. * Remember you can only change the shape positions, not their number when updating a polygon.
  98363. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98364. * @param name defines the name of the mesh to create
  98365. * @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
  98366. * @param scene defines the hosting scene
  98367. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98368. * @param updatable defines if the mesh must be flagged as updatable
  98369. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98370. * @param earcutInjection can be used to inject your own earcut reference
  98371. * @returns a new Mesh
  98372. */
  98373. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98374. /**
  98375. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98376. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98377. * @param name defines the name of the mesh to create
  98378. * @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
  98379. * @param depth defines the height of extrusion
  98380. * @param scene defines the hosting scene
  98381. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98382. * @param updatable defines if the mesh must be flagged as updatable
  98383. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98384. * @param earcutInjection can be used to inject your own earcut reference
  98385. * @returns a new Mesh
  98386. */
  98387. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98388. /**
  98389. * Creates an extruded shape mesh.
  98390. * 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
  98391. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98393. * @param name defines the name of the mesh to create
  98394. * @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
  98395. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98396. * @param scale is the value to scale the shape
  98397. * @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
  98398. * @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
  98399. * @param scene defines the hosting scene
  98400. * @param updatable defines if the mesh must be flagged as updatable
  98401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98402. * @param 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)
  98403. * @returns a new Mesh
  98404. */
  98405. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98406. /**
  98407. * Creates an custom extruded shape mesh.
  98408. * The custom extrusion is a parametric shape.
  98409. * It has no predefined shape. Its final shape will depend on the input parameters.
  98410. * Please consider using the same method from the MeshBuilder class instead
  98411. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98412. * @param name defines the name of the mesh to create
  98413. * @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
  98414. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98415. * @param scaleFunction is a custom Javascript function called on each path point
  98416. * @param rotationFunction is a custom Javascript function called on each path point
  98417. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98418. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98419. * @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
  98420. * @param scene defines the hosting scene
  98421. * @param updatable defines if the mesh must be flagged as updatable
  98422. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98423. * @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)
  98424. * @returns a new Mesh
  98425. */
  98426. 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;
  98427. /**
  98428. * Creates lathe mesh.
  98429. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98430. * Please consider using the same method from the MeshBuilder class instead
  98431. * @param name defines the name of the mesh to create
  98432. * @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
  98433. * @param radius is the radius value of the lathe
  98434. * @param tessellation is the side number of the lathe.
  98435. * @param scene defines the hosting scene
  98436. * @param updatable defines if the mesh must be flagged as updatable
  98437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98438. * @returns a new Mesh
  98439. */
  98440. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98441. /**
  98442. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98443. * @param name defines the name of the mesh to create
  98444. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98445. * @param scene defines the hosting scene
  98446. * @param updatable defines if the mesh must be flagged as updatable
  98447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98448. * @returns a new Mesh
  98449. */
  98450. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98451. /**
  98452. * Creates a ground mesh.
  98453. * Please consider using the same method from the MeshBuilder class instead
  98454. * @param name defines the name of the mesh to create
  98455. * @param width set the width of the ground
  98456. * @param height set the height of the ground
  98457. * @param subdivisions sets the number of subdivisions per side
  98458. * @param scene defines the hosting scene
  98459. * @param updatable defines if the mesh must be flagged as updatable
  98460. * @returns a new Mesh
  98461. */
  98462. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98463. /**
  98464. * Creates a tiled ground mesh.
  98465. * Please consider using the same method from the MeshBuilder class instead
  98466. * @param name defines the name of the mesh to create
  98467. * @param xmin set the ground minimum X coordinate
  98468. * @param zmin set the ground minimum Y coordinate
  98469. * @param xmax set the ground maximum X coordinate
  98470. * @param zmax set the ground maximum Z coordinate
  98471. * @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
  98472. * @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
  98473. * @param scene defines the hosting scene
  98474. * @param updatable defines if the mesh must be flagged as updatable
  98475. * @returns a new Mesh
  98476. */
  98477. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98478. w: number;
  98479. h: number;
  98480. }, precision: {
  98481. w: number;
  98482. h: number;
  98483. }, scene: Scene, updatable?: boolean): Mesh;
  98484. /**
  98485. * Creates a ground mesh from a height map.
  98486. * Please consider using the same method from the MeshBuilder class instead
  98487. * @see http://doc.babylonjs.com/babylon101/height_map
  98488. * @param name defines the name of the mesh to create
  98489. * @param url sets the URL of the height map image resource
  98490. * @param width set the ground width size
  98491. * @param height set the ground height size
  98492. * @param subdivisions sets the number of subdivision per side
  98493. * @param minHeight is the minimum altitude on the ground
  98494. * @param maxHeight is the maximum altitude on the ground
  98495. * @param scene defines the hosting scene
  98496. * @param updatable defines if the mesh must be flagged as updatable
  98497. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98498. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98499. * @returns a new Mesh
  98500. */
  98501. 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;
  98502. /**
  98503. * Creates a tube mesh.
  98504. * The tube is a parametric shape.
  98505. * It has no predefined shape. Its final shape will depend on the input parameters.
  98506. * Please consider using the same method from the MeshBuilder class instead
  98507. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98508. * @param name defines the name of the mesh to create
  98509. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98510. * @param radius sets the tube radius size
  98511. * @param tessellation is the number of sides on the tubular surface
  98512. * @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
  98513. * @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
  98514. * @param scene defines the hosting scene
  98515. * @param updatable defines if the mesh must be flagged as updatable
  98516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98517. * @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)
  98518. * @returns a new Mesh
  98519. */
  98520. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98521. (i: number, distance: number): number;
  98522. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98523. /**
  98524. * Creates a polyhedron mesh.
  98525. * Please consider using the same method from the MeshBuilder class instead.
  98526. * * 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
  98527. * * The parameter `size` (positive float, default 1) sets the polygon size
  98528. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98529. * * 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`
  98530. * * 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
  98531. * * 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)`)
  98532. * * 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
  98533. * * 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
  98534. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98535. * * If you create a double-sided mesh, you can choose what parts of 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
  98536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98537. * @param name defines the name of the mesh to create
  98538. * @param options defines the options used to create the mesh
  98539. * @param scene defines the hosting scene
  98540. * @returns a new Mesh
  98541. */
  98542. static CreatePolyhedron(name: string, options: {
  98543. type?: number;
  98544. size?: number;
  98545. sizeX?: number;
  98546. sizeY?: number;
  98547. sizeZ?: number;
  98548. custom?: any;
  98549. faceUV?: Vector4[];
  98550. faceColors?: Color4[];
  98551. updatable?: boolean;
  98552. sideOrientation?: number;
  98553. }, scene: Scene): Mesh;
  98554. /**
  98555. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98556. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98557. * * 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`)
  98558. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98559. * * 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
  98560. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98561. * * If you create a double-sided mesh, you can choose what parts of 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
  98562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98563. * @param name defines the name of the mesh
  98564. * @param options defines the options used to create the mesh
  98565. * @param scene defines the hosting scene
  98566. * @returns a new Mesh
  98567. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98568. */
  98569. static CreateIcoSphere(name: string, options: {
  98570. radius?: number;
  98571. flat?: boolean;
  98572. subdivisions?: number;
  98573. sideOrientation?: number;
  98574. updatable?: boolean;
  98575. }, scene: Scene): Mesh;
  98576. /**
  98577. * Creates a decal mesh.
  98578. * Please consider using the same method from the MeshBuilder class instead.
  98579. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98580. * @param name defines the name of the mesh
  98581. * @param sourceMesh defines the mesh receiving the decal
  98582. * @param position sets the position of the decal in world coordinates
  98583. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98584. * @param size sets the decal scaling
  98585. * @param angle sets the angle to rotate the decal
  98586. * @returns a new Mesh
  98587. */
  98588. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98589. /**
  98590. * Prepare internal position array for software CPU skinning
  98591. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98592. */
  98593. setPositionsForCPUSkinning(): Float32Array;
  98594. /**
  98595. * Prepare internal normal array for software CPU skinning
  98596. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98597. */
  98598. setNormalsForCPUSkinning(): Float32Array;
  98599. /**
  98600. * Updates the vertex buffer by applying transformation from the bones
  98601. * @param skeleton defines the skeleton to apply to current mesh
  98602. * @returns the current mesh
  98603. */
  98604. applySkeleton(skeleton: Skeleton): Mesh;
  98605. /**
  98606. * 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
  98607. * @param meshes defines the list of meshes to scan
  98608. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98609. */
  98610. static MinMax(meshes: AbstractMesh[]): {
  98611. min: Vector3;
  98612. max: Vector3;
  98613. };
  98614. /**
  98615. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98616. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98617. * @returns a vector3
  98618. */
  98619. static Center(meshesOrMinMaxVector: {
  98620. min: Vector3;
  98621. max: Vector3;
  98622. } | AbstractMesh[]): Vector3;
  98623. /**
  98624. * Merge the array of meshes into a single mesh for performance reasons.
  98625. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98626. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98627. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98628. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98629. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98630. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98631. * @returns a new mesh
  98632. */
  98633. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98634. /** @hidden */
  98635. addInstance(instance: InstancedMesh): void;
  98636. /** @hidden */
  98637. removeInstance(instance: InstancedMesh): void;
  98638. }
  98639. }
  98640. declare module BABYLON {
  98641. /**
  98642. * This is the base class of all the camera used in the application.
  98643. * @see http://doc.babylonjs.com/features/cameras
  98644. */
  98645. export class Camera extends Node {
  98646. /** @hidden */
  98647. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98648. /**
  98649. * This is the default projection mode used by the cameras.
  98650. * It helps recreating a feeling of perspective and better appreciate depth.
  98651. * This is the best way to simulate real life cameras.
  98652. */
  98653. static readonly PERSPECTIVE_CAMERA: number;
  98654. /**
  98655. * This helps creating camera with an orthographic mode.
  98656. * 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.
  98657. */
  98658. static readonly ORTHOGRAPHIC_CAMERA: number;
  98659. /**
  98660. * This is the default FOV mode for perspective cameras.
  98661. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98662. */
  98663. static readonly FOVMODE_VERTICAL_FIXED: number;
  98664. /**
  98665. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98666. */
  98667. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98668. /**
  98669. * This specifies ther is no need for a camera rig.
  98670. * Basically only one eye is rendered corresponding to the camera.
  98671. */
  98672. static readonly RIG_MODE_NONE: number;
  98673. /**
  98674. * Simulates a camera Rig with one blue eye and one red eye.
  98675. * This can be use with 3d blue and red glasses.
  98676. */
  98677. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98678. /**
  98679. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98680. */
  98681. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98682. /**
  98683. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98684. */
  98685. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98686. /**
  98687. * Defines that both eyes of the camera will be rendered over under each other.
  98688. */
  98689. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98690. /**
  98691. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98692. */
  98693. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98694. /**
  98695. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98696. */
  98697. static readonly RIG_MODE_VR: number;
  98698. /**
  98699. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98700. */
  98701. static readonly RIG_MODE_WEBVR: number;
  98702. /**
  98703. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98704. */
  98705. static readonly RIG_MODE_CUSTOM: number;
  98706. /**
  98707. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98708. */
  98709. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98710. /**
  98711. * Define the input manager associated with the camera.
  98712. */
  98713. inputs: CameraInputsManager<Camera>;
  98714. /** @hidden */
  98715. _position: Vector3;
  98716. /**
  98717. * Define the current local position of the camera in the scene
  98718. */
  98719. get position(): Vector3;
  98720. set position(newPosition: Vector3);
  98721. /**
  98722. * The vector the camera should consider as up.
  98723. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98724. */
  98725. upVector: Vector3;
  98726. /**
  98727. * Define the current limit on the left side for an orthographic camera
  98728. * In scene unit
  98729. */
  98730. orthoLeft: Nullable<number>;
  98731. /**
  98732. * Define the current limit on the right side for an orthographic camera
  98733. * In scene unit
  98734. */
  98735. orthoRight: Nullable<number>;
  98736. /**
  98737. * Define the current limit on the bottom side for an orthographic camera
  98738. * In scene unit
  98739. */
  98740. orthoBottom: Nullable<number>;
  98741. /**
  98742. * Define the current limit on the top side for an orthographic camera
  98743. * In scene unit
  98744. */
  98745. orthoTop: Nullable<number>;
  98746. /**
  98747. * Field Of View is set in Radians. (default is 0.8)
  98748. */
  98749. fov: number;
  98750. /**
  98751. * Define the minimum distance the camera can see from.
  98752. * This is important to note that the depth buffer are not infinite and the closer it starts
  98753. * the more your scene might encounter depth fighting issue.
  98754. */
  98755. minZ: number;
  98756. /**
  98757. * Define the maximum distance the camera can see to.
  98758. * This is important to note that the depth buffer are not infinite and the further it end
  98759. * the more your scene might encounter depth fighting issue.
  98760. */
  98761. maxZ: number;
  98762. /**
  98763. * Define the default inertia of the camera.
  98764. * This helps giving a smooth feeling to the camera movement.
  98765. */
  98766. inertia: number;
  98767. /**
  98768. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98769. */
  98770. mode: number;
  98771. /**
  98772. * Define whether the camera is intermediate.
  98773. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98774. */
  98775. isIntermediate: boolean;
  98776. /**
  98777. * Define the viewport of the camera.
  98778. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98779. */
  98780. viewport: Viewport;
  98781. /**
  98782. * Restricts the camera to viewing objects with the same layerMask.
  98783. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98784. */
  98785. layerMask: number;
  98786. /**
  98787. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98788. */
  98789. fovMode: number;
  98790. /**
  98791. * Rig mode of the camera.
  98792. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98793. * This is normally controlled byt the camera themselves as internal use.
  98794. */
  98795. cameraRigMode: number;
  98796. /**
  98797. * Defines the distance between both "eyes" in case of a RIG
  98798. */
  98799. interaxialDistance: number;
  98800. /**
  98801. * Defines if stereoscopic rendering is done side by side or over under.
  98802. */
  98803. isStereoscopicSideBySide: boolean;
  98804. /**
  98805. * 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
  98806. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98807. * else in the scene. (Eg. security camera)
  98808. *
  98809. * 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)
  98810. */
  98811. customRenderTargets: RenderTargetTexture[];
  98812. /**
  98813. * When set, the camera will render to this render target instead of the default canvas
  98814. *
  98815. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98816. */
  98817. outputRenderTarget: Nullable<RenderTargetTexture>;
  98818. /**
  98819. * Observable triggered when the camera view matrix has changed.
  98820. */
  98821. onViewMatrixChangedObservable: Observable<Camera>;
  98822. /**
  98823. * Observable triggered when the camera Projection matrix has changed.
  98824. */
  98825. onProjectionMatrixChangedObservable: Observable<Camera>;
  98826. /**
  98827. * Observable triggered when the inputs have been processed.
  98828. */
  98829. onAfterCheckInputsObservable: Observable<Camera>;
  98830. /**
  98831. * Observable triggered when reset has been called and applied to the camera.
  98832. */
  98833. onRestoreStateObservable: Observable<Camera>;
  98834. /**
  98835. * Is this camera a part of a rig system?
  98836. */
  98837. isRigCamera: boolean;
  98838. /**
  98839. * If isRigCamera set to true this will be set with the parent camera.
  98840. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98841. */
  98842. rigParent?: Camera;
  98843. /** @hidden */
  98844. _cameraRigParams: any;
  98845. /** @hidden */
  98846. _rigCameras: Camera[];
  98847. /** @hidden */
  98848. _rigPostProcess: Nullable<PostProcess>;
  98849. protected _webvrViewMatrix: Matrix;
  98850. /** @hidden */
  98851. _skipRendering: boolean;
  98852. /** @hidden */
  98853. _projectionMatrix: Matrix;
  98854. /** @hidden */
  98855. _postProcesses: Nullable<PostProcess>[];
  98856. /** @hidden */
  98857. _activeMeshes: SmartArray<AbstractMesh>;
  98858. protected _globalPosition: Vector3;
  98859. /** @hidden */
  98860. _computedViewMatrix: Matrix;
  98861. private _doNotComputeProjectionMatrix;
  98862. private _transformMatrix;
  98863. private _frustumPlanes;
  98864. private _refreshFrustumPlanes;
  98865. private _storedFov;
  98866. private _stateStored;
  98867. /**
  98868. * Instantiates a new camera object.
  98869. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98870. * @see http://doc.babylonjs.com/features/cameras
  98871. * @param name Defines the name of the camera in the scene
  98872. * @param position Defines the position of the camera
  98873. * @param scene Defines the scene the camera belongs too
  98874. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98875. */
  98876. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98877. /**
  98878. * Store current camera state (fov, position, etc..)
  98879. * @returns the camera
  98880. */
  98881. storeState(): Camera;
  98882. /**
  98883. * Restores the camera state values if it has been stored. You must call storeState() first
  98884. */
  98885. protected _restoreStateValues(): boolean;
  98886. /**
  98887. * Restored camera state. You must call storeState() first.
  98888. * @returns true if restored and false otherwise
  98889. */
  98890. restoreState(): boolean;
  98891. /**
  98892. * Gets the class name of the camera.
  98893. * @returns the class name
  98894. */
  98895. getClassName(): string;
  98896. /** @hidden */
  98897. readonly _isCamera: boolean;
  98898. /**
  98899. * Gets a string representation of the camera useful for debug purpose.
  98900. * @param fullDetails Defines that a more verboe level of logging is required
  98901. * @returns the string representation
  98902. */
  98903. toString(fullDetails?: boolean): string;
  98904. /**
  98905. * Gets the current world space position of the camera.
  98906. */
  98907. get globalPosition(): Vector3;
  98908. /**
  98909. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98910. * @returns the active meshe list
  98911. */
  98912. getActiveMeshes(): SmartArray<AbstractMesh>;
  98913. /**
  98914. * Check whether a mesh is part of the current active mesh list of the camera
  98915. * @param mesh Defines the mesh to check
  98916. * @returns true if active, false otherwise
  98917. */
  98918. isActiveMesh(mesh: Mesh): boolean;
  98919. /**
  98920. * Is this camera ready to be used/rendered
  98921. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98922. * @return true if the camera is ready
  98923. */
  98924. isReady(completeCheck?: boolean): boolean;
  98925. /** @hidden */
  98926. _initCache(): void;
  98927. /** @hidden */
  98928. _updateCache(ignoreParentClass?: boolean): void;
  98929. /** @hidden */
  98930. _isSynchronized(): boolean;
  98931. /** @hidden */
  98932. _isSynchronizedViewMatrix(): boolean;
  98933. /** @hidden */
  98934. _isSynchronizedProjectionMatrix(): boolean;
  98935. /**
  98936. * Attach the input controls to a specific dom element to get the input from.
  98937. * @param element Defines the element the controls should be listened from
  98938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98939. */
  98940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98941. /**
  98942. * Detach the current controls from the specified dom element.
  98943. * @param element Defines the element to stop listening the inputs from
  98944. */
  98945. detachControl(element: HTMLElement): void;
  98946. /**
  98947. * Update the camera state according to the different inputs gathered during the frame.
  98948. */
  98949. update(): void;
  98950. /** @hidden */
  98951. _checkInputs(): void;
  98952. /** @hidden */
  98953. get rigCameras(): Camera[];
  98954. /**
  98955. * Gets the post process used by the rig cameras
  98956. */
  98957. get rigPostProcess(): Nullable<PostProcess>;
  98958. /**
  98959. * Internal, gets the first post proces.
  98960. * @returns the first post process to be run on this camera.
  98961. */
  98962. _getFirstPostProcess(): Nullable<PostProcess>;
  98963. private _cascadePostProcessesToRigCams;
  98964. /**
  98965. * Attach a post process to the camera.
  98966. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98967. * @param postProcess The post process to attach to the camera
  98968. * @param insertAt The position of the post process in case several of them are in use in the scene
  98969. * @returns the position the post process has been inserted at
  98970. */
  98971. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98972. /**
  98973. * Detach a post process to the camera.
  98974. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98975. * @param postProcess The post process to detach from the camera
  98976. */
  98977. detachPostProcess(postProcess: PostProcess): void;
  98978. /**
  98979. * Gets the current world matrix of the camera
  98980. */
  98981. getWorldMatrix(): Matrix;
  98982. /** @hidden */
  98983. _getViewMatrix(): Matrix;
  98984. /**
  98985. * Gets the current view matrix of the camera.
  98986. * @param force forces the camera to recompute the matrix without looking at the cached state
  98987. * @returns the view matrix
  98988. */
  98989. getViewMatrix(force?: boolean): Matrix;
  98990. /**
  98991. * Freeze the projection matrix.
  98992. * It will prevent the cache check of the camera projection compute and can speed up perf
  98993. * if no parameter of the camera are meant to change
  98994. * @param projection Defines manually a projection if necessary
  98995. */
  98996. freezeProjectionMatrix(projection?: Matrix): void;
  98997. /**
  98998. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98999. */
  99000. unfreezeProjectionMatrix(): void;
  99001. /**
  99002. * Gets the current projection matrix of the camera.
  99003. * @param force forces the camera to recompute the matrix without looking at the cached state
  99004. * @returns the projection matrix
  99005. */
  99006. getProjectionMatrix(force?: boolean): Matrix;
  99007. /**
  99008. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99009. * @returns a Matrix
  99010. */
  99011. getTransformationMatrix(): Matrix;
  99012. private _updateFrustumPlanes;
  99013. /**
  99014. * Checks if a cullable object (mesh...) is in the camera frustum
  99015. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99016. * @param target The object to check
  99017. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99018. * @returns true if the object is in frustum otherwise false
  99019. */
  99020. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99021. /**
  99022. * Checks if a cullable object (mesh...) is in the camera frustum
  99023. * Unlike isInFrustum this cheks the full bounding box
  99024. * @param target The object to check
  99025. * @returns true if the object is in frustum otherwise false
  99026. */
  99027. isCompletelyInFrustum(target: ICullable): boolean;
  99028. /**
  99029. * Gets a ray in the forward direction from the camera.
  99030. * @param length Defines the length of the ray to create
  99031. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99032. * @param origin Defines the start point of the ray which defaults to the camera position
  99033. * @returns the forward ray
  99034. */
  99035. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99036. /**
  99037. * Releases resources associated with this node.
  99038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99040. */
  99041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99042. /** @hidden */
  99043. _isLeftCamera: boolean;
  99044. /**
  99045. * Gets the left camera of a rig setup in case of Rigged Camera
  99046. */
  99047. get isLeftCamera(): boolean;
  99048. /** @hidden */
  99049. _isRightCamera: boolean;
  99050. /**
  99051. * Gets the right camera of a rig setup in case of Rigged Camera
  99052. */
  99053. get isRightCamera(): boolean;
  99054. /**
  99055. * Gets the left camera of a rig setup in case of Rigged Camera
  99056. */
  99057. get leftCamera(): Nullable<FreeCamera>;
  99058. /**
  99059. * Gets the right camera of a rig setup in case of Rigged Camera
  99060. */
  99061. get rightCamera(): Nullable<FreeCamera>;
  99062. /**
  99063. * Gets the left camera target of a rig setup in case of Rigged Camera
  99064. * @returns the target position
  99065. */
  99066. getLeftTarget(): Nullable<Vector3>;
  99067. /**
  99068. * Gets the right camera target of a rig setup in case of Rigged Camera
  99069. * @returns the target position
  99070. */
  99071. getRightTarget(): Nullable<Vector3>;
  99072. /**
  99073. * @hidden
  99074. */
  99075. setCameraRigMode(mode: number, rigParams: any): void;
  99076. /** @hidden */
  99077. static _setStereoscopicRigMode(camera: Camera): void;
  99078. /** @hidden */
  99079. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99080. /** @hidden */
  99081. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99082. /** @hidden */
  99083. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99084. /** @hidden */
  99085. _getVRProjectionMatrix(): Matrix;
  99086. protected _updateCameraRotationMatrix(): void;
  99087. protected _updateWebVRCameraRotationMatrix(): void;
  99088. /**
  99089. * This function MUST be overwritten by the different WebVR cameras available.
  99090. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99091. * @hidden
  99092. */
  99093. _getWebVRProjectionMatrix(): Matrix;
  99094. /**
  99095. * This function MUST be overwritten by the different WebVR cameras available.
  99096. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99097. * @hidden
  99098. */
  99099. _getWebVRViewMatrix(): Matrix;
  99100. /** @hidden */
  99101. setCameraRigParameter(name: string, value: any): void;
  99102. /**
  99103. * needs to be overridden by children so sub has required properties to be copied
  99104. * @hidden
  99105. */
  99106. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99107. /**
  99108. * May need to be overridden by children
  99109. * @hidden
  99110. */
  99111. _updateRigCameras(): void;
  99112. /** @hidden */
  99113. _setupInputs(): void;
  99114. /**
  99115. * Serialiaze the camera setup to a json represention
  99116. * @returns the JSON representation
  99117. */
  99118. serialize(): any;
  99119. /**
  99120. * Clones the current camera.
  99121. * @param name The cloned camera name
  99122. * @returns the cloned camera
  99123. */
  99124. clone(name: string): Camera;
  99125. /**
  99126. * Gets the direction of the camera relative to a given local axis.
  99127. * @param localAxis Defines the reference axis to provide a relative direction.
  99128. * @return the direction
  99129. */
  99130. getDirection(localAxis: Vector3): Vector3;
  99131. /**
  99132. * Returns the current camera absolute rotation
  99133. */
  99134. get absoluteRotation(): Quaternion;
  99135. /**
  99136. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99137. * @param localAxis Defines the reference axis to provide a relative direction.
  99138. * @param result Defines the vector to store the result in
  99139. */
  99140. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99141. /**
  99142. * Gets a camera constructor for a given camera type
  99143. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99144. * @param name The name of the camera the result will be able to instantiate
  99145. * @param scene The scene the result will construct the camera in
  99146. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99147. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99148. * @returns a factory method to construc the camera
  99149. */
  99150. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99151. /**
  99152. * Compute the world matrix of the camera.
  99153. * @returns the camera world matrix
  99154. */
  99155. computeWorldMatrix(): Matrix;
  99156. /**
  99157. * Parse a JSON and creates the camera from the parsed information
  99158. * @param parsedCamera The JSON to parse
  99159. * @param scene The scene to instantiate the camera in
  99160. * @returns the newly constructed camera
  99161. */
  99162. static Parse(parsedCamera: any, scene: Scene): Camera;
  99163. }
  99164. }
  99165. declare module BABYLON {
  99166. /**
  99167. * Class containing static functions to help procedurally build meshes
  99168. */
  99169. export class DiscBuilder {
  99170. /**
  99171. * Creates a plane polygonal mesh. By default, this is a disc
  99172. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99173. * * 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
  99174. * * 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
  99175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99178. * @param name defines the name of the mesh
  99179. * @param options defines the options used to create the mesh
  99180. * @param scene defines the hosting scene
  99181. * @returns the plane polygonal mesh
  99182. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99183. */
  99184. static CreateDisc(name: string, options: {
  99185. radius?: number;
  99186. tessellation?: number;
  99187. arc?: number;
  99188. updatable?: boolean;
  99189. sideOrientation?: number;
  99190. frontUVs?: Vector4;
  99191. backUVs?: Vector4;
  99192. }, scene?: Nullable<Scene>): Mesh;
  99193. }
  99194. }
  99195. declare module BABYLON {
  99196. /**
  99197. * This represents all the required information to add a fresnel effect on a material:
  99198. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99199. */
  99200. export class FresnelParameters {
  99201. private _isEnabled;
  99202. /**
  99203. * Define if the fresnel effect is enable or not.
  99204. */
  99205. get isEnabled(): boolean;
  99206. set isEnabled(value: boolean);
  99207. /**
  99208. * Define the color used on edges (grazing angle)
  99209. */
  99210. leftColor: Color3;
  99211. /**
  99212. * Define the color used on center
  99213. */
  99214. rightColor: Color3;
  99215. /**
  99216. * Define bias applied to computed fresnel term
  99217. */
  99218. bias: number;
  99219. /**
  99220. * Defined the power exponent applied to fresnel term
  99221. */
  99222. power: number;
  99223. /**
  99224. * Clones the current fresnel and its valuues
  99225. * @returns a clone fresnel configuration
  99226. */
  99227. clone(): FresnelParameters;
  99228. /**
  99229. * Serializes the current fresnel parameters to a JSON representation.
  99230. * @return the JSON serialization
  99231. */
  99232. serialize(): any;
  99233. /**
  99234. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99235. * @param parsedFresnelParameters Define the JSON representation
  99236. * @returns the parsed parameters
  99237. */
  99238. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99239. }
  99240. }
  99241. declare module BABYLON {
  99242. /**
  99243. * Base class of materials working in push mode in babylon JS
  99244. * @hidden
  99245. */
  99246. export class PushMaterial extends Material {
  99247. protected _activeEffect: Effect;
  99248. protected _normalMatrix: Matrix;
  99249. /**
  99250. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99251. * This means that the material can keep using a previous shader while a new one is being compiled.
  99252. * This is mostly used when shader parallel compilation is supported (true by default)
  99253. */
  99254. allowShaderHotSwapping: boolean;
  99255. constructor(name: string, scene: Scene);
  99256. getEffect(): Effect;
  99257. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99258. /**
  99259. * Binds the given world matrix to the active effect
  99260. *
  99261. * @param world the matrix to bind
  99262. */
  99263. bindOnlyWorldMatrix(world: Matrix): void;
  99264. /**
  99265. * Binds the given normal matrix to the active effect
  99266. *
  99267. * @param normalMatrix the matrix to bind
  99268. */
  99269. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99270. bind(world: Matrix, mesh?: Mesh): void;
  99271. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99272. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99273. }
  99274. }
  99275. declare module BABYLON {
  99276. /**
  99277. * This groups all the flags used to control the materials channel.
  99278. */
  99279. export class MaterialFlags {
  99280. private static _DiffuseTextureEnabled;
  99281. /**
  99282. * Are diffuse textures enabled in the application.
  99283. */
  99284. static get DiffuseTextureEnabled(): boolean;
  99285. static set DiffuseTextureEnabled(value: boolean);
  99286. private static _AmbientTextureEnabled;
  99287. /**
  99288. * Are ambient textures enabled in the application.
  99289. */
  99290. static get AmbientTextureEnabled(): boolean;
  99291. static set AmbientTextureEnabled(value: boolean);
  99292. private static _OpacityTextureEnabled;
  99293. /**
  99294. * Are opacity textures enabled in the application.
  99295. */
  99296. static get OpacityTextureEnabled(): boolean;
  99297. static set OpacityTextureEnabled(value: boolean);
  99298. private static _ReflectionTextureEnabled;
  99299. /**
  99300. * Are reflection textures enabled in the application.
  99301. */
  99302. static get ReflectionTextureEnabled(): boolean;
  99303. static set ReflectionTextureEnabled(value: boolean);
  99304. private static _EmissiveTextureEnabled;
  99305. /**
  99306. * Are emissive textures enabled in the application.
  99307. */
  99308. static get EmissiveTextureEnabled(): boolean;
  99309. static set EmissiveTextureEnabled(value: boolean);
  99310. private static _SpecularTextureEnabled;
  99311. /**
  99312. * Are specular textures enabled in the application.
  99313. */
  99314. static get SpecularTextureEnabled(): boolean;
  99315. static set SpecularTextureEnabled(value: boolean);
  99316. private static _BumpTextureEnabled;
  99317. /**
  99318. * Are bump textures enabled in the application.
  99319. */
  99320. static get BumpTextureEnabled(): boolean;
  99321. static set BumpTextureEnabled(value: boolean);
  99322. private static _LightmapTextureEnabled;
  99323. /**
  99324. * Are lightmap textures enabled in the application.
  99325. */
  99326. static get LightmapTextureEnabled(): boolean;
  99327. static set LightmapTextureEnabled(value: boolean);
  99328. private static _RefractionTextureEnabled;
  99329. /**
  99330. * Are refraction textures enabled in the application.
  99331. */
  99332. static get RefractionTextureEnabled(): boolean;
  99333. static set RefractionTextureEnabled(value: boolean);
  99334. private static _ColorGradingTextureEnabled;
  99335. /**
  99336. * Are color grading textures enabled in the application.
  99337. */
  99338. static get ColorGradingTextureEnabled(): boolean;
  99339. static set ColorGradingTextureEnabled(value: boolean);
  99340. private static _FresnelEnabled;
  99341. /**
  99342. * Are fresnels enabled in the application.
  99343. */
  99344. static get FresnelEnabled(): boolean;
  99345. static set FresnelEnabled(value: boolean);
  99346. private static _ClearCoatTextureEnabled;
  99347. /**
  99348. * Are clear coat textures enabled in the application.
  99349. */
  99350. static get ClearCoatTextureEnabled(): boolean;
  99351. static set ClearCoatTextureEnabled(value: boolean);
  99352. private static _ClearCoatBumpTextureEnabled;
  99353. /**
  99354. * Are clear coat bump textures enabled in the application.
  99355. */
  99356. static get ClearCoatBumpTextureEnabled(): boolean;
  99357. static set ClearCoatBumpTextureEnabled(value: boolean);
  99358. private static _ClearCoatTintTextureEnabled;
  99359. /**
  99360. * Are clear coat tint textures enabled in the application.
  99361. */
  99362. static get ClearCoatTintTextureEnabled(): boolean;
  99363. static set ClearCoatTintTextureEnabled(value: boolean);
  99364. private static _SheenTextureEnabled;
  99365. /**
  99366. * Are sheen textures enabled in the application.
  99367. */
  99368. static get SheenTextureEnabled(): boolean;
  99369. static set SheenTextureEnabled(value: boolean);
  99370. private static _AnisotropicTextureEnabled;
  99371. /**
  99372. * Are anisotropic textures enabled in the application.
  99373. */
  99374. static get AnisotropicTextureEnabled(): boolean;
  99375. static set AnisotropicTextureEnabled(value: boolean);
  99376. private static _ThicknessTextureEnabled;
  99377. /**
  99378. * Are thickness textures enabled in the application.
  99379. */
  99380. static get ThicknessTextureEnabled(): boolean;
  99381. static set ThicknessTextureEnabled(value: boolean);
  99382. }
  99383. }
  99384. declare module BABYLON {
  99385. /** @hidden */
  99386. export var defaultFragmentDeclaration: {
  99387. name: string;
  99388. shader: string;
  99389. };
  99390. }
  99391. declare module BABYLON {
  99392. /** @hidden */
  99393. export var defaultUboDeclaration: {
  99394. name: string;
  99395. shader: string;
  99396. };
  99397. }
  99398. declare module BABYLON {
  99399. /** @hidden */
  99400. export var lightFragmentDeclaration: {
  99401. name: string;
  99402. shader: string;
  99403. };
  99404. }
  99405. declare module BABYLON {
  99406. /** @hidden */
  99407. export var lightUboDeclaration: {
  99408. name: string;
  99409. shader: string;
  99410. };
  99411. }
  99412. declare module BABYLON {
  99413. /** @hidden */
  99414. export var lightsFragmentFunctions: {
  99415. name: string;
  99416. shader: string;
  99417. };
  99418. }
  99419. declare module BABYLON {
  99420. /** @hidden */
  99421. export var shadowsFragmentFunctions: {
  99422. name: string;
  99423. shader: string;
  99424. };
  99425. }
  99426. declare module BABYLON {
  99427. /** @hidden */
  99428. export var fresnelFunction: {
  99429. name: string;
  99430. shader: string;
  99431. };
  99432. }
  99433. declare module BABYLON {
  99434. /** @hidden */
  99435. export var reflectionFunction: {
  99436. name: string;
  99437. shader: string;
  99438. };
  99439. }
  99440. declare module BABYLON {
  99441. /** @hidden */
  99442. export var bumpFragmentFunctions: {
  99443. name: string;
  99444. shader: string;
  99445. };
  99446. }
  99447. declare module BABYLON {
  99448. /** @hidden */
  99449. export var logDepthDeclaration: {
  99450. name: string;
  99451. shader: string;
  99452. };
  99453. }
  99454. declare module BABYLON {
  99455. /** @hidden */
  99456. export var bumpFragment: {
  99457. name: string;
  99458. shader: string;
  99459. };
  99460. }
  99461. declare module BABYLON {
  99462. /** @hidden */
  99463. export var depthPrePass: {
  99464. name: string;
  99465. shader: string;
  99466. };
  99467. }
  99468. declare module BABYLON {
  99469. /** @hidden */
  99470. export var lightFragment: {
  99471. name: string;
  99472. shader: string;
  99473. };
  99474. }
  99475. declare module BABYLON {
  99476. /** @hidden */
  99477. export var logDepthFragment: {
  99478. name: string;
  99479. shader: string;
  99480. };
  99481. }
  99482. declare module BABYLON {
  99483. /** @hidden */
  99484. export var defaultPixelShader: {
  99485. name: string;
  99486. shader: string;
  99487. };
  99488. }
  99489. declare module BABYLON {
  99490. /** @hidden */
  99491. export var defaultVertexDeclaration: {
  99492. name: string;
  99493. shader: string;
  99494. };
  99495. }
  99496. declare module BABYLON {
  99497. /** @hidden */
  99498. export var bumpVertexDeclaration: {
  99499. name: string;
  99500. shader: string;
  99501. };
  99502. }
  99503. declare module BABYLON {
  99504. /** @hidden */
  99505. export var bumpVertex: {
  99506. name: string;
  99507. shader: string;
  99508. };
  99509. }
  99510. declare module BABYLON {
  99511. /** @hidden */
  99512. export var fogVertex: {
  99513. name: string;
  99514. shader: string;
  99515. };
  99516. }
  99517. declare module BABYLON {
  99518. /** @hidden */
  99519. export var shadowsVertex: {
  99520. name: string;
  99521. shader: string;
  99522. };
  99523. }
  99524. declare module BABYLON {
  99525. /** @hidden */
  99526. export var pointCloudVertex: {
  99527. name: string;
  99528. shader: string;
  99529. };
  99530. }
  99531. declare module BABYLON {
  99532. /** @hidden */
  99533. export var logDepthVertex: {
  99534. name: string;
  99535. shader: string;
  99536. };
  99537. }
  99538. declare module BABYLON {
  99539. /** @hidden */
  99540. export var defaultVertexShader: {
  99541. name: string;
  99542. shader: string;
  99543. };
  99544. }
  99545. declare module BABYLON {
  99546. /** @hidden */
  99547. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99548. MAINUV1: boolean;
  99549. MAINUV2: boolean;
  99550. DIFFUSE: boolean;
  99551. DIFFUSEDIRECTUV: number;
  99552. AMBIENT: boolean;
  99553. AMBIENTDIRECTUV: number;
  99554. OPACITY: boolean;
  99555. OPACITYDIRECTUV: number;
  99556. OPACITYRGB: boolean;
  99557. REFLECTION: boolean;
  99558. EMISSIVE: boolean;
  99559. EMISSIVEDIRECTUV: number;
  99560. SPECULAR: boolean;
  99561. SPECULARDIRECTUV: number;
  99562. BUMP: boolean;
  99563. BUMPDIRECTUV: number;
  99564. PARALLAX: boolean;
  99565. PARALLAXOCCLUSION: boolean;
  99566. SPECULAROVERALPHA: boolean;
  99567. CLIPPLANE: boolean;
  99568. CLIPPLANE2: boolean;
  99569. CLIPPLANE3: boolean;
  99570. CLIPPLANE4: boolean;
  99571. CLIPPLANE5: boolean;
  99572. CLIPPLANE6: boolean;
  99573. ALPHATEST: boolean;
  99574. DEPTHPREPASS: boolean;
  99575. ALPHAFROMDIFFUSE: boolean;
  99576. POINTSIZE: boolean;
  99577. FOG: boolean;
  99578. SPECULARTERM: boolean;
  99579. DIFFUSEFRESNEL: boolean;
  99580. OPACITYFRESNEL: boolean;
  99581. REFLECTIONFRESNEL: boolean;
  99582. REFRACTIONFRESNEL: boolean;
  99583. EMISSIVEFRESNEL: boolean;
  99584. FRESNEL: boolean;
  99585. NORMAL: boolean;
  99586. UV1: boolean;
  99587. UV2: boolean;
  99588. VERTEXCOLOR: boolean;
  99589. VERTEXALPHA: boolean;
  99590. NUM_BONE_INFLUENCERS: number;
  99591. BonesPerMesh: number;
  99592. BONETEXTURE: boolean;
  99593. INSTANCES: boolean;
  99594. GLOSSINESS: boolean;
  99595. ROUGHNESS: boolean;
  99596. EMISSIVEASILLUMINATION: boolean;
  99597. LINKEMISSIVEWITHDIFFUSE: boolean;
  99598. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99599. LIGHTMAP: boolean;
  99600. LIGHTMAPDIRECTUV: number;
  99601. OBJECTSPACE_NORMALMAP: boolean;
  99602. USELIGHTMAPASSHADOWMAP: boolean;
  99603. REFLECTIONMAP_3D: boolean;
  99604. REFLECTIONMAP_SPHERICAL: boolean;
  99605. REFLECTIONMAP_PLANAR: boolean;
  99606. REFLECTIONMAP_CUBIC: boolean;
  99607. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99608. REFLECTIONMAP_PROJECTION: boolean;
  99609. REFLECTIONMAP_SKYBOX: boolean;
  99610. REFLECTIONMAP_EXPLICIT: boolean;
  99611. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99612. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99613. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99614. INVERTCUBICMAP: boolean;
  99615. LOGARITHMICDEPTH: boolean;
  99616. REFRACTION: boolean;
  99617. REFRACTIONMAP_3D: boolean;
  99618. REFLECTIONOVERALPHA: boolean;
  99619. TWOSIDEDLIGHTING: boolean;
  99620. SHADOWFLOAT: boolean;
  99621. MORPHTARGETS: boolean;
  99622. MORPHTARGETS_NORMAL: boolean;
  99623. MORPHTARGETS_TANGENT: boolean;
  99624. MORPHTARGETS_UV: boolean;
  99625. NUM_MORPH_INFLUENCERS: number;
  99626. NONUNIFORMSCALING: boolean;
  99627. PREMULTIPLYALPHA: boolean;
  99628. IMAGEPROCESSING: boolean;
  99629. VIGNETTE: boolean;
  99630. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99631. VIGNETTEBLENDMODEOPAQUE: boolean;
  99632. TONEMAPPING: boolean;
  99633. TONEMAPPING_ACES: boolean;
  99634. CONTRAST: boolean;
  99635. COLORCURVES: boolean;
  99636. COLORGRADING: boolean;
  99637. COLORGRADING3D: boolean;
  99638. SAMPLER3DGREENDEPTH: boolean;
  99639. SAMPLER3DBGRMAP: boolean;
  99640. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99641. MULTIVIEW: boolean;
  99642. /**
  99643. * If the reflection texture on this material is in linear color space
  99644. * @hidden
  99645. */
  99646. IS_REFLECTION_LINEAR: boolean;
  99647. /**
  99648. * If the refraction texture on this material is in linear color space
  99649. * @hidden
  99650. */
  99651. IS_REFRACTION_LINEAR: boolean;
  99652. EXPOSURE: boolean;
  99653. constructor();
  99654. setReflectionMode(modeToEnable: string): void;
  99655. }
  99656. /**
  99657. * This is the default material used in Babylon. It is the best trade off between quality
  99658. * and performances.
  99659. * @see http://doc.babylonjs.com/babylon101/materials
  99660. */
  99661. export class StandardMaterial extends PushMaterial {
  99662. private _diffuseTexture;
  99663. /**
  99664. * The basic texture of the material as viewed under a light.
  99665. */
  99666. diffuseTexture: Nullable<BaseTexture>;
  99667. private _ambientTexture;
  99668. /**
  99669. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99670. */
  99671. ambientTexture: Nullable<BaseTexture>;
  99672. private _opacityTexture;
  99673. /**
  99674. * Define the transparency of the material from a texture.
  99675. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99676. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99677. */
  99678. opacityTexture: Nullable<BaseTexture>;
  99679. private _reflectionTexture;
  99680. /**
  99681. * Define the texture used to display the reflection.
  99682. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99683. */
  99684. reflectionTexture: Nullable<BaseTexture>;
  99685. private _emissiveTexture;
  99686. /**
  99687. * Define texture of the material as if self lit.
  99688. * This will be mixed in the final result even in the absence of light.
  99689. */
  99690. emissiveTexture: Nullable<BaseTexture>;
  99691. private _specularTexture;
  99692. /**
  99693. * Define how the color and intensity of the highlight given by the light in the material.
  99694. */
  99695. specularTexture: Nullable<BaseTexture>;
  99696. private _bumpTexture;
  99697. /**
  99698. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99699. * 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.
  99700. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99701. */
  99702. bumpTexture: Nullable<BaseTexture>;
  99703. private _lightmapTexture;
  99704. /**
  99705. * Complex lighting can be computationally expensive to compute at runtime.
  99706. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99707. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99708. */
  99709. lightmapTexture: Nullable<BaseTexture>;
  99710. private _refractionTexture;
  99711. /**
  99712. * Define the texture used to display the refraction.
  99713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99714. */
  99715. refractionTexture: Nullable<BaseTexture>;
  99716. /**
  99717. * The color of the material lit by the environmental background lighting.
  99718. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99719. */
  99720. ambientColor: Color3;
  99721. /**
  99722. * The basic color of the material as viewed under a light.
  99723. */
  99724. diffuseColor: Color3;
  99725. /**
  99726. * Define how the color and intensity of the highlight given by the light in the material.
  99727. */
  99728. specularColor: Color3;
  99729. /**
  99730. * Define the color of the material as if self lit.
  99731. * This will be mixed in the final result even in the absence of light.
  99732. */
  99733. emissiveColor: Color3;
  99734. /**
  99735. * Defines how sharp are the highlights in the material.
  99736. * The bigger the value the sharper giving a more glossy feeling to the result.
  99737. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99738. */
  99739. specularPower: number;
  99740. private _useAlphaFromDiffuseTexture;
  99741. /**
  99742. * Does the transparency come from the diffuse texture alpha channel.
  99743. */
  99744. useAlphaFromDiffuseTexture: boolean;
  99745. private _useEmissiveAsIllumination;
  99746. /**
  99747. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99748. */
  99749. useEmissiveAsIllumination: boolean;
  99750. private _linkEmissiveWithDiffuse;
  99751. /**
  99752. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99753. * the emissive level when the final color is close to one.
  99754. */
  99755. linkEmissiveWithDiffuse: boolean;
  99756. private _useSpecularOverAlpha;
  99757. /**
  99758. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99759. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99760. */
  99761. useSpecularOverAlpha: boolean;
  99762. private _useReflectionOverAlpha;
  99763. /**
  99764. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99765. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99766. */
  99767. useReflectionOverAlpha: boolean;
  99768. private _disableLighting;
  99769. /**
  99770. * Does lights from the scene impacts this material.
  99771. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99772. */
  99773. disableLighting: boolean;
  99774. private _useObjectSpaceNormalMap;
  99775. /**
  99776. * Allows using an object space normal map (instead of tangent space).
  99777. */
  99778. useObjectSpaceNormalMap: boolean;
  99779. private _useParallax;
  99780. /**
  99781. * Is parallax enabled or not.
  99782. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99783. */
  99784. useParallax: boolean;
  99785. private _useParallaxOcclusion;
  99786. /**
  99787. * Is parallax occlusion enabled or not.
  99788. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99789. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99790. */
  99791. useParallaxOcclusion: boolean;
  99792. /**
  99793. * 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.
  99794. */
  99795. parallaxScaleBias: number;
  99796. private _roughness;
  99797. /**
  99798. * Helps to define how blurry the reflections should appears in the material.
  99799. */
  99800. roughness: number;
  99801. /**
  99802. * In case of refraction, define the value of the index of refraction.
  99803. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99804. */
  99805. indexOfRefraction: number;
  99806. /**
  99807. * Invert the refraction texture alongside the y axis.
  99808. * It can be useful with procedural textures or probe for instance.
  99809. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99810. */
  99811. invertRefractionY: boolean;
  99812. /**
  99813. * Defines the alpha limits in alpha test mode.
  99814. */
  99815. alphaCutOff: number;
  99816. private _useLightmapAsShadowmap;
  99817. /**
  99818. * In case of light mapping, define whether the map contains light or shadow informations.
  99819. */
  99820. useLightmapAsShadowmap: boolean;
  99821. private _diffuseFresnelParameters;
  99822. /**
  99823. * Define the diffuse fresnel parameters of the material.
  99824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99825. */
  99826. diffuseFresnelParameters: FresnelParameters;
  99827. private _opacityFresnelParameters;
  99828. /**
  99829. * Define the opacity fresnel parameters of the material.
  99830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99831. */
  99832. opacityFresnelParameters: FresnelParameters;
  99833. private _reflectionFresnelParameters;
  99834. /**
  99835. * Define the reflection fresnel parameters of the material.
  99836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99837. */
  99838. reflectionFresnelParameters: FresnelParameters;
  99839. private _refractionFresnelParameters;
  99840. /**
  99841. * Define the refraction fresnel parameters of the material.
  99842. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99843. */
  99844. refractionFresnelParameters: FresnelParameters;
  99845. private _emissiveFresnelParameters;
  99846. /**
  99847. * Define the emissive fresnel parameters of the material.
  99848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99849. */
  99850. emissiveFresnelParameters: FresnelParameters;
  99851. private _useReflectionFresnelFromSpecular;
  99852. /**
  99853. * If true automatically deducts the fresnels values from the material specularity.
  99854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99855. */
  99856. useReflectionFresnelFromSpecular: boolean;
  99857. private _useGlossinessFromSpecularMapAlpha;
  99858. /**
  99859. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99860. */
  99861. useGlossinessFromSpecularMapAlpha: boolean;
  99862. private _maxSimultaneousLights;
  99863. /**
  99864. * Defines the maximum number of lights that can be used in the material
  99865. */
  99866. maxSimultaneousLights: number;
  99867. private _invertNormalMapX;
  99868. /**
  99869. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99870. */
  99871. invertNormalMapX: boolean;
  99872. private _invertNormalMapY;
  99873. /**
  99874. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99875. */
  99876. invertNormalMapY: boolean;
  99877. private _twoSidedLighting;
  99878. /**
  99879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99880. */
  99881. twoSidedLighting: boolean;
  99882. /**
  99883. * Default configuration related to image processing available in the standard Material.
  99884. */
  99885. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99886. /**
  99887. * Gets the image processing configuration used either in this material.
  99888. */
  99889. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99890. /**
  99891. * Sets the Default image processing configuration used either in the this material.
  99892. *
  99893. * If sets to null, the scene one is in use.
  99894. */
  99895. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99896. /**
  99897. * Keep track of the image processing observer to allow dispose and replace.
  99898. */
  99899. private _imageProcessingObserver;
  99900. /**
  99901. * Attaches a new image processing configuration to the Standard Material.
  99902. * @param configuration
  99903. */
  99904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99905. /**
  99906. * Gets wether the color curves effect is enabled.
  99907. */
  99908. get cameraColorCurvesEnabled(): boolean;
  99909. /**
  99910. * Sets wether the color curves effect is enabled.
  99911. */
  99912. set cameraColorCurvesEnabled(value: boolean);
  99913. /**
  99914. * Gets wether the color grading effect is enabled.
  99915. */
  99916. get cameraColorGradingEnabled(): boolean;
  99917. /**
  99918. * Gets wether the color grading effect is enabled.
  99919. */
  99920. set cameraColorGradingEnabled(value: boolean);
  99921. /**
  99922. * Gets wether tonemapping is enabled or not.
  99923. */
  99924. get cameraToneMappingEnabled(): boolean;
  99925. /**
  99926. * Sets wether tonemapping is enabled or not
  99927. */
  99928. set cameraToneMappingEnabled(value: boolean);
  99929. /**
  99930. * The camera exposure used on this material.
  99931. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99932. * This corresponds to a photographic exposure.
  99933. */
  99934. get cameraExposure(): number;
  99935. /**
  99936. * The camera exposure used on this material.
  99937. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99938. * This corresponds to a photographic exposure.
  99939. */
  99940. set cameraExposure(value: number);
  99941. /**
  99942. * Gets The camera contrast used on this material.
  99943. */
  99944. get cameraContrast(): number;
  99945. /**
  99946. * Sets The camera contrast used on this material.
  99947. */
  99948. set cameraContrast(value: number);
  99949. /**
  99950. * Gets the Color Grading 2D Lookup Texture.
  99951. */
  99952. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99953. /**
  99954. * Sets the Color Grading 2D Lookup Texture.
  99955. */
  99956. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99957. /**
  99958. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99959. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99960. * 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;
  99961. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99962. */
  99963. get cameraColorCurves(): Nullable<ColorCurves>;
  99964. /**
  99965. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99966. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99967. * 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;
  99968. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99969. */
  99970. set cameraColorCurves(value: Nullable<ColorCurves>);
  99971. /**
  99972. * Custom callback helping to override the default shader used in the material.
  99973. */
  99974. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99975. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99976. protected _worldViewProjectionMatrix: Matrix;
  99977. protected _globalAmbientColor: Color3;
  99978. protected _useLogarithmicDepth: boolean;
  99979. protected _rebuildInParallel: boolean;
  99980. /**
  99981. * Instantiates a new standard material.
  99982. * This is the default material used in Babylon. It is the best trade off between quality
  99983. * and performances.
  99984. * @see http://doc.babylonjs.com/babylon101/materials
  99985. * @param name Define the name of the material in the scene
  99986. * @param scene Define the scene the material belong to
  99987. */
  99988. constructor(name: string, scene: Scene);
  99989. /**
  99990. * Gets a boolean indicating that current material needs to register RTT
  99991. */
  99992. get hasRenderTargetTextures(): boolean;
  99993. /**
  99994. * Gets the current class name of the material e.g. "StandardMaterial"
  99995. * Mainly use in serialization.
  99996. * @returns the class name
  99997. */
  99998. getClassName(): string;
  99999. /**
  100000. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100001. * You can try switching to logarithmic depth.
  100002. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100003. */
  100004. get useLogarithmicDepth(): boolean;
  100005. set useLogarithmicDepth(value: boolean);
  100006. /**
  100007. * Specifies if the material will require alpha blending
  100008. * @returns a boolean specifying if alpha blending is needed
  100009. */
  100010. needAlphaBlending(): boolean;
  100011. /**
  100012. * Specifies if this material should be rendered in alpha test mode
  100013. * @returns a boolean specifying if an alpha test is needed.
  100014. */
  100015. needAlphaTesting(): boolean;
  100016. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100017. /**
  100018. * Get the texture used for alpha test purpose.
  100019. * @returns the diffuse texture in case of the standard material.
  100020. */
  100021. getAlphaTestTexture(): Nullable<BaseTexture>;
  100022. /**
  100023. * Get if the submesh is ready to be used and all its information available.
  100024. * Child classes can use it to update shaders
  100025. * @param mesh defines the mesh to check
  100026. * @param subMesh defines which submesh to check
  100027. * @param useInstances specifies that instances should be used
  100028. * @returns a boolean indicating that the submesh is ready or not
  100029. */
  100030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100031. /**
  100032. * Builds the material UBO layouts.
  100033. * Used internally during the effect preparation.
  100034. */
  100035. buildUniformLayout(): void;
  100036. /**
  100037. * Unbinds the material from the mesh
  100038. */
  100039. unbind(): void;
  100040. /**
  100041. * Binds the submesh to this material by preparing the effect and shader to draw
  100042. * @param world defines the world transformation matrix
  100043. * @param mesh defines the mesh containing the submesh
  100044. * @param subMesh defines the submesh to bind the material to
  100045. */
  100046. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100047. /**
  100048. * Get the list of animatables in the material.
  100049. * @returns the list of animatables object used in the material
  100050. */
  100051. getAnimatables(): IAnimatable[];
  100052. /**
  100053. * Gets the active textures from the material
  100054. * @returns an array of textures
  100055. */
  100056. getActiveTextures(): BaseTexture[];
  100057. /**
  100058. * Specifies if the material uses a texture
  100059. * @param texture defines the texture to check against the material
  100060. * @returns a boolean specifying if the material uses the texture
  100061. */
  100062. hasTexture(texture: BaseTexture): boolean;
  100063. /**
  100064. * Disposes the material
  100065. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100066. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100067. */
  100068. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100069. /**
  100070. * Makes a duplicate of the material, and gives it a new name
  100071. * @param name defines the new name for the duplicated material
  100072. * @returns the cloned material
  100073. */
  100074. clone(name: string): StandardMaterial;
  100075. /**
  100076. * Serializes this material in a JSON representation
  100077. * @returns the serialized material object
  100078. */
  100079. serialize(): any;
  100080. /**
  100081. * Creates a standard material from parsed material data
  100082. * @param source defines the JSON representation of the material
  100083. * @param scene defines the hosting scene
  100084. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100085. * @returns a new standard material
  100086. */
  100087. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100088. /**
  100089. * Are diffuse textures enabled in the application.
  100090. */
  100091. static get DiffuseTextureEnabled(): boolean;
  100092. static set DiffuseTextureEnabled(value: boolean);
  100093. /**
  100094. * Are ambient textures enabled in the application.
  100095. */
  100096. static get AmbientTextureEnabled(): boolean;
  100097. static set AmbientTextureEnabled(value: boolean);
  100098. /**
  100099. * Are opacity textures enabled in the application.
  100100. */
  100101. static get OpacityTextureEnabled(): boolean;
  100102. static set OpacityTextureEnabled(value: boolean);
  100103. /**
  100104. * Are reflection textures enabled in the application.
  100105. */
  100106. static get ReflectionTextureEnabled(): boolean;
  100107. static set ReflectionTextureEnabled(value: boolean);
  100108. /**
  100109. * Are emissive textures enabled in the application.
  100110. */
  100111. static get EmissiveTextureEnabled(): boolean;
  100112. static set EmissiveTextureEnabled(value: boolean);
  100113. /**
  100114. * Are specular textures enabled in the application.
  100115. */
  100116. static get SpecularTextureEnabled(): boolean;
  100117. static set SpecularTextureEnabled(value: boolean);
  100118. /**
  100119. * Are bump textures enabled in the application.
  100120. */
  100121. static get BumpTextureEnabled(): boolean;
  100122. static set BumpTextureEnabled(value: boolean);
  100123. /**
  100124. * Are lightmap textures enabled in the application.
  100125. */
  100126. static get LightmapTextureEnabled(): boolean;
  100127. static set LightmapTextureEnabled(value: boolean);
  100128. /**
  100129. * Are refraction textures enabled in the application.
  100130. */
  100131. static get RefractionTextureEnabled(): boolean;
  100132. static set RefractionTextureEnabled(value: boolean);
  100133. /**
  100134. * Are color grading textures enabled in the application.
  100135. */
  100136. static get ColorGradingTextureEnabled(): boolean;
  100137. static set ColorGradingTextureEnabled(value: boolean);
  100138. /**
  100139. * Are fresnels enabled in the application.
  100140. */
  100141. static get FresnelEnabled(): boolean;
  100142. static set FresnelEnabled(value: boolean);
  100143. }
  100144. }
  100145. declare module BABYLON {
  100146. /**
  100147. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100148. *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.
  100149. * The SPS is also a particle system. It provides some methods to manage the particles.
  100150. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100151. *
  100152. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100153. */
  100154. export class SolidParticleSystem implements IDisposable {
  100155. /**
  100156. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100157. * Example : var p = SPS.particles[i];
  100158. */
  100159. particles: SolidParticle[];
  100160. /**
  100161. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100162. */
  100163. nbParticles: number;
  100164. /**
  100165. * If the particles must ever face the camera (default false). Useful for planar particles.
  100166. */
  100167. billboard: boolean;
  100168. /**
  100169. * Recompute normals when adding a shape
  100170. */
  100171. recomputeNormals: boolean;
  100172. /**
  100173. * This a counter ofr your own usage. It's not set by any SPS functions.
  100174. */
  100175. counter: number;
  100176. /**
  100177. * The SPS name. This name is also given to the underlying mesh.
  100178. */
  100179. name: string;
  100180. /**
  100181. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100182. */
  100183. mesh: Mesh;
  100184. /**
  100185. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100186. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100187. */
  100188. vars: any;
  100189. /**
  100190. * This array is populated when the SPS is set as 'pickable'.
  100191. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100192. * Each element of this array is an object `{idx: int, faceId: int}`.
  100193. * `idx` is the picked particle index in the `SPS.particles` array
  100194. * `faceId` is the picked face index counted within this particle.
  100195. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100196. */
  100197. pickedParticles: {
  100198. idx: number;
  100199. faceId: number;
  100200. }[];
  100201. /**
  100202. * This array is populated when `enableDepthSort` is set to true.
  100203. * Each element of this array is an instance of the class DepthSortedParticle.
  100204. */
  100205. depthSortedParticles: DepthSortedParticle[];
  100206. /**
  100207. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100208. * @hidden
  100209. */
  100210. _bSphereOnly: boolean;
  100211. /**
  100212. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100213. * @hidden
  100214. */
  100215. _bSphereRadiusFactor: number;
  100216. private _scene;
  100217. private _positions;
  100218. private _indices;
  100219. private _normals;
  100220. private _colors;
  100221. private _uvs;
  100222. private _indices32;
  100223. private _positions32;
  100224. private _normals32;
  100225. private _fixedNormal32;
  100226. private _colors32;
  100227. private _uvs32;
  100228. private _index;
  100229. private _updatable;
  100230. private _pickable;
  100231. private _isVisibilityBoxLocked;
  100232. private _alwaysVisible;
  100233. private _depthSort;
  100234. private _expandable;
  100235. private _shapeCounter;
  100236. private _copy;
  100237. private _color;
  100238. private _computeParticleColor;
  100239. private _computeParticleTexture;
  100240. private _computeParticleRotation;
  100241. private _computeParticleVertex;
  100242. private _computeBoundingBox;
  100243. private _depthSortParticles;
  100244. private _camera;
  100245. private _mustUnrotateFixedNormals;
  100246. private _particlesIntersect;
  100247. private _needs32Bits;
  100248. private _isNotBuilt;
  100249. private _lastParticleId;
  100250. private _idxOfId;
  100251. private _multimaterialEnabled;
  100252. private _useModelMaterial;
  100253. private _indicesByMaterial;
  100254. private _materialIndexes;
  100255. private _depthSortFunction;
  100256. private _materialSortFunction;
  100257. private _materials;
  100258. private _multimaterial;
  100259. private _materialIndexesById;
  100260. private _defaultMaterial;
  100261. private _autoUpdateSubMeshes;
  100262. /**
  100263. * Creates a SPS (Solid Particle System) object.
  100264. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100265. * @param scene (Scene) is the scene in which the SPS is added.
  100266. * @param options defines the options of the sps e.g.
  100267. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100268. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100269. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100270. * * 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.
  100271. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100272. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100273. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100274. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100275. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100276. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100277. */
  100278. constructor(name: string, scene: Scene, options?: {
  100279. updatable?: boolean;
  100280. isPickable?: boolean;
  100281. enableDepthSort?: boolean;
  100282. particleIntersection?: boolean;
  100283. boundingSphereOnly?: boolean;
  100284. bSphereRadiusFactor?: number;
  100285. expandable?: boolean;
  100286. useModelMaterial?: boolean;
  100287. enableMultiMaterial?: boolean;
  100288. });
  100289. /**
  100290. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100291. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100292. * @returns the created mesh
  100293. */
  100294. buildMesh(): Mesh;
  100295. /**
  100296. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100297. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100298. * Thus the particles generated from `digest()` have their property `position` set yet.
  100299. * @param mesh ( Mesh ) is the mesh to be digested
  100300. * @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
  100301. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100302. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100303. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100304. * @returns the current SPS
  100305. */
  100306. digest(mesh: Mesh, options?: {
  100307. facetNb?: number;
  100308. number?: number;
  100309. delta?: number;
  100310. storage?: [];
  100311. }): SolidParticleSystem;
  100312. /**
  100313. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100314. * @hidden
  100315. */
  100316. private _unrotateFixedNormals;
  100317. /**
  100318. * Resets the temporary working copy particle
  100319. * @hidden
  100320. */
  100321. private _resetCopy;
  100322. /**
  100323. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100324. * @param p the current index in the positions array to be updated
  100325. * @param ind the current index in the indices array
  100326. * @param shape a Vector3 array, the shape geometry
  100327. * @param positions the positions array to be updated
  100328. * @param meshInd the shape indices array
  100329. * @param indices the indices array to be updated
  100330. * @param meshUV the shape uv array
  100331. * @param uvs the uv array to be updated
  100332. * @param meshCol the shape color array
  100333. * @param colors the color array to be updated
  100334. * @param meshNor the shape normals array
  100335. * @param normals the normals array to be updated
  100336. * @param idx the particle index
  100337. * @param idxInShape the particle index in its shape
  100338. * @param options the addShape() method passed options
  100339. * @model the particle model
  100340. * @hidden
  100341. */
  100342. private _meshBuilder;
  100343. /**
  100344. * Returns a shape Vector3 array from positions float array
  100345. * @param positions float array
  100346. * @returns a vector3 array
  100347. * @hidden
  100348. */
  100349. private _posToShape;
  100350. /**
  100351. * Returns a shapeUV array from a float uvs (array deep copy)
  100352. * @param uvs as a float array
  100353. * @returns a shapeUV array
  100354. * @hidden
  100355. */
  100356. private _uvsToShapeUV;
  100357. /**
  100358. * Adds a new particle object in the particles array
  100359. * @param idx particle index in particles array
  100360. * @param id particle id
  100361. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100362. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100363. * @param model particle ModelShape object
  100364. * @param shapeId model shape identifier
  100365. * @param idxInShape index of the particle in the current model
  100366. * @param bInfo model bounding info object
  100367. * @param storage target storage array, if any
  100368. * @hidden
  100369. */
  100370. private _addParticle;
  100371. /**
  100372. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100373. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100374. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100375. * @param nb (positive integer) the number of particles to be created from this model
  100376. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100377. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100378. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100379. * @returns the number of shapes in the system
  100380. */
  100381. addShape(mesh: Mesh, nb: number, options?: {
  100382. positionFunction?: any;
  100383. vertexFunction?: any;
  100384. storage?: [];
  100385. }): number;
  100386. /**
  100387. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100388. * @hidden
  100389. */
  100390. private _rebuildParticle;
  100391. /**
  100392. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100393. * @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.
  100394. * @returns the SPS.
  100395. */
  100396. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100397. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100398. * Returns an array with the removed particles.
  100399. * 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.
  100400. * The SPS can't be empty so at least one particle needs to remain in place.
  100401. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100402. * @param start index of the first particle to remove
  100403. * @param end index of the last particle to remove (included)
  100404. * @returns an array populated with the removed particles
  100405. */
  100406. removeParticles(start: number, end: number): SolidParticle[];
  100407. /**
  100408. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100409. * @param solidParticleArray an array populated with Solid Particles objects
  100410. * @returns the SPS
  100411. */
  100412. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100413. /**
  100414. * Creates a new particle and modifies the SPS mesh geometry :
  100415. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100416. * - calls _addParticle() to populate the particle array
  100417. * factorized code from addShape() and insertParticlesFromArray()
  100418. * @param idx particle index in the particles array
  100419. * @param i particle index in its shape
  100420. * @param modelShape particle ModelShape object
  100421. * @param shape shape vertex array
  100422. * @param meshInd shape indices array
  100423. * @param meshUV shape uv array
  100424. * @param meshCol shape color array
  100425. * @param meshNor shape normals array
  100426. * @param bbInfo shape bounding info
  100427. * @param storage target particle storage
  100428. * @options addShape() passed options
  100429. * @hidden
  100430. */
  100431. private _insertNewParticle;
  100432. /**
  100433. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100434. * This method calls `updateParticle()` for each particle of the SPS.
  100435. * For an animated SPS, it is usually called within the render loop.
  100436. * 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.
  100437. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100438. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100439. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100440. * @returns the SPS.
  100441. */
  100442. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100443. /**
  100444. * Disposes the SPS.
  100445. */
  100446. dispose(): void;
  100447. /**
  100448. * Returns a SolidParticle object from its identifier : particle.id
  100449. * @param id (integer) the particle Id
  100450. * @returns the searched particle or null if not found in the SPS.
  100451. */
  100452. getParticleById(id: number): Nullable<SolidParticle>;
  100453. /**
  100454. * Returns a new array populated with the particles having the passed shapeId.
  100455. * @param shapeId (integer) the shape identifier
  100456. * @returns a new solid particle array
  100457. */
  100458. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100459. /**
  100460. * Populates the passed array "ref" with the particles having the passed shapeId.
  100461. * @param shapeId the shape identifier
  100462. * @returns the SPS
  100463. * @param ref
  100464. */
  100465. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100466. /**
  100467. * Computes the required SubMeshes according the materials assigned to the particles.
  100468. * @returns the solid particle system.
  100469. * Does nothing if called before the SPS mesh is built.
  100470. */
  100471. computeSubMeshes(): SolidParticleSystem;
  100472. /**
  100473. * Sorts the solid particles by material when MultiMaterial is enabled.
  100474. * Updates the indices32 array.
  100475. * Updates the indicesByMaterial array.
  100476. * Updates the mesh indices array.
  100477. * @returns the SPS
  100478. * @hidden
  100479. */
  100480. private _sortParticlesByMaterial;
  100481. /**
  100482. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100483. * @hidden
  100484. */
  100485. private _setMaterialIndexesById;
  100486. /**
  100487. * Returns an array with unique values of Materials from the passed array
  100488. * @param array the material array to be checked and filtered
  100489. * @hidden
  100490. */
  100491. private _filterUniqueMaterialId;
  100492. /**
  100493. * Sets a new Standard Material as _defaultMaterial if not already set.
  100494. * @hidden
  100495. */
  100496. private _setDefaultMaterial;
  100497. /**
  100498. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100499. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100500. * @returns the SPS.
  100501. */
  100502. refreshVisibleSize(): SolidParticleSystem;
  100503. /**
  100504. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100505. * @param size the size (float) of the visibility box
  100506. * note : this doesn't lock the SPS mesh bounding box.
  100507. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100508. */
  100509. setVisibilityBox(size: number): void;
  100510. /**
  100511. * Gets whether the SPS as always visible or not
  100512. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100513. */
  100514. get isAlwaysVisible(): boolean;
  100515. /**
  100516. * Sets the SPS as always visible or not
  100517. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100518. */
  100519. set isAlwaysVisible(val: boolean);
  100520. /**
  100521. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100522. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100523. */
  100524. set isVisibilityBoxLocked(val: boolean);
  100525. /**
  100526. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100527. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100528. */
  100529. get isVisibilityBoxLocked(): boolean;
  100530. /**
  100531. * Tells to `setParticles()` to compute the particle rotations or not.
  100532. * Default value : true. The SPS is faster when it's set to false.
  100533. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100534. */
  100535. set computeParticleRotation(val: boolean);
  100536. /**
  100537. * Tells to `setParticles()` to compute the particle colors or not.
  100538. * Default value : true. The SPS is faster when it's set to false.
  100539. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100540. */
  100541. set computeParticleColor(val: boolean);
  100542. set computeParticleTexture(val: boolean);
  100543. /**
  100544. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100545. * Default value : false. The SPS is faster when it's set to false.
  100546. * Note : the particle custom vertex positions aren't stored values.
  100547. */
  100548. set computeParticleVertex(val: boolean);
  100549. /**
  100550. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100551. */
  100552. set computeBoundingBox(val: boolean);
  100553. /**
  100554. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100555. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100556. * Default : `true`
  100557. */
  100558. set depthSortParticles(val: boolean);
  100559. /**
  100560. * Gets if `setParticles()` computes the particle rotations or not.
  100561. * Default value : true. The SPS is faster when it's set to false.
  100562. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100563. */
  100564. get computeParticleRotation(): boolean;
  100565. /**
  100566. * Gets if `setParticles()` computes the particle colors or not.
  100567. * Default value : true. The SPS is faster when it's set to false.
  100568. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100569. */
  100570. get computeParticleColor(): boolean;
  100571. /**
  100572. * Gets if `setParticles()` computes the particle textures or not.
  100573. * Default value : true. The SPS is faster when it's set to false.
  100574. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100575. */
  100576. get computeParticleTexture(): boolean;
  100577. /**
  100578. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100579. * Default value : false. The SPS is faster when it's set to false.
  100580. * Note : the particle custom vertex positions aren't stored values.
  100581. */
  100582. get computeParticleVertex(): boolean;
  100583. /**
  100584. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100585. */
  100586. get computeBoundingBox(): boolean;
  100587. /**
  100588. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100589. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100590. * Default : `true`
  100591. */
  100592. get depthSortParticles(): boolean;
  100593. /**
  100594. * Gets if the SPS is created as expandable at construction time.
  100595. * Default : `false`
  100596. */
  100597. get expandable(): boolean;
  100598. /**
  100599. * Gets if the SPS supports the Multi Materials
  100600. */
  100601. get multimaterialEnabled(): boolean;
  100602. /**
  100603. * Gets if the SPS uses the model materials for its own multimaterial.
  100604. */
  100605. get useModelMaterial(): boolean;
  100606. /**
  100607. * The SPS used material array.
  100608. */
  100609. get materials(): Material[];
  100610. /**
  100611. * Sets the SPS MultiMaterial from the passed materials.
  100612. * Note : the passed array is internally copied and not used then by reference.
  100613. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100614. */
  100615. setMultiMaterial(materials: Material[]): void;
  100616. /**
  100617. * The SPS computed multimaterial object
  100618. */
  100619. get multimaterial(): MultiMaterial;
  100620. set multimaterial(mm: MultiMaterial);
  100621. /**
  100622. * If the subMeshes must be updated on the next call to setParticles()
  100623. */
  100624. get autoUpdateSubMeshes(): boolean;
  100625. set autoUpdateSubMeshes(val: boolean);
  100626. /**
  100627. * This function does nothing. It may be overwritten to set all the particle first values.
  100628. * The SPS doesn't call this function, you may have to call it by your own.
  100629. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100630. */
  100631. initParticles(): void;
  100632. /**
  100633. * This function does nothing. It may be overwritten to recycle a particle.
  100634. * The SPS doesn't call this function, you may have to call it by your own.
  100635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100636. * @param particle The particle to recycle
  100637. * @returns the recycled particle
  100638. */
  100639. recycleParticle(particle: SolidParticle): SolidParticle;
  100640. /**
  100641. * Updates a particle : this function should be overwritten by the user.
  100642. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100644. * @example : just set a particle position or velocity and recycle conditions
  100645. * @param particle The particle to update
  100646. * @returns the updated particle
  100647. */
  100648. updateParticle(particle: SolidParticle): SolidParticle;
  100649. /**
  100650. * Updates a vertex of a particle : it can be overwritten by the user.
  100651. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100652. * @param particle the current particle
  100653. * @param vertex the current index of the current particle
  100654. * @param pt the index of the current vertex in the particle shape
  100655. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100656. * @example : just set a vertex particle position
  100657. * @returns the updated vertex
  100658. */
  100659. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100660. /**
  100661. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100662. * This does nothing and may be overwritten by the user.
  100663. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100665. * @param update the boolean update value actually passed to setParticles()
  100666. */
  100667. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100668. /**
  100669. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100670. * This will be passed three parameters.
  100671. * This does nothing and may be overwritten by the user.
  100672. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100674. * @param update the boolean update value actually passed to setParticles()
  100675. */
  100676. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100677. }
  100678. }
  100679. declare module BABYLON {
  100680. /**
  100681. * Represents one particle of a solid particle system.
  100682. */
  100683. export class SolidParticle {
  100684. /**
  100685. * particle global index
  100686. */
  100687. idx: number;
  100688. /**
  100689. * particle identifier
  100690. */
  100691. id: number;
  100692. /**
  100693. * The color of the particle
  100694. */
  100695. color: Nullable<Color4>;
  100696. /**
  100697. * The world space position of the particle.
  100698. */
  100699. position: Vector3;
  100700. /**
  100701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100702. */
  100703. rotation: Vector3;
  100704. /**
  100705. * The world space rotation quaternion of the particle.
  100706. */
  100707. rotationQuaternion: Nullable<Quaternion>;
  100708. /**
  100709. * The scaling of the particle.
  100710. */
  100711. scaling: Vector3;
  100712. /**
  100713. * The uvs of the particle.
  100714. */
  100715. uvs: Vector4;
  100716. /**
  100717. * The current speed of the particle.
  100718. */
  100719. velocity: Vector3;
  100720. /**
  100721. * The pivot point in the particle local space.
  100722. */
  100723. pivot: Vector3;
  100724. /**
  100725. * Must the particle be translated from its pivot point in its local space ?
  100726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100727. * Default : false
  100728. */
  100729. translateFromPivot: boolean;
  100730. /**
  100731. * Is the particle active or not ?
  100732. */
  100733. alive: boolean;
  100734. /**
  100735. * Is the particle visible or not ?
  100736. */
  100737. isVisible: boolean;
  100738. /**
  100739. * Index of this particle in the global "positions" array (Internal use)
  100740. * @hidden
  100741. */
  100742. _pos: number;
  100743. /**
  100744. * @hidden Index of this particle in the global "indices" array (Internal use)
  100745. */
  100746. _ind: number;
  100747. /**
  100748. * @hidden ModelShape of this particle (Internal use)
  100749. */
  100750. _model: ModelShape;
  100751. /**
  100752. * ModelShape id of this particle
  100753. */
  100754. shapeId: number;
  100755. /**
  100756. * Index of the particle in its shape id
  100757. */
  100758. idxInShape: number;
  100759. /**
  100760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100761. */
  100762. _modelBoundingInfo: BoundingInfo;
  100763. /**
  100764. * @hidden Particle BoundingInfo object (Internal use)
  100765. */
  100766. _boundingInfo: BoundingInfo;
  100767. /**
  100768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100769. */
  100770. _sps: SolidParticleSystem;
  100771. /**
  100772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100773. */
  100774. _stillInvisible: boolean;
  100775. /**
  100776. * @hidden Last computed particle rotation matrix
  100777. */
  100778. _rotationMatrix: number[];
  100779. /**
  100780. * Parent particle Id, if any.
  100781. * Default null.
  100782. */
  100783. parentId: Nullable<number>;
  100784. /**
  100785. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100786. */
  100787. materialIndex: Nullable<number>;
  100788. /**
  100789. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100790. * The possible values are :
  100791. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100792. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100793. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100794. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100795. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100796. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100797. * */
  100798. cullingStrategy: number;
  100799. /**
  100800. * @hidden Internal global position in the SPS.
  100801. */
  100802. _globalPosition: Vector3;
  100803. /**
  100804. * Creates a Solid Particle object.
  100805. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100806. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100807. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100808. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100809. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100810. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100811. * @param shapeId (integer) is the model shape identifier in the SPS.
  100812. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100813. * @param sps defines the sps it is associated to
  100814. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100815. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100816. */
  100817. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100818. /**
  100819. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100820. * @param target the particle target
  100821. * @returns the current particle
  100822. */
  100823. copyToRef(target: SolidParticle): SolidParticle;
  100824. /**
  100825. * Legacy support, changed scale to scaling
  100826. */
  100827. get scale(): Vector3;
  100828. /**
  100829. * Legacy support, changed scale to scaling
  100830. */
  100831. set scale(scale: Vector3);
  100832. /**
  100833. * Legacy support, changed quaternion to rotationQuaternion
  100834. */
  100835. get quaternion(): Nullable<Quaternion>;
  100836. /**
  100837. * Legacy support, changed quaternion to rotationQuaternion
  100838. */
  100839. set quaternion(q: Nullable<Quaternion>);
  100840. /**
  100841. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100842. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100843. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100844. * @returns true if it intersects
  100845. */
  100846. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100847. /**
  100848. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100849. * A particle is in the frustum if its bounding box intersects the frustum
  100850. * @param frustumPlanes defines the frustum to test
  100851. * @returns true if the particle is in the frustum planes
  100852. */
  100853. isInFrustum(frustumPlanes: Plane[]): boolean;
  100854. /**
  100855. * get the rotation matrix of the particle
  100856. * @hidden
  100857. */
  100858. getRotationMatrix(m: Matrix): void;
  100859. }
  100860. /**
  100861. * Represents the shape of the model used by one particle of a solid particle system.
  100862. * SPS internal tool, don't use it manually.
  100863. */
  100864. export class ModelShape {
  100865. /**
  100866. * The shape id
  100867. * @hidden
  100868. */
  100869. shapeID: number;
  100870. /**
  100871. * flat array of model positions (internal use)
  100872. * @hidden
  100873. */
  100874. _shape: Vector3[];
  100875. /**
  100876. * flat array of model UVs (internal use)
  100877. * @hidden
  100878. */
  100879. _shapeUV: number[];
  100880. /**
  100881. * color array of the model
  100882. * @hidden
  100883. */
  100884. _shapeColors: number[];
  100885. /**
  100886. * indices array of the model
  100887. * @hidden
  100888. */
  100889. _indices: number[];
  100890. /**
  100891. * normals array of the model
  100892. * @hidden
  100893. */
  100894. _normals: number[];
  100895. /**
  100896. * length of the shape in the model indices array (internal use)
  100897. * @hidden
  100898. */
  100899. _indicesLength: number;
  100900. /**
  100901. * Custom position function (internal use)
  100902. * @hidden
  100903. */
  100904. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100905. /**
  100906. * Custom vertex function (internal use)
  100907. * @hidden
  100908. */
  100909. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100910. /**
  100911. * Model material (internal use)
  100912. * @hidden
  100913. */
  100914. _material: Nullable<Material>;
  100915. /**
  100916. * 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.
  100917. * SPS internal tool, don't use it manually.
  100918. * @hidden
  100919. */
  100920. 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>);
  100921. }
  100922. /**
  100923. * Represents a Depth Sorted Particle in the solid particle system.
  100924. * @hidden
  100925. */
  100926. export class DepthSortedParticle {
  100927. /**
  100928. * Index of the particle in the "indices" array
  100929. */
  100930. ind: number;
  100931. /**
  100932. * Length of the particle shape in the "indices" array
  100933. */
  100934. indicesLength: number;
  100935. /**
  100936. * Squared distance from the particle to the camera
  100937. */
  100938. sqDistance: number;
  100939. /**
  100940. * Material index when used with MultiMaterials
  100941. */
  100942. materialIndex: number;
  100943. /**
  100944. * Creates a new sorted particle
  100945. * @param materialIndex
  100946. */
  100947. constructor(ind: number, indLength: number, materialIndex: number);
  100948. }
  100949. }
  100950. declare module BABYLON {
  100951. /**
  100952. * @hidden
  100953. */
  100954. export class _MeshCollisionData {
  100955. _checkCollisions: boolean;
  100956. _collisionMask: number;
  100957. _collisionGroup: number;
  100958. _collider: Nullable<Collider>;
  100959. _oldPositionForCollisions: Vector3;
  100960. _diffPositionForCollisions: Vector3;
  100961. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100962. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100963. }
  100964. }
  100965. declare module BABYLON {
  100966. /** @hidden */
  100967. class _FacetDataStorage {
  100968. facetPositions: Vector3[];
  100969. facetNormals: Vector3[];
  100970. facetPartitioning: number[][];
  100971. facetNb: number;
  100972. partitioningSubdivisions: number;
  100973. partitioningBBoxRatio: number;
  100974. facetDataEnabled: boolean;
  100975. facetParameters: any;
  100976. bbSize: Vector3;
  100977. subDiv: {
  100978. max: number;
  100979. X: number;
  100980. Y: number;
  100981. Z: number;
  100982. };
  100983. facetDepthSort: boolean;
  100984. facetDepthSortEnabled: boolean;
  100985. depthSortedIndices: IndicesArray;
  100986. depthSortedFacets: {
  100987. ind: number;
  100988. sqDistance: number;
  100989. }[];
  100990. facetDepthSortFunction: (f1: {
  100991. ind: number;
  100992. sqDistance: number;
  100993. }, f2: {
  100994. ind: number;
  100995. sqDistance: number;
  100996. }) => number;
  100997. facetDepthSortFrom: Vector3;
  100998. facetDepthSortOrigin: Vector3;
  100999. invertedMatrix: Matrix;
  101000. }
  101001. /**
  101002. * @hidden
  101003. **/
  101004. class _InternalAbstractMeshDataInfo {
  101005. _hasVertexAlpha: boolean;
  101006. _useVertexColors: boolean;
  101007. _numBoneInfluencers: number;
  101008. _applyFog: boolean;
  101009. _receiveShadows: boolean;
  101010. _facetData: _FacetDataStorage;
  101011. _visibility: number;
  101012. _skeleton: Nullable<Skeleton>;
  101013. _layerMask: number;
  101014. _computeBonesUsingShaders: boolean;
  101015. _isActive: boolean;
  101016. _onlyForInstances: boolean;
  101017. _isActiveIntermediate: boolean;
  101018. _onlyForInstancesIntermediate: boolean;
  101019. _actAsRegularMesh: boolean;
  101020. }
  101021. /**
  101022. * Class used to store all common mesh properties
  101023. */
  101024. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101025. /** No occlusion */
  101026. static OCCLUSION_TYPE_NONE: number;
  101027. /** Occlusion set to optimisitic */
  101028. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101029. /** Occlusion set to strict */
  101030. static OCCLUSION_TYPE_STRICT: number;
  101031. /** Use an accurante occlusion algorithm */
  101032. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101033. /** Use a conservative occlusion algorithm */
  101034. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101035. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101036. * Test order :
  101037. * Is the bounding sphere outside the frustum ?
  101038. * If not, are the bounding box vertices outside the frustum ?
  101039. * It not, then the cullable object is in the frustum.
  101040. */
  101041. static readonly CULLINGSTRATEGY_STANDARD: number;
  101042. /** Culling strategy : Bounding Sphere Only.
  101043. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101044. * It's also less accurate than the standard because some not visible objects can still be selected.
  101045. * Test : is the bounding sphere outside the frustum ?
  101046. * If not, then the cullable object is in the frustum.
  101047. */
  101048. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101049. /** Culling strategy : Optimistic Inclusion.
  101050. * This in an inclusion test first, then the standard exclusion test.
  101051. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101052. * 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.
  101053. * Anyway, it's as accurate as the standard strategy.
  101054. * Test :
  101055. * Is the cullable object bounding sphere center in the frustum ?
  101056. * If not, apply the default culling strategy.
  101057. */
  101058. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101059. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101060. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101061. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101062. * 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.
  101063. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101064. * Test :
  101065. * Is the cullable object bounding sphere center in the frustum ?
  101066. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101067. */
  101068. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101069. /**
  101070. * No billboard
  101071. */
  101072. static get BILLBOARDMODE_NONE(): number;
  101073. /** Billboard on X axis */
  101074. static get BILLBOARDMODE_X(): number;
  101075. /** Billboard on Y axis */
  101076. static get BILLBOARDMODE_Y(): number;
  101077. /** Billboard on Z axis */
  101078. static get BILLBOARDMODE_Z(): number;
  101079. /** Billboard on all axes */
  101080. static get BILLBOARDMODE_ALL(): number;
  101081. /** Billboard on using position instead of orientation */
  101082. static get BILLBOARDMODE_USE_POSITION(): number;
  101083. /** @hidden */
  101084. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101085. /**
  101086. * The culling strategy to use to check whether the mesh must be rendered or not.
  101087. * This value can be changed at any time and will be used on the next render mesh selection.
  101088. * The possible values are :
  101089. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101090. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101091. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101092. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101093. * Please read each static variable documentation to get details about the culling process.
  101094. * */
  101095. cullingStrategy: number;
  101096. /**
  101097. * Gets the number of facets in the mesh
  101098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101099. */
  101100. get facetNb(): number;
  101101. /**
  101102. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101104. */
  101105. get partitioningSubdivisions(): number;
  101106. set partitioningSubdivisions(nb: number);
  101107. /**
  101108. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101109. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101111. */
  101112. get partitioningBBoxRatio(): number;
  101113. set partitioningBBoxRatio(ratio: number);
  101114. /**
  101115. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101116. * Works only for updatable meshes.
  101117. * Doesn't work with multi-materials
  101118. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101119. */
  101120. get mustDepthSortFacets(): boolean;
  101121. set mustDepthSortFacets(sort: boolean);
  101122. /**
  101123. * The location (Vector3) where the facet depth sort must be computed from.
  101124. * By default, the active camera position.
  101125. * Used only when facet depth sort is enabled
  101126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101127. */
  101128. get facetDepthSortFrom(): Vector3;
  101129. set facetDepthSortFrom(location: Vector3);
  101130. /**
  101131. * gets a boolean indicating if facetData is enabled
  101132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101133. */
  101134. get isFacetDataEnabled(): boolean;
  101135. /** @hidden */
  101136. _updateNonUniformScalingState(value: boolean): boolean;
  101137. /**
  101138. * An event triggered when this mesh collides with another one
  101139. */
  101140. onCollideObservable: Observable<AbstractMesh>;
  101141. /** Set a function to call when this mesh collides with another one */
  101142. set onCollide(callback: () => void);
  101143. /**
  101144. * An event triggered when the collision's position changes
  101145. */
  101146. onCollisionPositionChangeObservable: Observable<Vector3>;
  101147. /** Set a function to call when the collision's position changes */
  101148. set onCollisionPositionChange(callback: () => void);
  101149. /**
  101150. * An event triggered when material is changed
  101151. */
  101152. onMaterialChangedObservable: Observable<AbstractMesh>;
  101153. /**
  101154. * Gets or sets the orientation for POV movement & rotation
  101155. */
  101156. definedFacingForward: boolean;
  101157. /** @hidden */
  101158. _occlusionQuery: Nullable<WebGLQuery>;
  101159. /** @hidden */
  101160. _renderingGroup: Nullable<RenderingGroup>;
  101161. /**
  101162. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101163. */
  101164. get visibility(): number;
  101165. /**
  101166. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101167. */
  101168. set visibility(value: number);
  101169. /** Gets or sets the alpha index used to sort transparent meshes
  101170. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101171. */
  101172. alphaIndex: number;
  101173. /**
  101174. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101175. */
  101176. isVisible: boolean;
  101177. /**
  101178. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101179. */
  101180. isPickable: boolean;
  101181. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101182. showSubMeshesBoundingBox: boolean;
  101183. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101184. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101185. */
  101186. isBlocker: boolean;
  101187. /**
  101188. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101189. */
  101190. enablePointerMoveEvents: boolean;
  101191. /**
  101192. * Specifies the rendering group id for this mesh (0 by default)
  101193. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101194. */
  101195. renderingGroupId: number;
  101196. private _material;
  101197. /** Gets or sets current material */
  101198. get material(): Nullable<Material>;
  101199. set material(value: Nullable<Material>);
  101200. /**
  101201. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101202. * @see http://doc.babylonjs.com/babylon101/shadows
  101203. */
  101204. get receiveShadows(): boolean;
  101205. set receiveShadows(value: boolean);
  101206. /** Defines color to use when rendering outline */
  101207. outlineColor: Color3;
  101208. /** Define width to use when rendering outline */
  101209. outlineWidth: number;
  101210. /** Defines color to use when rendering overlay */
  101211. overlayColor: Color3;
  101212. /** Defines alpha to use when rendering overlay */
  101213. overlayAlpha: number;
  101214. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101215. get hasVertexAlpha(): boolean;
  101216. set hasVertexAlpha(value: boolean);
  101217. /** 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) */
  101218. get useVertexColors(): boolean;
  101219. set useVertexColors(value: boolean);
  101220. /**
  101221. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101222. */
  101223. get computeBonesUsingShaders(): boolean;
  101224. set computeBonesUsingShaders(value: boolean);
  101225. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101226. get numBoneInfluencers(): number;
  101227. set numBoneInfluencers(value: number);
  101228. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101229. get applyFog(): boolean;
  101230. set applyFog(value: boolean);
  101231. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101232. useOctreeForRenderingSelection: boolean;
  101233. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101234. useOctreeForPicking: boolean;
  101235. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101236. useOctreeForCollisions: boolean;
  101237. /**
  101238. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101239. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101240. */
  101241. get layerMask(): number;
  101242. set layerMask(value: number);
  101243. /**
  101244. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101245. */
  101246. alwaysSelectAsActiveMesh: boolean;
  101247. /**
  101248. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101249. */
  101250. doNotSyncBoundingInfo: boolean;
  101251. /**
  101252. * Gets or sets the current action manager
  101253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101254. */
  101255. actionManager: Nullable<AbstractActionManager>;
  101256. private _meshCollisionData;
  101257. /**
  101258. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101259. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101260. */
  101261. ellipsoid: Vector3;
  101262. /**
  101263. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101264. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101265. */
  101266. ellipsoidOffset: Vector3;
  101267. /**
  101268. * Gets or sets a collision mask used to mask collisions (default is -1).
  101269. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101270. */
  101271. get collisionMask(): number;
  101272. set collisionMask(mask: number);
  101273. /**
  101274. * Gets or sets the current collision group mask (-1 by default).
  101275. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101276. */
  101277. get collisionGroup(): number;
  101278. set collisionGroup(mask: number);
  101279. /**
  101280. * Defines edge width used when edgesRenderer is enabled
  101281. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101282. */
  101283. edgesWidth: number;
  101284. /**
  101285. * Defines edge color used when edgesRenderer is enabled
  101286. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101287. */
  101288. edgesColor: Color4;
  101289. /** @hidden */
  101290. _edgesRenderer: Nullable<IEdgesRenderer>;
  101291. /** @hidden */
  101292. _masterMesh: Nullable<AbstractMesh>;
  101293. /** @hidden */
  101294. _boundingInfo: Nullable<BoundingInfo>;
  101295. /** @hidden */
  101296. _renderId: number;
  101297. /**
  101298. * Gets or sets the list of subMeshes
  101299. * @see http://doc.babylonjs.com/how_to/multi_materials
  101300. */
  101301. subMeshes: SubMesh[];
  101302. /** @hidden */
  101303. _intersectionsInProgress: AbstractMesh[];
  101304. /** @hidden */
  101305. _unIndexed: boolean;
  101306. /** @hidden */
  101307. _lightSources: Light[];
  101308. /** Gets the list of lights affecting that mesh */
  101309. get lightSources(): Light[];
  101310. /** @hidden */
  101311. get _positions(): Nullable<Vector3[]>;
  101312. /** @hidden */
  101313. _waitingData: {
  101314. lods: Nullable<any>;
  101315. actions: Nullable<any>;
  101316. freezeWorldMatrix: Nullable<boolean>;
  101317. };
  101318. /** @hidden */
  101319. _bonesTransformMatrices: Nullable<Float32Array>;
  101320. /** @hidden */
  101321. _transformMatrixTexture: Nullable<RawTexture>;
  101322. /**
  101323. * Gets or sets a skeleton to apply skining transformations
  101324. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101325. */
  101326. set skeleton(value: Nullable<Skeleton>);
  101327. get skeleton(): Nullable<Skeleton>;
  101328. /**
  101329. * An event triggered when the mesh is rebuilt.
  101330. */
  101331. onRebuildObservable: Observable<AbstractMesh>;
  101332. /**
  101333. * Creates a new AbstractMesh
  101334. * @param name defines the name of the mesh
  101335. * @param scene defines the hosting scene
  101336. */
  101337. constructor(name: string, scene?: Nullable<Scene>);
  101338. /**
  101339. * Returns the string "AbstractMesh"
  101340. * @returns "AbstractMesh"
  101341. */
  101342. getClassName(): string;
  101343. /**
  101344. * Gets a string representation of the current mesh
  101345. * @param fullDetails defines a boolean indicating if full details must be included
  101346. * @returns a string representation of the current mesh
  101347. */
  101348. toString(fullDetails?: boolean): string;
  101349. /**
  101350. * @hidden
  101351. */
  101352. protected _getEffectiveParent(): Nullable<Node>;
  101353. /** @hidden */
  101354. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101355. /** @hidden */
  101356. _rebuild(): void;
  101357. /** @hidden */
  101358. _resyncLightSources(): void;
  101359. /** @hidden */
  101360. _resyncLightSource(light: Light): void;
  101361. /** @hidden */
  101362. _unBindEffect(): void;
  101363. /** @hidden */
  101364. _removeLightSource(light: Light, dispose: boolean): void;
  101365. private _markSubMeshesAsDirty;
  101366. /** @hidden */
  101367. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101368. /** @hidden */
  101369. _markSubMeshesAsAttributesDirty(): void;
  101370. /** @hidden */
  101371. _markSubMeshesAsMiscDirty(): void;
  101372. /**
  101373. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101374. */
  101375. get scaling(): Vector3;
  101376. set scaling(newScaling: Vector3);
  101377. /**
  101378. * Returns true if the mesh is blocked. Implemented by child classes
  101379. */
  101380. get isBlocked(): boolean;
  101381. /**
  101382. * Returns the mesh itself by default. Implemented by child classes
  101383. * @param camera defines the camera to use to pick the right LOD level
  101384. * @returns the currentAbstractMesh
  101385. */
  101386. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101387. /**
  101388. * Returns 0 by default. Implemented by child classes
  101389. * @returns an integer
  101390. */
  101391. getTotalVertices(): number;
  101392. /**
  101393. * Returns a positive integer : the total number of indices in this mesh geometry.
  101394. * @returns the numner of indices or zero if the mesh has no geometry.
  101395. */
  101396. getTotalIndices(): number;
  101397. /**
  101398. * Returns null by default. Implemented by child classes
  101399. * @returns null
  101400. */
  101401. getIndices(): Nullable<IndicesArray>;
  101402. /**
  101403. * Returns the array of the requested vertex data kind. Implemented by child classes
  101404. * @param kind defines the vertex data kind to use
  101405. * @returns null
  101406. */
  101407. getVerticesData(kind: string): Nullable<FloatArray>;
  101408. /**
  101409. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101410. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101411. * Note that a new underlying VertexBuffer object is created each call.
  101412. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101413. * @param kind defines vertex data kind:
  101414. * * VertexBuffer.PositionKind
  101415. * * VertexBuffer.UVKind
  101416. * * VertexBuffer.UV2Kind
  101417. * * VertexBuffer.UV3Kind
  101418. * * VertexBuffer.UV4Kind
  101419. * * VertexBuffer.UV5Kind
  101420. * * VertexBuffer.UV6Kind
  101421. * * VertexBuffer.ColorKind
  101422. * * VertexBuffer.MatricesIndicesKind
  101423. * * VertexBuffer.MatricesIndicesExtraKind
  101424. * * VertexBuffer.MatricesWeightsKind
  101425. * * VertexBuffer.MatricesWeightsExtraKind
  101426. * @param data defines the data source
  101427. * @param updatable defines if the data must be flagged as updatable (or static)
  101428. * @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
  101429. * @returns the current mesh
  101430. */
  101431. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101432. /**
  101433. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101434. * If the mesh has no geometry, it is simply returned as it is.
  101435. * @param kind defines vertex data kind:
  101436. * * VertexBuffer.PositionKind
  101437. * * VertexBuffer.UVKind
  101438. * * VertexBuffer.UV2Kind
  101439. * * VertexBuffer.UV3Kind
  101440. * * VertexBuffer.UV4Kind
  101441. * * VertexBuffer.UV5Kind
  101442. * * VertexBuffer.UV6Kind
  101443. * * VertexBuffer.ColorKind
  101444. * * VertexBuffer.MatricesIndicesKind
  101445. * * VertexBuffer.MatricesIndicesExtraKind
  101446. * * VertexBuffer.MatricesWeightsKind
  101447. * * VertexBuffer.MatricesWeightsExtraKind
  101448. * @param data defines the data source
  101449. * @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
  101450. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101451. * @returns the current mesh
  101452. */
  101453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101454. /**
  101455. * Sets the mesh indices,
  101456. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101457. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101458. * @param totalVertices Defines the total number of vertices
  101459. * @returns the current mesh
  101460. */
  101461. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101462. /**
  101463. * Gets a boolean indicating if specific vertex data is present
  101464. * @param kind defines the vertex data kind to use
  101465. * @returns true is data kind is present
  101466. */
  101467. isVerticesDataPresent(kind: string): boolean;
  101468. /**
  101469. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101470. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101471. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101472. * @returns a BoundingInfo
  101473. */
  101474. getBoundingInfo(): BoundingInfo;
  101475. /**
  101476. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101477. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101478. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101479. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101480. * @returns the current mesh
  101481. */
  101482. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101483. /**
  101484. * Overwrite the current bounding info
  101485. * @param boundingInfo defines the new bounding info
  101486. * @returns the current mesh
  101487. */
  101488. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101489. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101490. get useBones(): boolean;
  101491. /** @hidden */
  101492. _preActivate(): void;
  101493. /** @hidden */
  101494. _preActivateForIntermediateRendering(renderId: number): void;
  101495. /** @hidden */
  101496. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101497. /** @hidden */
  101498. _postActivate(): void;
  101499. /** @hidden */
  101500. _freeze(): void;
  101501. /** @hidden */
  101502. _unFreeze(): void;
  101503. /**
  101504. * Gets the current world matrix
  101505. * @returns a Matrix
  101506. */
  101507. getWorldMatrix(): Matrix;
  101508. /** @hidden */
  101509. _getWorldMatrixDeterminant(): number;
  101510. /**
  101511. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101512. */
  101513. get isAnInstance(): boolean;
  101514. /**
  101515. * Gets a boolean indicating if this mesh has instances
  101516. */
  101517. get hasInstances(): boolean;
  101518. /**
  101519. * Perform relative position change from the point of view of behind the front of the mesh.
  101520. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101521. * Supports definition of mesh facing forward or backward
  101522. * @param amountRight defines the distance on the right axis
  101523. * @param amountUp defines the distance on the up axis
  101524. * @param amountForward defines the distance on the forward axis
  101525. * @returns the current mesh
  101526. */
  101527. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101528. /**
  101529. * Calculate relative position change from the point of view of behind the front of the mesh.
  101530. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101531. * Supports definition of mesh facing forward or backward
  101532. * @param amountRight defines the distance on the right axis
  101533. * @param amountUp defines the distance on the up axis
  101534. * @param amountForward defines the distance on the forward axis
  101535. * @returns the new displacement vector
  101536. */
  101537. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101538. /**
  101539. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101540. * Supports definition of mesh facing forward or backward
  101541. * @param flipBack defines the flip
  101542. * @param twirlClockwise defines the twirl
  101543. * @param tiltRight defines the tilt
  101544. * @returns the current mesh
  101545. */
  101546. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101547. /**
  101548. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101549. * Supports definition of mesh facing forward or backward.
  101550. * @param flipBack defines the flip
  101551. * @param twirlClockwise defines the twirl
  101552. * @param tiltRight defines the tilt
  101553. * @returns the new rotation vector
  101554. */
  101555. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101556. /**
  101557. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101558. * This means the mesh underlying bounding box and sphere are recomputed.
  101559. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101560. * @returns the current mesh
  101561. */
  101562. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101563. /** @hidden */
  101564. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101565. /** @hidden */
  101566. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101567. /** @hidden */
  101568. _updateBoundingInfo(): AbstractMesh;
  101569. /** @hidden */
  101570. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101571. /** @hidden */
  101572. protected _afterComputeWorldMatrix(): void;
  101573. /** @hidden */
  101574. get _effectiveMesh(): AbstractMesh;
  101575. /**
  101576. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101577. * A mesh is in the frustum if its bounding box intersects the frustum
  101578. * @param frustumPlanes defines the frustum to test
  101579. * @returns true if the mesh is in the frustum planes
  101580. */
  101581. isInFrustum(frustumPlanes: Plane[]): boolean;
  101582. /**
  101583. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101584. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101585. * @param frustumPlanes defines the frustum to test
  101586. * @returns true if the mesh is completely in the frustum planes
  101587. */
  101588. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101589. /**
  101590. * True if the mesh intersects another mesh or a SolidParticle object
  101591. * @param mesh defines a target mesh or SolidParticle to test
  101592. * @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)
  101593. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101594. * @returns true if there is an intersection
  101595. */
  101596. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101597. /**
  101598. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101599. * @param point defines the point to test
  101600. * @returns true if there is an intersection
  101601. */
  101602. intersectsPoint(point: Vector3): boolean;
  101603. /**
  101604. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101606. */
  101607. get checkCollisions(): boolean;
  101608. set checkCollisions(collisionEnabled: boolean);
  101609. /**
  101610. * Gets Collider object used to compute collisions (not physics)
  101611. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101612. */
  101613. get collider(): Nullable<Collider>;
  101614. /**
  101615. * Move the mesh using collision engine
  101616. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101617. * @param displacement defines the requested displacement vector
  101618. * @returns the current mesh
  101619. */
  101620. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101621. private _onCollisionPositionChange;
  101622. /** @hidden */
  101623. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101624. /** @hidden */
  101625. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101626. /** @hidden */
  101627. _checkCollision(collider: Collider): AbstractMesh;
  101628. /** @hidden */
  101629. _generatePointsArray(): boolean;
  101630. /**
  101631. * Checks if the passed Ray intersects with the mesh
  101632. * @param ray defines the ray to use
  101633. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101634. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101635. * @returns the picking info
  101636. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101637. */
  101638. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101639. /**
  101640. * Clones the current mesh
  101641. * @param name defines the mesh name
  101642. * @param newParent defines the new mesh parent
  101643. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101644. * @returns the new mesh
  101645. */
  101646. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101647. /**
  101648. * Disposes all the submeshes of the current meshnp
  101649. * @returns the current mesh
  101650. */
  101651. releaseSubMeshes(): AbstractMesh;
  101652. /**
  101653. * Releases resources associated with this abstract mesh.
  101654. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101655. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101656. */
  101657. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101658. /**
  101659. * Adds the passed mesh as a child to the current mesh
  101660. * @param mesh defines the child mesh
  101661. * @returns the current mesh
  101662. */
  101663. addChild(mesh: AbstractMesh): AbstractMesh;
  101664. /**
  101665. * Removes the passed mesh from the current mesh children list
  101666. * @param mesh defines the child mesh
  101667. * @returns the current mesh
  101668. */
  101669. removeChild(mesh: AbstractMesh): AbstractMesh;
  101670. /** @hidden */
  101671. private _initFacetData;
  101672. /**
  101673. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101674. * This method can be called within the render loop.
  101675. * 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
  101676. * @returns the current mesh
  101677. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101678. */
  101679. updateFacetData(): AbstractMesh;
  101680. /**
  101681. * Returns the facetLocalNormals array.
  101682. * The normals are expressed in the mesh local spac
  101683. * @returns an array of Vector3
  101684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101685. */
  101686. getFacetLocalNormals(): Vector3[];
  101687. /**
  101688. * Returns the facetLocalPositions array.
  101689. * The facet positions are expressed in the mesh local space
  101690. * @returns an array of Vector3
  101691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101692. */
  101693. getFacetLocalPositions(): Vector3[];
  101694. /**
  101695. * Returns the facetLocalPartioning array
  101696. * @returns an array of array of numbers
  101697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101698. */
  101699. getFacetLocalPartitioning(): number[][];
  101700. /**
  101701. * Returns the i-th facet position in the world system.
  101702. * This method allocates a new Vector3 per call
  101703. * @param i defines the facet index
  101704. * @returns a new Vector3
  101705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101706. */
  101707. getFacetPosition(i: number): Vector3;
  101708. /**
  101709. * Sets the reference Vector3 with the i-th facet position in the world system
  101710. * @param i defines the facet index
  101711. * @param ref defines the target vector
  101712. * @returns the current mesh
  101713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101714. */
  101715. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101716. /**
  101717. * Returns the i-th facet normal in the world system.
  101718. * This method allocates a new Vector3 per call
  101719. * @param i defines the facet index
  101720. * @returns a new Vector3
  101721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101722. */
  101723. getFacetNormal(i: number): Vector3;
  101724. /**
  101725. * Sets the reference Vector3 with the i-th facet normal in the world system
  101726. * @param i defines the facet index
  101727. * @param ref defines the target vector
  101728. * @returns the current mesh
  101729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101730. */
  101731. getFacetNormalToRef(i: number, ref: Vector3): this;
  101732. /**
  101733. * 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)
  101734. * @param x defines x coordinate
  101735. * @param y defines y coordinate
  101736. * @param z defines z coordinate
  101737. * @returns the array of facet indexes
  101738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101739. */
  101740. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101741. /**
  101742. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101743. * @param projected sets as the (x,y,z) world projection on the facet
  101744. * @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
  101745. * @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
  101746. * @param x defines x coordinate
  101747. * @param y defines y coordinate
  101748. * @param z defines z coordinate
  101749. * @returns the face index if found (or null instead)
  101750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101751. */
  101752. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101753. /**
  101754. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101755. * @param projected sets as the (x,y,z) local projection on the facet
  101756. * @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
  101757. * @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
  101758. * @param x defines x coordinate
  101759. * @param y defines y coordinate
  101760. * @param z defines z coordinate
  101761. * @returns the face index if found (or null instead)
  101762. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101763. */
  101764. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101765. /**
  101766. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101767. * @returns the parameters
  101768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101769. */
  101770. getFacetDataParameters(): any;
  101771. /**
  101772. * Disables the feature FacetData and frees the related memory
  101773. * @returns the current mesh
  101774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101775. */
  101776. disableFacetData(): AbstractMesh;
  101777. /**
  101778. * Updates the AbstractMesh indices array
  101779. * @param indices defines the data source
  101780. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101781. * @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)
  101782. * @returns the current mesh
  101783. */
  101784. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101785. /**
  101786. * Creates new normals data for the mesh
  101787. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101788. * @returns the current mesh
  101789. */
  101790. createNormals(updatable: boolean): AbstractMesh;
  101791. /**
  101792. * Align the mesh with a normal
  101793. * @param normal defines the normal to use
  101794. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101795. * @returns the current mesh
  101796. */
  101797. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101798. /** @hidden */
  101799. _checkOcclusionQuery(): boolean;
  101800. /**
  101801. * Disables the mesh edge rendering mode
  101802. * @returns the currentAbstractMesh
  101803. */
  101804. disableEdgesRendering(): AbstractMesh;
  101805. /**
  101806. * Enables the edge rendering mode on the mesh.
  101807. * This mode makes the mesh edges visible
  101808. * @param epsilon defines the maximal distance between two angles to detect a face
  101809. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101810. * @returns the currentAbstractMesh
  101811. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101812. */
  101813. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101814. }
  101815. }
  101816. declare module BABYLON {
  101817. /**
  101818. * Interface used to define ActionEvent
  101819. */
  101820. export interface IActionEvent {
  101821. /** The mesh or sprite that triggered the action */
  101822. source: any;
  101823. /** The X mouse cursor position at the time of the event */
  101824. pointerX: number;
  101825. /** The Y mouse cursor position at the time of the event */
  101826. pointerY: number;
  101827. /** The mesh that is currently pointed at (can be null) */
  101828. meshUnderPointer: Nullable<AbstractMesh>;
  101829. /** the original (browser) event that triggered the ActionEvent */
  101830. sourceEvent?: any;
  101831. /** additional data for the event */
  101832. additionalData?: any;
  101833. }
  101834. /**
  101835. * ActionEvent is the event being sent when an action is triggered.
  101836. */
  101837. export class ActionEvent implements IActionEvent {
  101838. /** The mesh or sprite that triggered the action */
  101839. source: any;
  101840. /** The X mouse cursor position at the time of the event */
  101841. pointerX: number;
  101842. /** The Y mouse cursor position at the time of the event */
  101843. pointerY: number;
  101844. /** The mesh that is currently pointed at (can be null) */
  101845. meshUnderPointer: Nullable<AbstractMesh>;
  101846. /** the original (browser) event that triggered the ActionEvent */
  101847. sourceEvent?: any;
  101848. /** additional data for the event */
  101849. additionalData?: any;
  101850. /**
  101851. * Creates a new ActionEvent
  101852. * @param source The mesh or sprite that triggered the action
  101853. * @param pointerX The X mouse cursor position at the time of the event
  101854. * @param pointerY The Y mouse cursor position at the time of the event
  101855. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101856. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101857. * @param additionalData additional data for the event
  101858. */
  101859. constructor(
  101860. /** The mesh or sprite that triggered the action */
  101861. source: any,
  101862. /** The X mouse cursor position at the time of the event */
  101863. pointerX: number,
  101864. /** The Y mouse cursor position at the time of the event */
  101865. pointerY: number,
  101866. /** The mesh that is currently pointed at (can be null) */
  101867. meshUnderPointer: Nullable<AbstractMesh>,
  101868. /** the original (browser) event that triggered the ActionEvent */
  101869. sourceEvent?: any,
  101870. /** additional data for the event */
  101871. additionalData?: any);
  101872. /**
  101873. * Helper function to auto-create an ActionEvent from a source mesh.
  101874. * @param source The source mesh that triggered the event
  101875. * @param evt The original (browser) event
  101876. * @param additionalData additional data for the event
  101877. * @returns the new ActionEvent
  101878. */
  101879. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101880. /**
  101881. * Helper function to auto-create an ActionEvent from a source sprite
  101882. * @param source The source sprite that triggered the event
  101883. * @param scene Scene associated with the sprite
  101884. * @param evt The original (browser) event
  101885. * @param additionalData additional data for the event
  101886. * @returns the new ActionEvent
  101887. */
  101888. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101889. /**
  101890. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101891. * @param scene the scene where the event occurred
  101892. * @param evt The original (browser) event
  101893. * @returns the new ActionEvent
  101894. */
  101895. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101896. /**
  101897. * Helper function to auto-create an ActionEvent from a primitive
  101898. * @param prim defines the target primitive
  101899. * @param pointerPos defines the pointer position
  101900. * @param evt The original (browser) event
  101901. * @param additionalData additional data for the event
  101902. * @returns the new ActionEvent
  101903. */
  101904. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101905. }
  101906. }
  101907. declare module BABYLON {
  101908. /**
  101909. * Abstract class used to decouple action Manager from scene and meshes.
  101910. * Do not instantiate.
  101911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101912. */
  101913. export abstract class AbstractActionManager implements IDisposable {
  101914. /** Gets the list of active triggers */
  101915. static Triggers: {
  101916. [key: string]: number;
  101917. };
  101918. /** Gets the cursor to use when hovering items */
  101919. hoverCursor: string;
  101920. /** Gets the list of actions */
  101921. actions: IAction[];
  101922. /**
  101923. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101924. */
  101925. isRecursive: boolean;
  101926. /**
  101927. * Releases all associated resources
  101928. */
  101929. abstract dispose(): void;
  101930. /**
  101931. * Does this action manager has pointer triggers
  101932. */
  101933. abstract get hasPointerTriggers(): boolean;
  101934. /**
  101935. * Does this action manager has pick triggers
  101936. */
  101937. abstract get hasPickTriggers(): boolean;
  101938. /**
  101939. * Process a specific trigger
  101940. * @param trigger defines the trigger to process
  101941. * @param evt defines the event details to be processed
  101942. */
  101943. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101944. /**
  101945. * Does this action manager handles actions of any of the given triggers
  101946. * @param triggers defines the triggers to be tested
  101947. * @return a boolean indicating whether one (or more) of the triggers is handled
  101948. */
  101949. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101950. /**
  101951. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101952. * speed.
  101953. * @param triggerA defines the trigger to be tested
  101954. * @param triggerB defines the trigger to be tested
  101955. * @return a boolean indicating whether one (or more) of the triggers is handled
  101956. */
  101957. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101958. /**
  101959. * Does this action manager handles actions of a given trigger
  101960. * @param trigger defines the trigger to be tested
  101961. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101962. * @return whether the trigger is handled
  101963. */
  101964. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101965. /**
  101966. * Serialize this manager to a JSON object
  101967. * @param name defines the property name to store this manager
  101968. * @returns a JSON representation of this manager
  101969. */
  101970. abstract serialize(name: string): any;
  101971. /**
  101972. * Registers an action to this action manager
  101973. * @param action defines the action to be registered
  101974. * @return the action amended (prepared) after registration
  101975. */
  101976. abstract registerAction(action: IAction): Nullable<IAction>;
  101977. /**
  101978. * Unregisters an action to this action manager
  101979. * @param action defines the action to be unregistered
  101980. * @return a boolean indicating whether the action has been unregistered
  101981. */
  101982. abstract unregisterAction(action: IAction): Boolean;
  101983. /**
  101984. * Does exist one action manager with at least one trigger
  101985. **/
  101986. static get HasTriggers(): boolean;
  101987. /**
  101988. * Does exist one action manager with at least one pick trigger
  101989. **/
  101990. static get HasPickTriggers(): boolean;
  101991. /**
  101992. * Does exist one action manager that handles actions of a given trigger
  101993. * @param trigger defines the trigger to be tested
  101994. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101995. **/
  101996. static HasSpecificTrigger(trigger: number): boolean;
  101997. }
  101998. }
  101999. declare module BABYLON {
  102000. /**
  102001. * Defines how a node can be built from a string name.
  102002. */
  102003. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102004. /**
  102005. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102006. */
  102007. export class Node implements IBehaviorAware<Node> {
  102008. /** @hidden */
  102009. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102010. private static _NodeConstructors;
  102011. /**
  102012. * Add a new node constructor
  102013. * @param type defines the type name of the node to construct
  102014. * @param constructorFunc defines the constructor function
  102015. */
  102016. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102017. /**
  102018. * Returns a node constructor based on type name
  102019. * @param type defines the type name
  102020. * @param name defines the new node name
  102021. * @param scene defines the hosting scene
  102022. * @param options defines optional options to transmit to constructors
  102023. * @returns the new constructor or null
  102024. */
  102025. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102026. /**
  102027. * Gets or sets the name of the node
  102028. */
  102029. name: string;
  102030. /**
  102031. * Gets or sets the id of the node
  102032. */
  102033. id: string;
  102034. /**
  102035. * Gets or sets the unique id of the node
  102036. */
  102037. uniqueId: number;
  102038. /**
  102039. * Gets or sets a string used to store user defined state for the node
  102040. */
  102041. state: string;
  102042. /**
  102043. * Gets or sets an object used to store user defined information for the node
  102044. */
  102045. metadata: any;
  102046. /**
  102047. * For internal use only. Please do not use.
  102048. */
  102049. reservedDataStore: any;
  102050. /**
  102051. * List of inspectable custom properties (used by the Inspector)
  102052. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102053. */
  102054. inspectableCustomProperties: IInspectable[];
  102055. private _doNotSerialize;
  102056. /**
  102057. * Gets or sets a boolean used to define if the node must be serialized
  102058. */
  102059. get doNotSerialize(): boolean;
  102060. set doNotSerialize(value: boolean);
  102061. /** @hidden */
  102062. _isDisposed: boolean;
  102063. /**
  102064. * Gets a list of Animations associated with the node
  102065. */
  102066. animations: Animation[];
  102067. protected _ranges: {
  102068. [name: string]: Nullable<AnimationRange>;
  102069. };
  102070. /**
  102071. * Callback raised when the node is ready to be used
  102072. */
  102073. onReady: Nullable<(node: Node) => void>;
  102074. private _isEnabled;
  102075. private _isParentEnabled;
  102076. private _isReady;
  102077. /** @hidden */
  102078. _currentRenderId: number;
  102079. private _parentUpdateId;
  102080. /** @hidden */
  102081. _childUpdateId: number;
  102082. /** @hidden */
  102083. _waitingParentId: Nullable<string>;
  102084. /** @hidden */
  102085. _scene: Scene;
  102086. /** @hidden */
  102087. _cache: any;
  102088. private _parentNode;
  102089. private _children;
  102090. /** @hidden */
  102091. _worldMatrix: Matrix;
  102092. /** @hidden */
  102093. _worldMatrixDeterminant: number;
  102094. /** @hidden */
  102095. _worldMatrixDeterminantIsDirty: boolean;
  102096. /** @hidden */
  102097. private _sceneRootNodesIndex;
  102098. /**
  102099. * Gets a boolean indicating if the node has been disposed
  102100. * @returns true if the node was disposed
  102101. */
  102102. isDisposed(): boolean;
  102103. /**
  102104. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102105. * @see https://doc.babylonjs.com/how_to/parenting
  102106. */
  102107. set parent(parent: Nullable<Node>);
  102108. get parent(): Nullable<Node>;
  102109. /** @hidden */
  102110. _addToSceneRootNodes(): void;
  102111. /** @hidden */
  102112. _removeFromSceneRootNodes(): void;
  102113. private _animationPropertiesOverride;
  102114. /**
  102115. * Gets or sets the animation properties override
  102116. */
  102117. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102118. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102119. /**
  102120. * Gets a string idenfifying the name of the class
  102121. * @returns "Node" string
  102122. */
  102123. getClassName(): string;
  102124. /** @hidden */
  102125. readonly _isNode: boolean;
  102126. /**
  102127. * An event triggered when the mesh is disposed
  102128. */
  102129. onDisposeObservable: Observable<Node>;
  102130. private _onDisposeObserver;
  102131. /**
  102132. * Sets a callback that will be raised when the node will be disposed
  102133. */
  102134. set onDispose(callback: () => void);
  102135. /**
  102136. * Creates a new Node
  102137. * @param name the name and id to be given to this node
  102138. * @param scene the scene this node will be added to
  102139. */
  102140. constructor(name: string, scene?: Nullable<Scene>);
  102141. /**
  102142. * Gets the scene of the node
  102143. * @returns a scene
  102144. */
  102145. getScene(): Scene;
  102146. /**
  102147. * Gets the engine of the node
  102148. * @returns a Engine
  102149. */
  102150. getEngine(): Engine;
  102151. private _behaviors;
  102152. /**
  102153. * Attach a behavior to the node
  102154. * @see http://doc.babylonjs.com/features/behaviour
  102155. * @param behavior defines the behavior to attach
  102156. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102157. * @returns the current Node
  102158. */
  102159. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102160. /**
  102161. * Remove an attached behavior
  102162. * @see http://doc.babylonjs.com/features/behaviour
  102163. * @param behavior defines the behavior to attach
  102164. * @returns the current Node
  102165. */
  102166. removeBehavior(behavior: Behavior<Node>): Node;
  102167. /**
  102168. * Gets the list of attached behaviors
  102169. * @see http://doc.babylonjs.com/features/behaviour
  102170. */
  102171. get behaviors(): Behavior<Node>[];
  102172. /**
  102173. * Gets an attached behavior by name
  102174. * @param name defines the name of the behavior to look for
  102175. * @see http://doc.babylonjs.com/features/behaviour
  102176. * @returns null if behavior was not found else the requested behavior
  102177. */
  102178. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102179. /**
  102180. * Returns the latest update of the World matrix
  102181. * @returns a Matrix
  102182. */
  102183. getWorldMatrix(): Matrix;
  102184. /** @hidden */
  102185. _getWorldMatrixDeterminant(): number;
  102186. /**
  102187. * Returns directly the latest state of the mesh World matrix.
  102188. * A Matrix is returned.
  102189. */
  102190. get worldMatrixFromCache(): Matrix;
  102191. /** @hidden */
  102192. _initCache(): void;
  102193. /** @hidden */
  102194. updateCache(force?: boolean): void;
  102195. /** @hidden */
  102196. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102197. /** @hidden */
  102198. _updateCache(ignoreParentClass?: boolean): void;
  102199. /** @hidden */
  102200. _isSynchronized(): boolean;
  102201. /** @hidden */
  102202. _markSyncedWithParent(): void;
  102203. /** @hidden */
  102204. isSynchronizedWithParent(): boolean;
  102205. /** @hidden */
  102206. isSynchronized(): boolean;
  102207. /**
  102208. * Is this node ready to be used/rendered
  102209. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102210. * @return true if the node is ready
  102211. */
  102212. isReady(completeCheck?: boolean): boolean;
  102213. /**
  102214. * Is this node enabled?
  102215. * 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
  102216. * @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
  102217. * @return whether this node (and its parent) is enabled
  102218. */
  102219. isEnabled(checkAncestors?: boolean): boolean;
  102220. /** @hidden */
  102221. protected _syncParentEnabledState(): void;
  102222. /**
  102223. * Set the enabled state of this node
  102224. * @param value defines the new enabled state
  102225. */
  102226. setEnabled(value: boolean): void;
  102227. /**
  102228. * Is this node a descendant of the given node?
  102229. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102230. * @param ancestor defines the parent node to inspect
  102231. * @returns a boolean indicating if this node is a descendant of the given node
  102232. */
  102233. isDescendantOf(ancestor: Node): boolean;
  102234. /** @hidden */
  102235. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102236. /**
  102237. * Will return all nodes that have this node as ascendant
  102238. * @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
  102239. * @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
  102240. * @return all children nodes of all types
  102241. */
  102242. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102243. /**
  102244. * Get all child-meshes of this node
  102245. * @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)
  102246. * @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
  102247. * @returns an array of AbstractMesh
  102248. */
  102249. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102250. /**
  102251. * Get all direct children of this node
  102252. * @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
  102253. * @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)
  102254. * @returns an array of Node
  102255. */
  102256. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102257. /** @hidden */
  102258. _setReady(state: boolean): void;
  102259. /**
  102260. * Get an animation by name
  102261. * @param name defines the name of the animation to look for
  102262. * @returns null if not found else the requested animation
  102263. */
  102264. getAnimationByName(name: string): Nullable<Animation>;
  102265. /**
  102266. * Creates an animation range for this node
  102267. * @param name defines the name of the range
  102268. * @param from defines the starting key
  102269. * @param to defines the end key
  102270. */
  102271. createAnimationRange(name: string, from: number, to: number): void;
  102272. /**
  102273. * Delete a specific animation range
  102274. * @param name defines the name of the range to delete
  102275. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102276. */
  102277. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102278. /**
  102279. * Get an animation range by name
  102280. * @param name defines the name of the animation range to look for
  102281. * @returns null if not found else the requested animation range
  102282. */
  102283. getAnimationRange(name: string): Nullable<AnimationRange>;
  102284. /**
  102285. * Gets the list of all animation ranges defined on this node
  102286. * @returns an array
  102287. */
  102288. getAnimationRanges(): Nullable<AnimationRange>[];
  102289. /**
  102290. * Will start the animation sequence
  102291. * @param name defines the range frames for animation sequence
  102292. * @param loop defines if the animation should loop (false by default)
  102293. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102294. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102295. * @returns the object created for this animation. If range does not exist, it will return null
  102296. */
  102297. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102298. /**
  102299. * Serialize animation ranges into a JSON compatible object
  102300. * @returns serialization object
  102301. */
  102302. serializeAnimationRanges(): any;
  102303. /**
  102304. * Computes the world matrix of the node
  102305. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102306. * @returns the world matrix
  102307. */
  102308. computeWorldMatrix(force?: boolean): Matrix;
  102309. /**
  102310. * Releases resources associated with this node.
  102311. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102312. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102313. */
  102314. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102315. /**
  102316. * Parse animation range data from a serialization object and store them into a given node
  102317. * @param node defines where to store the animation ranges
  102318. * @param parsedNode defines the serialization object to read data from
  102319. * @param scene defines the hosting scene
  102320. */
  102321. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102322. /**
  102323. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102324. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102325. * @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
  102326. * @returns the new bounding vectors
  102327. */
  102328. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102329. min: Vector3;
  102330. max: Vector3;
  102331. };
  102332. }
  102333. }
  102334. declare module BABYLON {
  102335. /**
  102336. * @hidden
  102337. */
  102338. export class _IAnimationState {
  102339. key: number;
  102340. repeatCount: number;
  102341. workValue?: any;
  102342. loopMode?: number;
  102343. offsetValue?: any;
  102344. highLimitValue?: any;
  102345. }
  102346. /**
  102347. * Class used to store any kind of animation
  102348. */
  102349. export class Animation {
  102350. /**Name of the animation */
  102351. name: string;
  102352. /**Property to animate */
  102353. targetProperty: string;
  102354. /**The frames per second of the animation */
  102355. framePerSecond: number;
  102356. /**The data type of the animation */
  102357. dataType: number;
  102358. /**The loop mode of the animation */
  102359. loopMode?: number | undefined;
  102360. /**Specifies if blending should be enabled */
  102361. enableBlending?: boolean | undefined;
  102362. /**
  102363. * Use matrix interpolation instead of using direct key value when animating matrices
  102364. */
  102365. static AllowMatricesInterpolation: boolean;
  102366. /**
  102367. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102368. */
  102369. static AllowMatrixDecomposeForInterpolation: boolean;
  102370. /**
  102371. * Stores the key frames of the animation
  102372. */
  102373. private _keys;
  102374. /**
  102375. * Stores the easing function of the animation
  102376. */
  102377. private _easingFunction;
  102378. /**
  102379. * @hidden Internal use only
  102380. */
  102381. _runtimeAnimations: RuntimeAnimation[];
  102382. /**
  102383. * The set of event that will be linked to this animation
  102384. */
  102385. private _events;
  102386. /**
  102387. * Stores an array of target property paths
  102388. */
  102389. targetPropertyPath: string[];
  102390. /**
  102391. * Stores the blending speed of the animation
  102392. */
  102393. blendingSpeed: number;
  102394. /**
  102395. * Stores the animation ranges for the animation
  102396. */
  102397. private _ranges;
  102398. /**
  102399. * @hidden Internal use
  102400. */
  102401. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102402. /**
  102403. * Sets up an animation
  102404. * @param property The property to animate
  102405. * @param animationType The animation type to apply
  102406. * @param framePerSecond The frames per second of the animation
  102407. * @param easingFunction The easing function used in the animation
  102408. * @returns The created animation
  102409. */
  102410. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102411. /**
  102412. * Create and start an animation on a node
  102413. * @param name defines the name of the global animation that will be run on all nodes
  102414. * @param node defines the root node where the animation will take place
  102415. * @param targetProperty defines property to animate
  102416. * @param framePerSecond defines the number of frame per second yo use
  102417. * @param totalFrame defines the number of frames in total
  102418. * @param from defines the initial value
  102419. * @param to defines the final value
  102420. * @param loopMode defines which loop mode you want to use (off by default)
  102421. * @param easingFunction defines the easing function to use (linear by default)
  102422. * @param onAnimationEnd defines the callback to call when animation end
  102423. * @returns the animatable created for this animation
  102424. */
  102425. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102426. /**
  102427. * Create and start an animation on a node and its descendants
  102428. * @param name defines the name of the global animation that will be run on all nodes
  102429. * @param node defines the root node where the animation will take place
  102430. * @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
  102431. * @param targetProperty defines property to animate
  102432. * @param framePerSecond defines the number of frame per second to use
  102433. * @param totalFrame defines the number of frames in total
  102434. * @param from defines the initial value
  102435. * @param to defines the final value
  102436. * @param loopMode defines which loop mode you want to use (off by default)
  102437. * @param easingFunction defines the easing function to use (linear by default)
  102438. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102439. * @returns the list of animatables created for all nodes
  102440. * @example https://www.babylonjs-playground.com/#MH0VLI
  102441. */
  102442. 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[]>;
  102443. /**
  102444. * Creates a new animation, merges it with the existing animations and starts it
  102445. * @param name Name of the animation
  102446. * @param node Node which contains the scene that begins the animations
  102447. * @param targetProperty Specifies which property to animate
  102448. * @param framePerSecond The frames per second of the animation
  102449. * @param totalFrame The total number of frames
  102450. * @param from The frame at the beginning of the animation
  102451. * @param to The frame at the end of the animation
  102452. * @param loopMode Specifies the loop mode of the animation
  102453. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102454. * @param onAnimationEnd Callback to run once the animation is complete
  102455. * @returns Nullable animation
  102456. */
  102457. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102458. /**
  102459. * Transition property of an host to the target Value
  102460. * @param property The property to transition
  102461. * @param targetValue The target Value of the property
  102462. * @param host The object where the property to animate belongs
  102463. * @param scene Scene used to run the animation
  102464. * @param frameRate Framerate (in frame/s) to use
  102465. * @param transition The transition type we want to use
  102466. * @param duration The duration of the animation, in milliseconds
  102467. * @param onAnimationEnd Callback trigger at the end of the animation
  102468. * @returns Nullable animation
  102469. */
  102470. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102471. /**
  102472. * Return the array of runtime animations currently using this animation
  102473. */
  102474. get runtimeAnimations(): RuntimeAnimation[];
  102475. /**
  102476. * Specifies if any of the runtime animations are currently running
  102477. */
  102478. get hasRunningRuntimeAnimations(): boolean;
  102479. /**
  102480. * Initializes the animation
  102481. * @param name Name of the animation
  102482. * @param targetProperty Property to animate
  102483. * @param framePerSecond The frames per second of the animation
  102484. * @param dataType The data type of the animation
  102485. * @param loopMode The loop mode of the animation
  102486. * @param enableBlending Specifies if blending should be enabled
  102487. */
  102488. constructor(
  102489. /**Name of the animation */
  102490. name: string,
  102491. /**Property to animate */
  102492. targetProperty: string,
  102493. /**The frames per second of the animation */
  102494. framePerSecond: number,
  102495. /**The data type of the animation */
  102496. dataType: number,
  102497. /**The loop mode of the animation */
  102498. loopMode?: number | undefined,
  102499. /**Specifies if blending should be enabled */
  102500. enableBlending?: boolean | undefined);
  102501. /**
  102502. * Converts the animation to a string
  102503. * @param fullDetails support for multiple levels of logging within scene loading
  102504. * @returns String form of the animation
  102505. */
  102506. toString(fullDetails?: boolean): string;
  102507. /**
  102508. * Add an event to this animation
  102509. * @param event Event to add
  102510. */
  102511. addEvent(event: AnimationEvent): void;
  102512. /**
  102513. * Remove all events found at the given frame
  102514. * @param frame The frame to remove events from
  102515. */
  102516. removeEvents(frame: number): void;
  102517. /**
  102518. * Retrieves all the events from the animation
  102519. * @returns Events from the animation
  102520. */
  102521. getEvents(): AnimationEvent[];
  102522. /**
  102523. * Creates an animation range
  102524. * @param name Name of the animation range
  102525. * @param from Starting frame of the animation range
  102526. * @param to Ending frame of the animation
  102527. */
  102528. createRange(name: string, from: number, to: number): void;
  102529. /**
  102530. * Deletes an animation range by name
  102531. * @param name Name of the animation range to delete
  102532. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102533. */
  102534. deleteRange(name: string, deleteFrames?: boolean): void;
  102535. /**
  102536. * Gets the animation range by name, or null if not defined
  102537. * @param name Name of the animation range
  102538. * @returns Nullable animation range
  102539. */
  102540. getRange(name: string): Nullable<AnimationRange>;
  102541. /**
  102542. * Gets the key frames from the animation
  102543. * @returns The key frames of the animation
  102544. */
  102545. getKeys(): Array<IAnimationKey>;
  102546. /**
  102547. * Gets the highest frame rate of the animation
  102548. * @returns Highest frame rate of the animation
  102549. */
  102550. getHighestFrame(): number;
  102551. /**
  102552. * Gets the easing function of the animation
  102553. * @returns Easing function of the animation
  102554. */
  102555. getEasingFunction(): IEasingFunction;
  102556. /**
  102557. * Sets the easing function of the animation
  102558. * @param easingFunction A custom mathematical formula for animation
  102559. */
  102560. setEasingFunction(easingFunction: EasingFunction): void;
  102561. /**
  102562. * Interpolates a scalar linearly
  102563. * @param startValue Start value of the animation curve
  102564. * @param endValue End value of the animation curve
  102565. * @param gradient Scalar amount to interpolate
  102566. * @returns Interpolated scalar value
  102567. */
  102568. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102569. /**
  102570. * Interpolates a scalar cubically
  102571. * @param startValue Start value of the animation curve
  102572. * @param outTangent End tangent of the animation
  102573. * @param endValue End value of the animation curve
  102574. * @param inTangent Start tangent of the animation curve
  102575. * @param gradient Scalar amount to interpolate
  102576. * @returns Interpolated scalar value
  102577. */
  102578. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102579. /**
  102580. * Interpolates a quaternion using a spherical linear interpolation
  102581. * @param startValue Start value of the animation curve
  102582. * @param endValue End value of the animation curve
  102583. * @param gradient Scalar amount to interpolate
  102584. * @returns Interpolated quaternion value
  102585. */
  102586. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102587. /**
  102588. * Interpolates a quaternion cubically
  102589. * @param startValue Start value of the animation curve
  102590. * @param outTangent End tangent of the animation curve
  102591. * @param endValue End value of the animation curve
  102592. * @param inTangent Start tangent of the animation curve
  102593. * @param gradient Scalar amount to interpolate
  102594. * @returns Interpolated quaternion value
  102595. */
  102596. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102597. /**
  102598. * Interpolates a Vector3 linearl
  102599. * @param startValue Start value of the animation curve
  102600. * @param endValue End value of the animation curve
  102601. * @param gradient Scalar amount to interpolate
  102602. * @returns Interpolated scalar value
  102603. */
  102604. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102605. /**
  102606. * Interpolates a Vector3 cubically
  102607. * @param startValue Start value of the animation curve
  102608. * @param outTangent End tangent of the animation
  102609. * @param endValue End value of the animation curve
  102610. * @param inTangent Start tangent of the animation curve
  102611. * @param gradient Scalar amount to interpolate
  102612. * @returns InterpolatedVector3 value
  102613. */
  102614. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102615. /**
  102616. * Interpolates a Vector2 linearly
  102617. * @param startValue Start value of the animation curve
  102618. * @param endValue End value of the animation curve
  102619. * @param gradient Scalar amount to interpolate
  102620. * @returns Interpolated Vector2 value
  102621. */
  102622. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102623. /**
  102624. * Interpolates a Vector2 cubically
  102625. * @param startValue Start value of the animation curve
  102626. * @param outTangent End tangent of the animation
  102627. * @param endValue End value of the animation curve
  102628. * @param inTangent Start tangent of the animation curve
  102629. * @param gradient Scalar amount to interpolate
  102630. * @returns Interpolated Vector2 value
  102631. */
  102632. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102633. /**
  102634. * Interpolates a size linearly
  102635. * @param startValue Start value of the animation curve
  102636. * @param endValue End value of the animation curve
  102637. * @param gradient Scalar amount to interpolate
  102638. * @returns Interpolated Size value
  102639. */
  102640. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102641. /**
  102642. * Interpolates a Color3 linearly
  102643. * @param startValue Start value of the animation curve
  102644. * @param endValue End value of the animation curve
  102645. * @param gradient Scalar amount to interpolate
  102646. * @returns Interpolated Color3 value
  102647. */
  102648. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102649. /**
  102650. * Interpolates a Color4 linearly
  102651. * @param startValue Start value of the animation curve
  102652. * @param endValue End value of the animation curve
  102653. * @param gradient Scalar amount to interpolate
  102654. * @returns Interpolated Color3 value
  102655. */
  102656. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102657. /**
  102658. * @hidden Internal use only
  102659. */
  102660. _getKeyValue(value: any): any;
  102661. /**
  102662. * @hidden Internal use only
  102663. */
  102664. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102665. /**
  102666. * Defines the function to use to interpolate matrices
  102667. * @param startValue defines the start matrix
  102668. * @param endValue defines the end matrix
  102669. * @param gradient defines the gradient between both matrices
  102670. * @param result defines an optional target matrix where to store the interpolation
  102671. * @returns the interpolated matrix
  102672. */
  102673. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102674. /**
  102675. * Makes a copy of the animation
  102676. * @returns Cloned animation
  102677. */
  102678. clone(): Animation;
  102679. /**
  102680. * Sets the key frames of the animation
  102681. * @param values The animation key frames to set
  102682. */
  102683. setKeys(values: Array<IAnimationKey>): void;
  102684. /**
  102685. * Serializes the animation to an object
  102686. * @returns Serialized object
  102687. */
  102688. serialize(): any;
  102689. /**
  102690. * Float animation type
  102691. */
  102692. static readonly ANIMATIONTYPE_FLOAT: number;
  102693. /**
  102694. * Vector3 animation type
  102695. */
  102696. static readonly ANIMATIONTYPE_VECTOR3: number;
  102697. /**
  102698. * Quaternion animation type
  102699. */
  102700. static readonly ANIMATIONTYPE_QUATERNION: number;
  102701. /**
  102702. * Matrix animation type
  102703. */
  102704. static readonly ANIMATIONTYPE_MATRIX: number;
  102705. /**
  102706. * Color3 animation type
  102707. */
  102708. static readonly ANIMATIONTYPE_COLOR3: number;
  102709. /**
  102710. * Color3 animation type
  102711. */
  102712. static readonly ANIMATIONTYPE_COLOR4: number;
  102713. /**
  102714. * Vector2 animation type
  102715. */
  102716. static readonly ANIMATIONTYPE_VECTOR2: number;
  102717. /**
  102718. * Size animation type
  102719. */
  102720. static readonly ANIMATIONTYPE_SIZE: number;
  102721. /**
  102722. * Relative Loop Mode
  102723. */
  102724. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102725. /**
  102726. * Cycle Loop Mode
  102727. */
  102728. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102729. /**
  102730. * Constant Loop Mode
  102731. */
  102732. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102733. /** @hidden */
  102734. static _UniversalLerp(left: any, right: any, amount: number): any;
  102735. /**
  102736. * Parses an animation object and creates an animation
  102737. * @param parsedAnimation Parsed animation object
  102738. * @returns Animation object
  102739. */
  102740. static Parse(parsedAnimation: any): Animation;
  102741. /**
  102742. * Appends the serialized animations from the source animations
  102743. * @param source Source containing the animations
  102744. * @param destination Target to store the animations
  102745. */
  102746. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102747. }
  102748. }
  102749. declare module BABYLON {
  102750. /**
  102751. * Interface containing an array of animations
  102752. */
  102753. export interface IAnimatable {
  102754. /**
  102755. * Array of animations
  102756. */
  102757. animations: Nullable<Array<Animation>>;
  102758. }
  102759. }
  102760. declare module BABYLON {
  102761. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102762. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102763. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102764. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102765. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102766. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102767. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102768. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102769. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102770. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102771. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102772. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102773. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102774. /**
  102775. * Decorator used to define property that can be serialized as reference to a camera
  102776. * @param sourceName defines the name of the property to decorate
  102777. */
  102778. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102779. /**
  102780. * Class used to help serialization objects
  102781. */
  102782. export class SerializationHelper {
  102783. /** @hidden */
  102784. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102785. /** @hidden */
  102786. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102787. /** @hidden */
  102788. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102789. /** @hidden */
  102790. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102791. /**
  102792. * Appends the serialized animations from the source animations
  102793. * @param source Source containing the animations
  102794. * @param destination Target to store the animations
  102795. */
  102796. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102797. /**
  102798. * Static function used to serialized a specific entity
  102799. * @param entity defines the entity to serialize
  102800. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102801. * @returns a JSON compatible object representing the serialization of the entity
  102802. */
  102803. static Serialize<T>(entity: T, serializationObject?: any): any;
  102804. /**
  102805. * Creates a new entity from a serialization data object
  102806. * @param creationFunction defines a function used to instanciated the new entity
  102807. * @param source defines the source serialization data
  102808. * @param scene defines the hosting scene
  102809. * @param rootUrl defines the root url for resources
  102810. * @returns a new entity
  102811. */
  102812. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102813. /**
  102814. * Clones an object
  102815. * @param creationFunction defines the function used to instanciate the new object
  102816. * @param source defines the source object
  102817. * @returns the cloned object
  102818. */
  102819. static Clone<T>(creationFunction: () => T, source: T): T;
  102820. /**
  102821. * Instanciates a new object based on a source one (some data will be shared between both object)
  102822. * @param creationFunction defines the function used to instanciate the new object
  102823. * @param source defines the source object
  102824. * @returns the new object
  102825. */
  102826. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102827. }
  102828. }
  102829. declare module BABYLON {
  102830. /**
  102831. * Class used to manipulate GUIDs
  102832. */
  102833. export class GUID {
  102834. /**
  102835. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102836. * Be aware Math.random() could cause collisions, but:
  102837. * "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"
  102838. * @returns a pseudo random id
  102839. */
  102840. static RandomId(): string;
  102841. }
  102842. }
  102843. declare module BABYLON {
  102844. /**
  102845. * Base class of all the textures in babylon.
  102846. * It groups all the common properties the materials, post process, lights... might need
  102847. * in order to make a correct use of the texture.
  102848. */
  102849. export class BaseTexture implements IAnimatable {
  102850. /**
  102851. * Default anisotropic filtering level for the application.
  102852. * It is set to 4 as a good tradeoff between perf and quality.
  102853. */
  102854. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102855. /**
  102856. * Gets or sets the unique id of the texture
  102857. */
  102858. uniqueId: number;
  102859. /**
  102860. * Define the name of the texture.
  102861. */
  102862. name: string;
  102863. /**
  102864. * Gets or sets an object used to store user defined information.
  102865. */
  102866. metadata: any;
  102867. /**
  102868. * For internal use only. Please do not use.
  102869. */
  102870. reservedDataStore: any;
  102871. private _hasAlpha;
  102872. /**
  102873. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102874. */
  102875. set hasAlpha(value: boolean);
  102876. get hasAlpha(): boolean;
  102877. /**
  102878. * Defines if the alpha value should be determined via the rgb values.
  102879. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102880. */
  102881. getAlphaFromRGB: boolean;
  102882. /**
  102883. * Intensity or strength of the texture.
  102884. * It is commonly used by materials to fine tune the intensity of the texture
  102885. */
  102886. level: number;
  102887. /**
  102888. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102889. * This is part of the texture as textures usually maps to one uv set.
  102890. */
  102891. coordinatesIndex: number;
  102892. private _coordinatesMode;
  102893. /**
  102894. * How a texture is mapped.
  102895. *
  102896. * | Value | Type | Description |
  102897. * | ----- | ----------------------------------- | ----------- |
  102898. * | 0 | EXPLICIT_MODE | |
  102899. * | 1 | SPHERICAL_MODE | |
  102900. * | 2 | PLANAR_MODE | |
  102901. * | 3 | CUBIC_MODE | |
  102902. * | 4 | PROJECTION_MODE | |
  102903. * | 5 | SKYBOX_MODE | |
  102904. * | 6 | INVCUBIC_MODE | |
  102905. * | 7 | EQUIRECTANGULAR_MODE | |
  102906. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102907. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102908. */
  102909. set coordinatesMode(value: number);
  102910. get coordinatesMode(): number;
  102911. /**
  102912. * | Value | Type | Description |
  102913. * | ----- | ------------------ | ----------- |
  102914. * | 0 | CLAMP_ADDRESSMODE | |
  102915. * | 1 | WRAP_ADDRESSMODE | |
  102916. * | 2 | MIRROR_ADDRESSMODE | |
  102917. */
  102918. wrapU: number;
  102919. /**
  102920. * | Value | Type | Description |
  102921. * | ----- | ------------------ | ----------- |
  102922. * | 0 | CLAMP_ADDRESSMODE | |
  102923. * | 1 | WRAP_ADDRESSMODE | |
  102924. * | 2 | MIRROR_ADDRESSMODE | |
  102925. */
  102926. wrapV: number;
  102927. /**
  102928. * | Value | Type | Description |
  102929. * | ----- | ------------------ | ----------- |
  102930. * | 0 | CLAMP_ADDRESSMODE | |
  102931. * | 1 | WRAP_ADDRESSMODE | |
  102932. * | 2 | MIRROR_ADDRESSMODE | |
  102933. */
  102934. wrapR: number;
  102935. /**
  102936. * With compliant hardware and browser (supporting anisotropic filtering)
  102937. * this defines the level of anisotropic filtering in the texture.
  102938. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102939. */
  102940. anisotropicFilteringLevel: number;
  102941. /**
  102942. * Define if the texture is a cube texture or if false a 2d texture.
  102943. */
  102944. get isCube(): boolean;
  102945. set isCube(value: boolean);
  102946. /**
  102947. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102948. */
  102949. get is3D(): boolean;
  102950. set is3D(value: boolean);
  102951. /**
  102952. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102953. */
  102954. get is2DArray(): boolean;
  102955. set is2DArray(value: boolean);
  102956. /**
  102957. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102958. * HDR texture are usually stored in linear space.
  102959. * This only impacts the PBR and Background materials
  102960. */
  102961. gammaSpace: boolean;
  102962. /**
  102963. * Gets or sets whether or not the texture contains RGBD data.
  102964. */
  102965. get isRGBD(): boolean;
  102966. set isRGBD(value: boolean);
  102967. /**
  102968. * Is Z inverted in the texture (useful in a cube texture).
  102969. */
  102970. invertZ: boolean;
  102971. /**
  102972. * Are mip maps generated for this texture or not.
  102973. */
  102974. get noMipmap(): boolean;
  102975. /**
  102976. * @hidden
  102977. */
  102978. lodLevelInAlpha: boolean;
  102979. /**
  102980. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102981. */
  102982. get lodGenerationOffset(): number;
  102983. set lodGenerationOffset(value: number);
  102984. /**
  102985. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102986. */
  102987. get lodGenerationScale(): number;
  102988. set lodGenerationScale(value: number);
  102989. /**
  102990. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102991. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102992. * average roughness values.
  102993. */
  102994. get linearSpecularLOD(): boolean;
  102995. set linearSpecularLOD(value: boolean);
  102996. /**
  102997. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102998. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102999. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103000. */
  103001. get irradianceTexture(): Nullable<BaseTexture>;
  103002. set irradianceTexture(value: Nullable<BaseTexture>);
  103003. /**
  103004. * Define if the texture is a render target.
  103005. */
  103006. isRenderTarget: boolean;
  103007. /**
  103008. * Define the unique id of the texture in the scene.
  103009. */
  103010. get uid(): string;
  103011. /**
  103012. * Return a string representation of the texture.
  103013. * @returns the texture as a string
  103014. */
  103015. toString(): string;
  103016. /**
  103017. * Get the class name of the texture.
  103018. * @returns "BaseTexture"
  103019. */
  103020. getClassName(): string;
  103021. /**
  103022. * Define the list of animation attached to the texture.
  103023. */
  103024. animations: Animation[];
  103025. /**
  103026. * An event triggered when the texture is disposed.
  103027. */
  103028. onDisposeObservable: Observable<BaseTexture>;
  103029. private _onDisposeObserver;
  103030. /**
  103031. * Callback triggered when the texture has been disposed.
  103032. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103033. */
  103034. set onDispose(callback: () => void);
  103035. /**
  103036. * Define the current state of the loading sequence when in delayed load mode.
  103037. */
  103038. delayLoadState: number;
  103039. private _scene;
  103040. /** @hidden */
  103041. _texture: Nullable<InternalTexture>;
  103042. private _uid;
  103043. /**
  103044. * Define if the texture is preventinga material to render or not.
  103045. * If not and the texture is not ready, the engine will use a default black texture instead.
  103046. */
  103047. get isBlocking(): boolean;
  103048. /**
  103049. * Instantiates a new BaseTexture.
  103050. * Base class of all the textures in babylon.
  103051. * It groups all the common properties the materials, post process, lights... might need
  103052. * in order to make a correct use of the texture.
  103053. * @param scene Define the scene the texture blongs to
  103054. */
  103055. constructor(scene: Nullable<Scene>);
  103056. /**
  103057. * Get the scene the texture belongs to.
  103058. * @returns the scene or null if undefined
  103059. */
  103060. getScene(): Nullable<Scene>;
  103061. /**
  103062. * Get the texture transform matrix used to offset tile the texture for istance.
  103063. * @returns the transformation matrix
  103064. */
  103065. getTextureMatrix(): Matrix;
  103066. /**
  103067. * Get the texture reflection matrix used to rotate/transform the reflection.
  103068. * @returns the reflection matrix
  103069. */
  103070. getReflectionTextureMatrix(): Matrix;
  103071. /**
  103072. * Get the underlying lower level texture from Babylon.
  103073. * @returns the insternal texture
  103074. */
  103075. getInternalTexture(): Nullable<InternalTexture>;
  103076. /**
  103077. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103078. * @returns true if ready or not blocking
  103079. */
  103080. isReadyOrNotBlocking(): boolean;
  103081. /**
  103082. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103083. * @returns true if fully ready
  103084. */
  103085. isReady(): boolean;
  103086. private _cachedSize;
  103087. /**
  103088. * Get the size of the texture.
  103089. * @returns the texture size.
  103090. */
  103091. getSize(): ISize;
  103092. /**
  103093. * Get the base size of the texture.
  103094. * It can be different from the size if the texture has been resized for POT for instance
  103095. * @returns the base size
  103096. */
  103097. getBaseSize(): ISize;
  103098. /**
  103099. * Update the sampling mode of the texture.
  103100. * Default is Trilinear mode.
  103101. *
  103102. * | Value | Type | Description |
  103103. * | ----- | ------------------ | ----------- |
  103104. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103105. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103106. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103107. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103108. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103109. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103110. * | 7 | NEAREST_LINEAR | |
  103111. * | 8 | NEAREST_NEAREST | |
  103112. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103113. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103114. * | 11 | LINEAR_LINEAR | |
  103115. * | 12 | LINEAR_NEAREST | |
  103116. *
  103117. * > _mag_: magnification filter (close to the viewer)
  103118. * > _min_: minification filter (far from the viewer)
  103119. * > _mip_: filter used between mip map levels
  103120. *@param samplingMode Define the new sampling mode of the texture
  103121. */
  103122. updateSamplingMode(samplingMode: number): void;
  103123. /**
  103124. * Scales the texture if is `canRescale()`
  103125. * @param ratio the resize factor we want to use to rescale
  103126. */
  103127. scale(ratio: number): void;
  103128. /**
  103129. * Get if the texture can rescale.
  103130. */
  103131. get canRescale(): boolean;
  103132. /** @hidden */
  103133. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103134. /** @hidden */
  103135. _rebuild(): void;
  103136. /**
  103137. * Triggers the load sequence in delayed load mode.
  103138. */
  103139. delayLoad(): void;
  103140. /**
  103141. * Clones the texture.
  103142. * @returns the cloned texture
  103143. */
  103144. clone(): Nullable<BaseTexture>;
  103145. /**
  103146. * Get the texture underlying type (INT, FLOAT...)
  103147. */
  103148. get textureType(): number;
  103149. /**
  103150. * Get the texture underlying format (RGB, RGBA...)
  103151. */
  103152. get textureFormat(): number;
  103153. /**
  103154. * Indicates that textures need to be re-calculated for all materials
  103155. */
  103156. protected _markAllSubMeshesAsTexturesDirty(): void;
  103157. /**
  103158. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103159. * This will returns an RGBA array buffer containing either in values (0-255) or
  103160. * float values (0-1) depending of the underlying buffer type.
  103161. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103162. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103163. * @param buffer defines a user defined buffer to fill with data (can be null)
  103164. * @returns The Array buffer containing the pixels data.
  103165. */
  103166. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103167. /**
  103168. * Release and destroy the underlying lower level texture aka internalTexture.
  103169. */
  103170. releaseInternalTexture(): void;
  103171. /** @hidden */
  103172. get _lodTextureHigh(): Nullable<BaseTexture>;
  103173. /** @hidden */
  103174. get _lodTextureMid(): Nullable<BaseTexture>;
  103175. /** @hidden */
  103176. get _lodTextureLow(): Nullable<BaseTexture>;
  103177. /**
  103178. * Dispose the texture and release its associated resources.
  103179. */
  103180. dispose(): void;
  103181. /**
  103182. * Serialize the texture into a JSON representation that can be parsed later on.
  103183. * @returns the JSON representation of the texture
  103184. */
  103185. serialize(): any;
  103186. /**
  103187. * Helper function to be called back once a list of texture contains only ready textures.
  103188. * @param textures Define the list of textures to wait for
  103189. * @param callback Define the callback triggered once the entire list will be ready
  103190. */
  103191. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103192. }
  103193. }
  103194. declare module BABYLON {
  103195. /**
  103196. * Options to be used when creating an effect.
  103197. */
  103198. export interface IEffectCreationOptions {
  103199. /**
  103200. * Atrributes that will be used in the shader.
  103201. */
  103202. attributes: string[];
  103203. /**
  103204. * Uniform varible names that will be set in the shader.
  103205. */
  103206. uniformsNames: string[];
  103207. /**
  103208. * Uniform buffer variable names that will be set in the shader.
  103209. */
  103210. uniformBuffersNames: string[];
  103211. /**
  103212. * Sampler texture variable names that will be set in the shader.
  103213. */
  103214. samplers: string[];
  103215. /**
  103216. * Define statements that will be set in the shader.
  103217. */
  103218. defines: any;
  103219. /**
  103220. * Possible fallbacks for this effect to improve performance when needed.
  103221. */
  103222. fallbacks: Nullable<IEffectFallbacks>;
  103223. /**
  103224. * Callback that will be called when the shader is compiled.
  103225. */
  103226. onCompiled: Nullable<(effect: Effect) => void>;
  103227. /**
  103228. * Callback that will be called if an error occurs during shader compilation.
  103229. */
  103230. onError: Nullable<(effect: Effect, errors: string) => void>;
  103231. /**
  103232. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103233. */
  103234. indexParameters?: any;
  103235. /**
  103236. * Max number of lights that can be used in the shader.
  103237. */
  103238. maxSimultaneousLights?: number;
  103239. /**
  103240. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103241. */
  103242. transformFeedbackVaryings?: Nullable<string[]>;
  103243. }
  103244. /**
  103245. * Effect containing vertex and fragment shader that can be executed on an object.
  103246. */
  103247. export class Effect implements IDisposable {
  103248. /**
  103249. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103250. */
  103251. static ShadersRepository: string;
  103252. /**
  103253. * Name of the effect.
  103254. */
  103255. name: any;
  103256. /**
  103257. * String container all the define statements that should be set on the shader.
  103258. */
  103259. defines: string;
  103260. /**
  103261. * Callback that will be called when the shader is compiled.
  103262. */
  103263. onCompiled: Nullable<(effect: Effect) => void>;
  103264. /**
  103265. * Callback that will be called if an error occurs during shader compilation.
  103266. */
  103267. onError: Nullable<(effect: Effect, errors: string) => void>;
  103268. /**
  103269. * Callback that will be called when effect is bound.
  103270. */
  103271. onBind: Nullable<(effect: Effect) => void>;
  103272. /**
  103273. * Unique ID of the effect.
  103274. */
  103275. uniqueId: number;
  103276. /**
  103277. * Observable that will be called when the shader is compiled.
  103278. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103279. */
  103280. onCompileObservable: Observable<Effect>;
  103281. /**
  103282. * Observable that will be called if an error occurs during shader compilation.
  103283. */
  103284. onErrorObservable: Observable<Effect>;
  103285. /** @hidden */
  103286. _onBindObservable: Nullable<Observable<Effect>>;
  103287. /**
  103288. * @hidden
  103289. * Specifies if the effect was previously ready
  103290. */
  103291. _wasPreviouslyReady: boolean;
  103292. /**
  103293. * Observable that will be called when effect is bound.
  103294. */
  103295. get onBindObservable(): Observable<Effect>;
  103296. /** @hidden */
  103297. _bonesComputationForcedToCPU: boolean;
  103298. private static _uniqueIdSeed;
  103299. private _engine;
  103300. private _uniformBuffersNames;
  103301. private _uniformsNames;
  103302. private _samplerList;
  103303. private _samplers;
  103304. private _isReady;
  103305. private _compilationError;
  103306. private _allFallbacksProcessed;
  103307. private _attributesNames;
  103308. private _attributes;
  103309. private _attributeLocationByName;
  103310. private _uniforms;
  103311. /**
  103312. * Key for the effect.
  103313. * @hidden
  103314. */
  103315. _key: string;
  103316. private _indexParameters;
  103317. private _fallbacks;
  103318. private _vertexSourceCode;
  103319. private _fragmentSourceCode;
  103320. private _vertexSourceCodeOverride;
  103321. private _fragmentSourceCodeOverride;
  103322. private _transformFeedbackVaryings;
  103323. /**
  103324. * Compiled shader to webGL program.
  103325. * @hidden
  103326. */
  103327. _pipelineContext: Nullable<IPipelineContext>;
  103328. private _valueCache;
  103329. private static _baseCache;
  103330. /**
  103331. * Instantiates an effect.
  103332. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103333. * @param baseName Name of the effect.
  103334. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103335. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103336. * @param samplers List of sampler variables that will be passed to the shader.
  103337. * @param engine Engine to be used to render the effect
  103338. * @param defines Define statements to be added to the shader.
  103339. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103340. * @param onCompiled Callback that will be called when the shader is compiled.
  103341. * @param onError Callback that will be called if an error occurs during shader compilation.
  103342. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103343. */
  103344. 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);
  103345. private _useFinalCode;
  103346. /**
  103347. * Unique key for this effect
  103348. */
  103349. get key(): string;
  103350. /**
  103351. * If the effect has been compiled and prepared.
  103352. * @returns if the effect is compiled and prepared.
  103353. */
  103354. isReady(): boolean;
  103355. private _isReadyInternal;
  103356. /**
  103357. * The engine the effect was initialized with.
  103358. * @returns the engine.
  103359. */
  103360. getEngine(): Engine;
  103361. /**
  103362. * The pipeline context for this effect
  103363. * @returns the associated pipeline context
  103364. */
  103365. getPipelineContext(): Nullable<IPipelineContext>;
  103366. /**
  103367. * The set of names of attribute variables for the shader.
  103368. * @returns An array of attribute names.
  103369. */
  103370. getAttributesNames(): string[];
  103371. /**
  103372. * Returns the attribute at the given index.
  103373. * @param index The index of the attribute.
  103374. * @returns The location of the attribute.
  103375. */
  103376. getAttributeLocation(index: number): number;
  103377. /**
  103378. * Returns the attribute based on the name of the variable.
  103379. * @param name of the attribute to look up.
  103380. * @returns the attribute location.
  103381. */
  103382. getAttributeLocationByName(name: string): number;
  103383. /**
  103384. * The number of attributes.
  103385. * @returns the numnber of attributes.
  103386. */
  103387. getAttributesCount(): number;
  103388. /**
  103389. * Gets the index of a uniform variable.
  103390. * @param uniformName of the uniform to look up.
  103391. * @returns the index.
  103392. */
  103393. getUniformIndex(uniformName: string): number;
  103394. /**
  103395. * Returns the attribute based on the name of the variable.
  103396. * @param uniformName of the uniform to look up.
  103397. * @returns the location of the uniform.
  103398. */
  103399. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103400. /**
  103401. * Returns an array of sampler variable names
  103402. * @returns The array of sampler variable neames.
  103403. */
  103404. getSamplers(): string[];
  103405. /**
  103406. * The error from the last compilation.
  103407. * @returns the error string.
  103408. */
  103409. getCompilationError(): string;
  103410. /**
  103411. * Gets a boolean indicating that all fallbacks were used during compilation
  103412. * @returns true if all fallbacks were used
  103413. */
  103414. allFallbacksProcessed(): boolean;
  103415. /**
  103416. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103417. * @param func The callback to be used.
  103418. */
  103419. executeWhenCompiled(func: (effect: Effect) => void): void;
  103420. private _checkIsReady;
  103421. private _loadShader;
  103422. /**
  103423. * Recompiles the webGL program
  103424. * @param vertexSourceCode The source code for the vertex shader.
  103425. * @param fragmentSourceCode The source code for the fragment shader.
  103426. * @param onCompiled Callback called when completed.
  103427. * @param onError Callback called on error.
  103428. * @hidden
  103429. */
  103430. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103431. /**
  103432. * Prepares the effect
  103433. * @hidden
  103434. */
  103435. _prepareEffect(): void;
  103436. private _processCompilationErrors;
  103437. /**
  103438. * Checks if the effect is supported. (Must be called after compilation)
  103439. */
  103440. get isSupported(): boolean;
  103441. /**
  103442. * Binds a texture to the engine to be used as output of the shader.
  103443. * @param channel Name of the output variable.
  103444. * @param texture Texture to bind.
  103445. * @hidden
  103446. */
  103447. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103448. /**
  103449. * Sets a texture on the engine to be used in the shader.
  103450. * @param channel Name of the sampler variable.
  103451. * @param texture Texture to set.
  103452. */
  103453. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103454. /**
  103455. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103456. * @param channel Name of the sampler variable.
  103457. * @param texture Texture to set.
  103458. */
  103459. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103460. /**
  103461. * Sets an array of textures on the engine to be used in the shader.
  103462. * @param channel Name of the variable.
  103463. * @param textures Textures to set.
  103464. */
  103465. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103466. /**
  103467. * 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)
  103468. * @param channel Name of the sampler variable.
  103469. * @param postProcess Post process to get the input texture from.
  103470. */
  103471. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103472. /**
  103473. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103474. * 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)
  103475. * @param channel Name of the sampler variable.
  103476. * @param postProcess Post process to get the output texture from.
  103477. */
  103478. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103479. /** @hidden */
  103480. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103481. /** @hidden */
  103482. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103483. /** @hidden */
  103484. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103485. /** @hidden */
  103486. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103487. /**
  103488. * Binds a buffer to a uniform.
  103489. * @param buffer Buffer to bind.
  103490. * @param name Name of the uniform variable to bind to.
  103491. */
  103492. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103493. /**
  103494. * Binds block to a uniform.
  103495. * @param blockName Name of the block to bind.
  103496. * @param index Index to bind.
  103497. */
  103498. bindUniformBlock(blockName: string, index: number): void;
  103499. /**
  103500. * Sets an interger value on a uniform variable.
  103501. * @param uniformName Name of the variable.
  103502. * @param value Value to be set.
  103503. * @returns this effect.
  103504. */
  103505. setInt(uniformName: string, value: number): Effect;
  103506. /**
  103507. * Sets an int array on a uniform variable.
  103508. * @param uniformName Name of the variable.
  103509. * @param array array to be set.
  103510. * @returns this effect.
  103511. */
  103512. setIntArray(uniformName: string, array: Int32Array): Effect;
  103513. /**
  103514. * 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)
  103515. * @param uniformName Name of the variable.
  103516. * @param array array to be set.
  103517. * @returns this effect.
  103518. */
  103519. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103520. /**
  103521. * 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)
  103522. * @param uniformName Name of the variable.
  103523. * @param array array to be set.
  103524. * @returns this effect.
  103525. */
  103526. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103527. /**
  103528. * 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)
  103529. * @param uniformName Name of the variable.
  103530. * @param array array to be set.
  103531. * @returns this effect.
  103532. */
  103533. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103534. /**
  103535. * Sets an float array on a uniform variable.
  103536. * @param uniformName Name of the variable.
  103537. * @param array array to be set.
  103538. * @returns this effect.
  103539. */
  103540. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103541. /**
  103542. * 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)
  103543. * @param uniformName Name of the variable.
  103544. * @param array array to be set.
  103545. * @returns this effect.
  103546. */
  103547. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103548. /**
  103549. * 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)
  103550. * @param uniformName Name of the variable.
  103551. * @param array array to be set.
  103552. * @returns this effect.
  103553. */
  103554. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103555. /**
  103556. * 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)
  103557. * @param uniformName Name of the variable.
  103558. * @param array array to be set.
  103559. * @returns this effect.
  103560. */
  103561. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103562. /**
  103563. * Sets an array on a uniform variable.
  103564. * @param uniformName Name of the variable.
  103565. * @param array array to be set.
  103566. * @returns this effect.
  103567. */
  103568. setArray(uniformName: string, array: number[]): Effect;
  103569. /**
  103570. * 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)
  103571. * @param uniformName Name of the variable.
  103572. * @param array array to be set.
  103573. * @returns this effect.
  103574. */
  103575. setArray2(uniformName: string, array: number[]): Effect;
  103576. /**
  103577. * 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)
  103578. * @param uniformName Name of the variable.
  103579. * @param array array to be set.
  103580. * @returns this effect.
  103581. */
  103582. setArray3(uniformName: string, array: number[]): Effect;
  103583. /**
  103584. * 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)
  103585. * @param uniformName Name of the variable.
  103586. * @param array array to be set.
  103587. * @returns this effect.
  103588. */
  103589. setArray4(uniformName: string, array: number[]): Effect;
  103590. /**
  103591. * Sets matrices on a uniform variable.
  103592. * @param uniformName Name of the variable.
  103593. * @param matrices matrices to be set.
  103594. * @returns this effect.
  103595. */
  103596. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103597. /**
  103598. * Sets matrix on a uniform variable.
  103599. * @param uniformName Name of the variable.
  103600. * @param matrix matrix to be set.
  103601. * @returns this effect.
  103602. */
  103603. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103604. /**
  103605. * 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)
  103606. * @param uniformName Name of the variable.
  103607. * @param matrix matrix to be set.
  103608. * @returns this effect.
  103609. */
  103610. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103611. /**
  103612. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103613. * @param uniformName Name of the variable.
  103614. * @param matrix matrix to be set.
  103615. * @returns this effect.
  103616. */
  103617. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103618. /**
  103619. * Sets a float on a uniform variable.
  103620. * @param uniformName Name of the variable.
  103621. * @param value value to be set.
  103622. * @returns this effect.
  103623. */
  103624. setFloat(uniformName: string, value: number): Effect;
  103625. /**
  103626. * Sets a boolean on a uniform variable.
  103627. * @param uniformName Name of the variable.
  103628. * @param bool value to be set.
  103629. * @returns this effect.
  103630. */
  103631. setBool(uniformName: string, bool: boolean): Effect;
  103632. /**
  103633. * Sets a Vector2 on a uniform variable.
  103634. * @param uniformName Name of the variable.
  103635. * @param vector2 vector2 to be set.
  103636. * @returns this effect.
  103637. */
  103638. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103639. /**
  103640. * Sets a float2 on a uniform variable.
  103641. * @param uniformName Name of the variable.
  103642. * @param x First float in float2.
  103643. * @param y Second float in float2.
  103644. * @returns this effect.
  103645. */
  103646. setFloat2(uniformName: string, x: number, y: number): Effect;
  103647. /**
  103648. * Sets a Vector3 on a uniform variable.
  103649. * @param uniformName Name of the variable.
  103650. * @param vector3 Value to be set.
  103651. * @returns this effect.
  103652. */
  103653. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103654. /**
  103655. * Sets a float3 on a uniform variable.
  103656. * @param uniformName Name of the variable.
  103657. * @param x First float in float3.
  103658. * @param y Second float in float3.
  103659. * @param z Third float in float3.
  103660. * @returns this effect.
  103661. */
  103662. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103663. /**
  103664. * Sets a Vector4 on a uniform variable.
  103665. * @param uniformName Name of the variable.
  103666. * @param vector4 Value to be set.
  103667. * @returns this effect.
  103668. */
  103669. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103670. /**
  103671. * Sets a float4 on a uniform variable.
  103672. * @param uniformName Name of the variable.
  103673. * @param x First float in float4.
  103674. * @param y Second float in float4.
  103675. * @param z Third float in float4.
  103676. * @param w Fourth float in float4.
  103677. * @returns this effect.
  103678. */
  103679. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103680. /**
  103681. * Sets a Color3 on a uniform variable.
  103682. * @param uniformName Name of the variable.
  103683. * @param color3 Value to be set.
  103684. * @returns this effect.
  103685. */
  103686. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103687. /**
  103688. * Sets a Color4 on a uniform variable.
  103689. * @param uniformName Name of the variable.
  103690. * @param color3 Value to be set.
  103691. * @param alpha Alpha value to be set.
  103692. * @returns this effect.
  103693. */
  103694. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103695. /**
  103696. * Sets a Color4 on a uniform variable
  103697. * @param uniformName defines the name of the variable
  103698. * @param color4 defines the value to be set
  103699. * @returns this effect.
  103700. */
  103701. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103702. /** Release all associated resources */
  103703. dispose(): void;
  103704. /**
  103705. * This function will add a new shader to the shader store
  103706. * @param name the name of the shader
  103707. * @param pixelShader optional pixel shader content
  103708. * @param vertexShader optional vertex shader content
  103709. */
  103710. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103711. /**
  103712. * Store of each shader (The can be looked up using effect.key)
  103713. */
  103714. static ShadersStore: {
  103715. [key: string]: string;
  103716. };
  103717. /**
  103718. * Store of each included file for a shader (The can be looked up using effect.key)
  103719. */
  103720. static IncludesShadersStore: {
  103721. [key: string]: string;
  103722. };
  103723. /**
  103724. * Resets the cache of effects.
  103725. */
  103726. static ResetCache(): void;
  103727. }
  103728. }
  103729. declare module BABYLON {
  103730. /**
  103731. * Interface used to describe the capabilities of the engine relatively to the current browser
  103732. */
  103733. export interface EngineCapabilities {
  103734. /** Maximum textures units per fragment shader */
  103735. maxTexturesImageUnits: number;
  103736. /** Maximum texture units per vertex shader */
  103737. maxVertexTextureImageUnits: number;
  103738. /** Maximum textures units in the entire pipeline */
  103739. maxCombinedTexturesImageUnits: number;
  103740. /** Maximum texture size */
  103741. maxTextureSize: number;
  103742. /** Maximum texture samples */
  103743. maxSamples?: number;
  103744. /** Maximum cube texture size */
  103745. maxCubemapTextureSize: number;
  103746. /** Maximum render texture size */
  103747. maxRenderTextureSize: number;
  103748. /** Maximum number of vertex attributes */
  103749. maxVertexAttribs: number;
  103750. /** Maximum number of varyings */
  103751. maxVaryingVectors: number;
  103752. /** Maximum number of uniforms per vertex shader */
  103753. maxVertexUniformVectors: number;
  103754. /** Maximum number of uniforms per fragment shader */
  103755. maxFragmentUniformVectors: number;
  103756. /** Defines if standard derivates (dx/dy) are supported */
  103757. standardDerivatives: boolean;
  103758. /** Defines if s3tc texture compression is supported */
  103759. s3tc?: WEBGL_compressed_texture_s3tc;
  103760. /** Defines if pvrtc texture compression is supported */
  103761. pvrtc: any;
  103762. /** Defines if etc1 texture compression is supported */
  103763. etc1: any;
  103764. /** Defines if etc2 texture compression is supported */
  103765. etc2: any;
  103766. /** Defines if astc texture compression is supported */
  103767. astc: any;
  103768. /** Defines if float textures are supported */
  103769. textureFloat: boolean;
  103770. /** Defines if vertex array objects are supported */
  103771. vertexArrayObject: boolean;
  103772. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103773. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103774. /** Gets the maximum level of anisotropy supported */
  103775. maxAnisotropy: number;
  103776. /** Defines if instancing is supported */
  103777. instancedArrays: boolean;
  103778. /** Defines if 32 bits indices are supported */
  103779. uintIndices: boolean;
  103780. /** Defines if high precision shaders are supported */
  103781. highPrecisionShaderSupported: boolean;
  103782. /** Defines if depth reading in the fragment shader is supported */
  103783. fragmentDepthSupported: boolean;
  103784. /** Defines if float texture linear filtering is supported*/
  103785. textureFloatLinearFiltering: boolean;
  103786. /** Defines if rendering to float textures is supported */
  103787. textureFloatRender: boolean;
  103788. /** Defines if half float textures are supported*/
  103789. textureHalfFloat: boolean;
  103790. /** Defines if half float texture linear filtering is supported*/
  103791. textureHalfFloatLinearFiltering: boolean;
  103792. /** Defines if rendering to half float textures is supported */
  103793. textureHalfFloatRender: boolean;
  103794. /** Defines if textureLOD shader command is supported */
  103795. textureLOD: boolean;
  103796. /** Defines if draw buffers extension is supported */
  103797. drawBuffersExtension: boolean;
  103798. /** Defines if depth textures are supported */
  103799. depthTextureExtension: boolean;
  103800. /** Defines if float color buffer are supported */
  103801. colorBufferFloat: boolean;
  103802. /** Gets disjoint timer query extension (null if not supported) */
  103803. timerQuery?: EXT_disjoint_timer_query;
  103804. /** Defines if timestamp can be used with timer query */
  103805. canUseTimestampForTimerQuery: boolean;
  103806. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103807. multiview?: any;
  103808. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103809. oculusMultiview?: any;
  103810. /** Function used to let the system compiles shaders in background */
  103811. parallelShaderCompile?: {
  103812. COMPLETION_STATUS_KHR: number;
  103813. };
  103814. /** Max number of texture samples for MSAA */
  103815. maxMSAASamples: number;
  103816. /** Defines if the blend min max extension is supported */
  103817. blendMinMax: boolean;
  103818. }
  103819. }
  103820. declare module BABYLON {
  103821. /**
  103822. * @hidden
  103823. **/
  103824. export class DepthCullingState {
  103825. private _isDepthTestDirty;
  103826. private _isDepthMaskDirty;
  103827. private _isDepthFuncDirty;
  103828. private _isCullFaceDirty;
  103829. private _isCullDirty;
  103830. private _isZOffsetDirty;
  103831. private _isFrontFaceDirty;
  103832. private _depthTest;
  103833. private _depthMask;
  103834. private _depthFunc;
  103835. private _cull;
  103836. private _cullFace;
  103837. private _zOffset;
  103838. private _frontFace;
  103839. /**
  103840. * Initializes the state.
  103841. */
  103842. constructor();
  103843. get isDirty(): boolean;
  103844. get zOffset(): number;
  103845. set zOffset(value: number);
  103846. get cullFace(): Nullable<number>;
  103847. set cullFace(value: Nullable<number>);
  103848. get cull(): Nullable<boolean>;
  103849. set cull(value: Nullable<boolean>);
  103850. get depthFunc(): Nullable<number>;
  103851. set depthFunc(value: Nullable<number>);
  103852. get depthMask(): boolean;
  103853. set depthMask(value: boolean);
  103854. get depthTest(): boolean;
  103855. set depthTest(value: boolean);
  103856. get frontFace(): Nullable<number>;
  103857. set frontFace(value: Nullable<number>);
  103858. reset(): void;
  103859. apply(gl: WebGLRenderingContext): void;
  103860. }
  103861. }
  103862. declare module BABYLON {
  103863. /**
  103864. * @hidden
  103865. **/
  103866. export class StencilState {
  103867. /** 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 */
  103868. static readonly ALWAYS: number;
  103869. /** Passed to stencilOperation to specify that stencil value must be kept */
  103870. static readonly KEEP: number;
  103871. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103872. static readonly REPLACE: number;
  103873. private _isStencilTestDirty;
  103874. private _isStencilMaskDirty;
  103875. private _isStencilFuncDirty;
  103876. private _isStencilOpDirty;
  103877. private _stencilTest;
  103878. private _stencilMask;
  103879. private _stencilFunc;
  103880. private _stencilFuncRef;
  103881. private _stencilFuncMask;
  103882. private _stencilOpStencilFail;
  103883. private _stencilOpDepthFail;
  103884. private _stencilOpStencilDepthPass;
  103885. get isDirty(): boolean;
  103886. get stencilFunc(): number;
  103887. set stencilFunc(value: number);
  103888. get stencilFuncRef(): number;
  103889. set stencilFuncRef(value: number);
  103890. get stencilFuncMask(): number;
  103891. set stencilFuncMask(value: number);
  103892. get stencilOpStencilFail(): number;
  103893. set stencilOpStencilFail(value: number);
  103894. get stencilOpDepthFail(): number;
  103895. set stencilOpDepthFail(value: number);
  103896. get stencilOpStencilDepthPass(): number;
  103897. set stencilOpStencilDepthPass(value: number);
  103898. get stencilMask(): number;
  103899. set stencilMask(value: number);
  103900. get stencilTest(): boolean;
  103901. set stencilTest(value: boolean);
  103902. constructor();
  103903. reset(): void;
  103904. apply(gl: WebGLRenderingContext): void;
  103905. }
  103906. }
  103907. declare module BABYLON {
  103908. /**
  103909. * @hidden
  103910. **/
  103911. export class AlphaState {
  103912. private _isAlphaBlendDirty;
  103913. private _isBlendFunctionParametersDirty;
  103914. private _isBlendEquationParametersDirty;
  103915. private _isBlendConstantsDirty;
  103916. private _alphaBlend;
  103917. private _blendFunctionParameters;
  103918. private _blendEquationParameters;
  103919. private _blendConstants;
  103920. /**
  103921. * Initializes the state.
  103922. */
  103923. constructor();
  103924. get isDirty(): boolean;
  103925. get alphaBlend(): boolean;
  103926. set alphaBlend(value: boolean);
  103927. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103928. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103929. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103930. reset(): void;
  103931. apply(gl: WebGLRenderingContext): void;
  103932. }
  103933. }
  103934. declare module BABYLON {
  103935. /** @hidden */
  103936. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103937. attributeProcessor(attribute: string): string;
  103938. varyingProcessor(varying: string, isFragment: boolean): string;
  103939. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103940. }
  103941. }
  103942. declare module BABYLON {
  103943. /**
  103944. * Interface for attribute information associated with buffer instanciation
  103945. */
  103946. export interface InstancingAttributeInfo {
  103947. /**
  103948. * Name of the GLSL attribute
  103949. * if attribute index is not specified, this is used to retrieve the index from the effect
  103950. */
  103951. attributeName: string;
  103952. /**
  103953. * Index/offset of the attribute in the vertex shader
  103954. * if not specified, this will be computes from the name.
  103955. */
  103956. index?: number;
  103957. /**
  103958. * size of the attribute, 1, 2, 3 or 4
  103959. */
  103960. attributeSize: number;
  103961. /**
  103962. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103963. */
  103964. offset: number;
  103965. /**
  103966. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103967. * default to 1
  103968. */
  103969. divisor?: number;
  103970. /**
  103971. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103972. * default is FLOAT
  103973. */
  103974. attributeType?: number;
  103975. /**
  103976. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103977. */
  103978. normalized?: boolean;
  103979. }
  103980. }
  103981. declare module BABYLON {
  103982. interface ThinEngine {
  103983. /**
  103984. * Update a video texture
  103985. * @param texture defines the texture to update
  103986. * @param video defines the video element to use
  103987. * @param invertY defines if data must be stored with Y axis inverted
  103988. */
  103989. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103990. }
  103991. }
  103992. declare module BABYLON {
  103993. /**
  103994. * Settings for finer control over video usage
  103995. */
  103996. export interface VideoTextureSettings {
  103997. /**
  103998. * Applies `autoplay` to video, if specified
  103999. */
  104000. autoPlay?: boolean;
  104001. /**
  104002. * Applies `loop` to video, if specified
  104003. */
  104004. loop?: boolean;
  104005. /**
  104006. * Automatically updates internal texture from video at every frame in the render loop
  104007. */
  104008. autoUpdateTexture: boolean;
  104009. /**
  104010. * Image src displayed during the video loading or until the user interacts with the video.
  104011. */
  104012. poster?: string;
  104013. }
  104014. /**
  104015. * If you want to display a video in your scene, this is the special texture for that.
  104016. * This special texture works similar to other textures, with the exception of a few parameters.
  104017. * @see https://doc.babylonjs.com/how_to/video_texture
  104018. */
  104019. export class VideoTexture extends Texture {
  104020. /**
  104021. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104022. */
  104023. readonly autoUpdateTexture: boolean;
  104024. /**
  104025. * The video instance used by the texture internally
  104026. */
  104027. readonly video: HTMLVideoElement;
  104028. private _onUserActionRequestedObservable;
  104029. /**
  104030. * Event triggerd when a dom action is required by the user to play the video.
  104031. * This happens due to recent changes in browser policies preventing video to auto start.
  104032. */
  104033. get onUserActionRequestedObservable(): Observable<Texture>;
  104034. private _generateMipMaps;
  104035. private _engine;
  104036. private _stillImageCaptured;
  104037. private _displayingPosterTexture;
  104038. private _settings;
  104039. private _createInternalTextureOnEvent;
  104040. private _frameId;
  104041. private _currentSrc;
  104042. /**
  104043. * Creates a video texture.
  104044. * If you want to display a video in your scene, this is the special texture for that.
  104045. * This special texture works similar to other textures, with the exception of a few parameters.
  104046. * @see https://doc.babylonjs.com/how_to/video_texture
  104047. * @param name optional name, will detect from video source, if not defined
  104048. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104049. * @param scene is obviously the current scene.
  104050. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104051. * @param invertY is false by default but can be used to invert video on Y axis
  104052. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104053. * @param settings allows finer control over video usage
  104054. */
  104055. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104056. private _getName;
  104057. private _getVideo;
  104058. private _createInternalTexture;
  104059. private reset;
  104060. /**
  104061. * @hidden Internal method to initiate `update`.
  104062. */
  104063. _rebuild(): void;
  104064. /**
  104065. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104066. */
  104067. update(): void;
  104068. /**
  104069. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104070. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104071. */
  104072. updateTexture(isVisible: boolean): void;
  104073. protected _updateInternalTexture: () => void;
  104074. /**
  104075. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104076. * @param url New url.
  104077. */
  104078. updateURL(url: string): void;
  104079. /**
  104080. * Clones the texture.
  104081. * @returns the cloned texture
  104082. */
  104083. clone(): VideoTexture;
  104084. /**
  104085. * Dispose the texture and release its associated resources.
  104086. */
  104087. dispose(): void;
  104088. /**
  104089. * Creates a video texture straight from a stream.
  104090. * @param scene Define the scene the texture should be created in
  104091. * @param stream Define the stream the texture should be created from
  104092. * @returns The created video texture as a promise
  104093. */
  104094. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104095. /**
  104096. * Creates a video texture straight from your WebCam video feed.
  104097. * @param scene Define the scene the texture should be created in
  104098. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104099. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104100. * @returns The created video texture as a promise
  104101. */
  104102. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104103. minWidth: number;
  104104. maxWidth: number;
  104105. minHeight: number;
  104106. maxHeight: number;
  104107. deviceId: string;
  104108. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104109. /**
  104110. * Creates a video texture straight from your WebCam video feed.
  104111. * @param scene Define the scene the texture should be created in
  104112. * @param onReady Define a callback to triggered once the texture will be ready
  104113. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104114. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104115. */
  104116. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104117. minWidth: number;
  104118. maxWidth: number;
  104119. minHeight: number;
  104120. maxHeight: number;
  104121. deviceId: string;
  104122. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104123. }
  104124. }
  104125. declare module BABYLON {
  104126. /**
  104127. * Defines the interface used by objects working like Scene
  104128. * @hidden
  104129. */
  104130. interface ISceneLike {
  104131. _addPendingData(data: any): void;
  104132. _removePendingData(data: any): void;
  104133. offlineProvider: IOfflineProvider;
  104134. }
  104135. /** Interface defining initialization parameters for Engine class */
  104136. export interface EngineOptions extends WebGLContextAttributes {
  104137. /**
  104138. * Defines if the engine should no exceed a specified device ratio
  104139. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104140. */
  104141. limitDeviceRatio?: number;
  104142. /**
  104143. * Defines if webvr should be enabled automatically
  104144. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104145. */
  104146. autoEnableWebVR?: boolean;
  104147. /**
  104148. * Defines if webgl2 should be turned off even if supported
  104149. * @see http://doc.babylonjs.com/features/webgl2
  104150. */
  104151. disableWebGL2Support?: boolean;
  104152. /**
  104153. * Defines if webaudio should be initialized as well
  104154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104155. */
  104156. audioEngine?: boolean;
  104157. /**
  104158. * Defines if animations should run using a deterministic lock step
  104159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104160. */
  104161. deterministicLockstep?: boolean;
  104162. /** Defines the maximum steps to use with deterministic lock step mode */
  104163. lockstepMaxSteps?: number;
  104164. /** Defines the seconds between each deterministic lock step */
  104165. timeStep?: number;
  104166. /**
  104167. * Defines that engine should ignore context lost events
  104168. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104169. */
  104170. doNotHandleContextLost?: boolean;
  104171. /**
  104172. * Defines that engine should ignore modifying touch action attribute and style
  104173. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104174. */
  104175. doNotHandleTouchAction?: boolean;
  104176. /**
  104177. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104178. */
  104179. useHighPrecisionFloats?: boolean;
  104180. }
  104181. /**
  104182. * The base engine class (root of all engines)
  104183. */
  104184. export class ThinEngine {
  104185. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104186. static ExceptionList: ({
  104187. key: string;
  104188. capture: string;
  104189. captureConstraint: number;
  104190. targets: string[];
  104191. } | {
  104192. key: string;
  104193. capture: null;
  104194. captureConstraint: null;
  104195. targets: string[];
  104196. })[];
  104197. /** @hidden */
  104198. static _TextureLoaders: IInternalTextureLoader[];
  104199. /**
  104200. * Returns the current npm package of the sdk
  104201. */
  104202. static get NpmPackage(): string;
  104203. /**
  104204. * Returns the current version of the framework
  104205. */
  104206. static get Version(): string;
  104207. /**
  104208. * Returns a string describing the current engine
  104209. */
  104210. get description(): string;
  104211. /**
  104212. * Gets or sets the epsilon value used by collision engine
  104213. */
  104214. static CollisionsEpsilon: number;
  104215. /**
  104216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104217. */
  104218. static get ShadersRepository(): string;
  104219. static set ShadersRepository(value: string);
  104220. /**
  104221. * Gets or sets the textures that the engine should not attempt to load as compressed
  104222. */
  104223. protected _excludedCompressedTextures: string[];
  104224. /**
  104225. * Filters the compressed texture formats to only include
  104226. * files that are not included in the skippable list
  104227. *
  104228. * @param url the current extension
  104229. * @param textureFormatInUse the current compressed texture format
  104230. * @returns "format" string
  104231. */
  104232. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104233. /** @hidden */
  104234. _shaderProcessor: IShaderProcessor;
  104235. /**
  104236. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104237. */
  104238. forcePOTTextures: boolean;
  104239. /**
  104240. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104241. */
  104242. isFullscreen: boolean;
  104243. /**
  104244. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104245. */
  104246. cullBackFaces: boolean;
  104247. /**
  104248. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104249. */
  104250. renderEvenInBackground: boolean;
  104251. /**
  104252. * Gets or sets a boolean indicating that cache can be kept between frames
  104253. */
  104254. preventCacheWipeBetweenFrames: boolean;
  104255. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104256. validateShaderPrograms: boolean;
  104257. /**
  104258. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104259. * This can provide greater z depth for distant objects.
  104260. */
  104261. useReverseDepthBuffer: boolean;
  104262. /**
  104263. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104264. */
  104265. disableUniformBuffers: boolean;
  104266. /** @hidden */
  104267. _uniformBuffers: UniformBuffer[];
  104268. /**
  104269. * Gets a boolean indicating that the engine supports uniform buffers
  104270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104271. */
  104272. get supportsUniformBuffers(): boolean;
  104273. /** @hidden */
  104274. _gl: WebGLRenderingContext;
  104275. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104276. protected _windowIsBackground: boolean;
  104277. protected _webGLVersion: number;
  104278. protected _creationOptions: EngineOptions;
  104279. protected _highPrecisionShadersAllowed: boolean;
  104280. /** @hidden */
  104281. get _shouldUseHighPrecisionShader(): boolean;
  104282. /**
  104283. * Gets a boolean indicating that only power of 2 textures are supported
  104284. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104285. */
  104286. get needPOTTextures(): boolean;
  104287. /** @hidden */
  104288. _badOS: boolean;
  104289. /** @hidden */
  104290. _badDesktopOS: boolean;
  104291. private _hardwareScalingLevel;
  104292. /** @hidden */
  104293. _caps: EngineCapabilities;
  104294. private _isStencilEnable;
  104295. private _glVersion;
  104296. private _glRenderer;
  104297. private _glVendor;
  104298. /** @hidden */
  104299. _videoTextureSupported: boolean;
  104300. protected _renderingQueueLaunched: boolean;
  104301. protected _activeRenderLoops: (() => void)[];
  104302. /**
  104303. * Observable signaled when a context lost event is raised
  104304. */
  104305. onContextLostObservable: Observable<ThinEngine>;
  104306. /**
  104307. * Observable signaled when a context restored event is raised
  104308. */
  104309. onContextRestoredObservable: Observable<ThinEngine>;
  104310. private _onContextLost;
  104311. private _onContextRestored;
  104312. protected _contextWasLost: boolean;
  104313. /** @hidden */
  104314. _doNotHandleContextLost: boolean;
  104315. /**
  104316. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104318. */
  104319. get doNotHandleContextLost(): boolean;
  104320. set doNotHandleContextLost(value: boolean);
  104321. /**
  104322. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104323. */
  104324. disableVertexArrayObjects: boolean;
  104325. /** @hidden */
  104326. protected _colorWrite: boolean;
  104327. /** @hidden */
  104328. protected _colorWriteChanged: boolean;
  104329. /** @hidden */
  104330. protected _depthCullingState: DepthCullingState;
  104331. /** @hidden */
  104332. protected _stencilState: StencilState;
  104333. /** @hidden */
  104334. _alphaState: AlphaState;
  104335. /** @hidden */
  104336. _alphaMode: number;
  104337. /** @hidden */
  104338. _alphaEquation: number;
  104339. /** @hidden */
  104340. _internalTexturesCache: InternalTexture[];
  104341. /** @hidden */
  104342. protected _activeChannel: number;
  104343. private _currentTextureChannel;
  104344. /** @hidden */
  104345. protected _boundTexturesCache: {
  104346. [key: string]: Nullable<InternalTexture>;
  104347. };
  104348. /** @hidden */
  104349. protected _currentEffect: Nullable<Effect>;
  104350. /** @hidden */
  104351. protected _currentProgram: Nullable<WebGLProgram>;
  104352. private _compiledEffects;
  104353. private _vertexAttribArraysEnabled;
  104354. /** @hidden */
  104355. protected _cachedViewport: Nullable<IViewportLike>;
  104356. private _cachedVertexArrayObject;
  104357. /** @hidden */
  104358. protected _cachedVertexBuffers: any;
  104359. /** @hidden */
  104360. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104361. /** @hidden */
  104362. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104363. /** @hidden */
  104364. _currentRenderTarget: Nullable<InternalTexture>;
  104365. private _uintIndicesCurrentlySet;
  104366. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104367. /** @hidden */
  104368. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104369. private _currentBufferPointers;
  104370. private _currentInstanceLocations;
  104371. private _currentInstanceBuffers;
  104372. private _textureUnits;
  104373. /** @hidden */
  104374. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104375. /** @hidden */
  104376. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104377. /** @hidden */
  104378. _boundRenderFunction: any;
  104379. private _vaoRecordInProgress;
  104380. private _mustWipeVertexAttributes;
  104381. private _emptyTexture;
  104382. private _emptyCubeTexture;
  104383. private _emptyTexture3D;
  104384. private _emptyTexture2DArray;
  104385. /** @hidden */
  104386. _frameHandler: number;
  104387. private _nextFreeTextureSlots;
  104388. private _maxSimultaneousTextures;
  104389. private _activeRequests;
  104390. protected _texturesSupported: string[];
  104391. /** @hidden */
  104392. _textureFormatInUse: Nullable<string>;
  104393. protected get _supportsHardwareTextureRescaling(): boolean;
  104394. /**
  104395. * Gets the list of texture formats supported
  104396. */
  104397. get texturesSupported(): Array<string>;
  104398. /**
  104399. * Gets the list of texture formats in use
  104400. */
  104401. get textureFormatInUse(): Nullable<string>;
  104402. /**
  104403. * Gets the current viewport
  104404. */
  104405. get currentViewport(): Nullable<IViewportLike>;
  104406. /**
  104407. * Gets the default empty texture
  104408. */
  104409. get emptyTexture(): InternalTexture;
  104410. /**
  104411. * Gets the default empty 3D texture
  104412. */
  104413. get emptyTexture3D(): InternalTexture;
  104414. /**
  104415. * Gets the default empty 2D array texture
  104416. */
  104417. get emptyTexture2DArray(): InternalTexture;
  104418. /**
  104419. * Gets the default empty cube texture
  104420. */
  104421. get emptyCubeTexture(): InternalTexture;
  104422. /**
  104423. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104424. */
  104425. readonly premultipliedAlpha: boolean;
  104426. /**
  104427. * Observable event triggered before each texture is initialized
  104428. */
  104429. onBeforeTextureInitObservable: Observable<Texture>;
  104430. /**
  104431. * Creates a new engine
  104432. * @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
  104433. * @param antialias defines enable antialiasing (default: false)
  104434. * @param options defines further options to be sent to the getContext() function
  104435. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104436. */
  104437. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104438. private _rebuildInternalTextures;
  104439. private _rebuildEffects;
  104440. /**
  104441. * Gets a boolean indicating if all created effects are ready
  104442. * @returns true if all effects are ready
  104443. */
  104444. areAllEffectsReady(): boolean;
  104445. protected _rebuildBuffers(): void;
  104446. private _initGLContext;
  104447. /**
  104448. * Gets version of the current webGL context
  104449. */
  104450. get webGLVersion(): number;
  104451. /**
  104452. * Gets a string idenfifying the name of the class
  104453. * @returns "Engine" string
  104454. */
  104455. getClassName(): string;
  104456. /**
  104457. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104458. */
  104459. get isStencilEnable(): boolean;
  104460. /** @hidden */
  104461. _prepareWorkingCanvas(): void;
  104462. /**
  104463. * Reset the texture cache to empty state
  104464. */
  104465. resetTextureCache(): void;
  104466. /**
  104467. * Gets an object containing information about the current webGL context
  104468. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104469. */
  104470. getGlInfo(): {
  104471. vendor: string;
  104472. renderer: string;
  104473. version: string;
  104474. };
  104475. /**
  104476. * Defines the hardware scaling level.
  104477. * By default the hardware scaling level is computed from the window device ratio.
  104478. * 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.
  104479. * @param level defines the level to use
  104480. */
  104481. setHardwareScalingLevel(level: number): void;
  104482. /**
  104483. * Gets the current hardware scaling level.
  104484. * By default the hardware scaling level is computed from the window device ratio.
  104485. * 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.
  104486. * @returns a number indicating the current hardware scaling level
  104487. */
  104488. getHardwareScalingLevel(): number;
  104489. /**
  104490. * Gets the list of loaded textures
  104491. * @returns an array containing all loaded textures
  104492. */
  104493. getLoadedTexturesCache(): InternalTexture[];
  104494. /**
  104495. * Gets the object containing all engine capabilities
  104496. * @returns the EngineCapabilities object
  104497. */
  104498. getCaps(): EngineCapabilities;
  104499. /**
  104500. * stop executing a render loop function and remove it from the execution array
  104501. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104502. */
  104503. stopRenderLoop(renderFunction?: () => void): void;
  104504. /** @hidden */
  104505. _renderLoop(): void;
  104506. /**
  104507. * Gets the HTML canvas attached with the current webGL context
  104508. * @returns a HTML canvas
  104509. */
  104510. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104511. /**
  104512. * Gets host window
  104513. * @returns the host window object
  104514. */
  104515. getHostWindow(): Nullable<Window>;
  104516. /**
  104517. * Gets the current render width
  104518. * @param useScreen defines if screen size must be used (or the current render target if any)
  104519. * @returns a number defining the current render width
  104520. */
  104521. getRenderWidth(useScreen?: boolean): number;
  104522. /**
  104523. * Gets the current render height
  104524. * @param useScreen defines if screen size must be used (or the current render target if any)
  104525. * @returns a number defining the current render height
  104526. */
  104527. getRenderHeight(useScreen?: boolean): number;
  104528. /**
  104529. * Can be used to override the current requestAnimationFrame requester.
  104530. * @hidden
  104531. */
  104532. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104533. /**
  104534. * Register and execute a render loop. The engine can have more than one render function
  104535. * @param renderFunction defines the function to continuously execute
  104536. */
  104537. runRenderLoop(renderFunction: () => void): void;
  104538. /**
  104539. * Clear the current render buffer or the current render target (if any is set up)
  104540. * @param color defines the color to use
  104541. * @param backBuffer defines if the back buffer must be cleared
  104542. * @param depth defines if the depth buffer must be cleared
  104543. * @param stencil defines if the stencil buffer must be cleared
  104544. */
  104545. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104546. private _viewportCached;
  104547. /** @hidden */
  104548. _viewport(x: number, y: number, width: number, height: number): void;
  104549. /**
  104550. * Set the WebGL's viewport
  104551. * @param viewport defines the viewport element to be used
  104552. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104553. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104554. */
  104555. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104556. /**
  104557. * Begin a new frame
  104558. */
  104559. beginFrame(): void;
  104560. /**
  104561. * Enf the current frame
  104562. */
  104563. endFrame(): void;
  104564. /**
  104565. * Resize the view according to the canvas' size
  104566. */
  104567. resize(): void;
  104568. /**
  104569. * Force a specific size of the canvas
  104570. * @param width defines the new canvas' width
  104571. * @param height defines the new canvas' height
  104572. */
  104573. setSize(width: number, height: number): void;
  104574. /**
  104575. * Binds the frame buffer to the specified texture.
  104576. * @param texture The texture to render to or null for the default canvas
  104577. * @param faceIndex The face of the texture to render to in case of cube texture
  104578. * @param requiredWidth The width of the target to render to
  104579. * @param requiredHeight The height of the target to render to
  104580. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104581. * @param lodLevel defines the lod level to bind to the frame buffer
  104582. * @param layer defines the 2d array index to bind to frame buffer to
  104583. */
  104584. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104585. /** @hidden */
  104586. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104587. /**
  104588. * Unbind the current render target texture from the webGL context
  104589. * @param texture defines the render target texture to unbind
  104590. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104591. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104592. */
  104593. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104594. /**
  104595. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104596. */
  104597. flushFramebuffer(): void;
  104598. /**
  104599. * Unbind the current render target and bind the default framebuffer
  104600. */
  104601. restoreDefaultFramebuffer(): void;
  104602. /** @hidden */
  104603. protected _resetVertexBufferBinding(): void;
  104604. /**
  104605. * Creates a vertex buffer
  104606. * @param data the data for the vertex buffer
  104607. * @returns the new WebGL static buffer
  104608. */
  104609. createVertexBuffer(data: DataArray): DataBuffer;
  104610. private _createVertexBuffer;
  104611. /**
  104612. * Creates a dynamic vertex buffer
  104613. * @param data the data for the dynamic vertex buffer
  104614. * @returns the new WebGL dynamic buffer
  104615. */
  104616. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104617. protected _resetIndexBufferBinding(): void;
  104618. /**
  104619. * Creates a new index buffer
  104620. * @param indices defines the content of the index buffer
  104621. * @param updatable defines if the index buffer must be updatable
  104622. * @returns a new webGL buffer
  104623. */
  104624. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104625. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104626. /**
  104627. * Bind a webGL buffer to the webGL context
  104628. * @param buffer defines the buffer to bind
  104629. */
  104630. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104631. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104632. private bindBuffer;
  104633. /**
  104634. * update the bound buffer with the given data
  104635. * @param data defines the data to update
  104636. */
  104637. updateArrayBuffer(data: Float32Array): void;
  104638. private _vertexAttribPointer;
  104639. /** @hidden */
  104640. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104641. private _bindVertexBuffersAttributes;
  104642. /**
  104643. * Records a vertex array object
  104644. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104645. * @param vertexBuffers defines the list of vertex buffers to store
  104646. * @param indexBuffer defines the index buffer to store
  104647. * @param effect defines the effect to store
  104648. * @returns the new vertex array object
  104649. */
  104650. recordVertexArrayObject(vertexBuffers: {
  104651. [key: string]: VertexBuffer;
  104652. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104653. /**
  104654. * Bind a specific vertex array object
  104655. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104656. * @param vertexArrayObject defines the vertex array object to bind
  104657. * @param indexBuffer defines the index buffer to bind
  104658. */
  104659. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104660. /**
  104661. * Bind webGl buffers directly to the webGL context
  104662. * @param vertexBuffer defines the vertex buffer to bind
  104663. * @param indexBuffer defines the index buffer to bind
  104664. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104665. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104666. * @param effect defines the effect associated with the vertex buffer
  104667. */
  104668. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104669. private _unbindVertexArrayObject;
  104670. /**
  104671. * Bind a list of vertex buffers to the webGL context
  104672. * @param vertexBuffers defines the list of vertex buffers to bind
  104673. * @param indexBuffer defines the index buffer to bind
  104674. * @param effect defines the effect associated with the vertex buffers
  104675. */
  104676. bindBuffers(vertexBuffers: {
  104677. [key: string]: Nullable<VertexBuffer>;
  104678. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104679. /**
  104680. * Unbind all instance attributes
  104681. */
  104682. unbindInstanceAttributes(): void;
  104683. /**
  104684. * Release and free the memory of a vertex array object
  104685. * @param vao defines the vertex array object to delete
  104686. */
  104687. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104688. /** @hidden */
  104689. _releaseBuffer(buffer: DataBuffer): boolean;
  104690. protected _deleteBuffer(buffer: DataBuffer): void;
  104691. /**
  104692. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104693. * @param instancesBuffer defines the webGL buffer to update and bind
  104694. * @param data defines the data to store in the buffer
  104695. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104696. */
  104697. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104698. /**
  104699. * Bind the content of a webGL buffer used with instantiation
  104700. * @param instancesBuffer defines the webGL buffer to bind
  104701. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104702. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104703. */
  104704. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104705. /**
  104706. * Disable the instance attribute corresponding to the name in parameter
  104707. * @param name defines the name of the attribute to disable
  104708. */
  104709. disableInstanceAttributeByName(name: string): void;
  104710. /**
  104711. * Disable the instance attribute corresponding to the location in parameter
  104712. * @param attributeLocation defines the attribute location of the attribute to disable
  104713. */
  104714. disableInstanceAttribute(attributeLocation: number): void;
  104715. /**
  104716. * Disable the attribute corresponding to the location in parameter
  104717. * @param attributeLocation defines the attribute location of the attribute to disable
  104718. */
  104719. disableAttributeByIndex(attributeLocation: number): void;
  104720. /**
  104721. * Send a draw order
  104722. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104723. * @param indexStart defines the starting index
  104724. * @param indexCount defines the number of index to draw
  104725. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104726. */
  104727. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104728. /**
  104729. * Draw a list of points
  104730. * @param verticesStart defines the index of first vertex to draw
  104731. * @param verticesCount defines the count of vertices to draw
  104732. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104733. */
  104734. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104735. /**
  104736. * Draw a list of unindexed primitives
  104737. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104738. * @param verticesStart defines the index of first vertex to draw
  104739. * @param verticesCount defines the count of vertices to draw
  104740. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104741. */
  104742. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104743. /**
  104744. * Draw a list of indexed primitives
  104745. * @param fillMode defines the primitive to use
  104746. * @param indexStart defines the starting index
  104747. * @param indexCount defines the number of index to draw
  104748. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104749. */
  104750. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104751. /**
  104752. * Draw a list of unindexed primitives
  104753. * @param fillMode defines the primitive to use
  104754. * @param verticesStart defines the index of first vertex to draw
  104755. * @param verticesCount defines the count of vertices to draw
  104756. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104757. */
  104758. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104759. private _drawMode;
  104760. /** @hidden */
  104761. protected _reportDrawCall(): void;
  104762. /** @hidden */
  104763. _releaseEffect(effect: Effect): void;
  104764. /** @hidden */
  104765. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104766. /**
  104767. * Create a new effect (used to store vertex/fragment shaders)
  104768. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104769. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104770. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104771. * @param samplers defines an array of string used to represent textures
  104772. * @param defines defines the string containing the defines to use to compile the shaders
  104773. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104774. * @param onCompiled defines a function to call when the effect creation is successful
  104775. * @param onError defines a function to call when the effect creation has failed
  104776. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104777. * @returns the new Effect
  104778. */
  104779. 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;
  104780. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104781. private _compileShader;
  104782. private _compileRawShader;
  104783. /**
  104784. * Directly creates a webGL program
  104785. * @param pipelineContext defines the pipeline context to attach to
  104786. * @param vertexCode defines the vertex shader code to use
  104787. * @param fragmentCode defines the fragment shader code to use
  104788. * @param context defines the webGL context to use (if not set, the current one will be used)
  104789. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104790. * @returns the new webGL program
  104791. */
  104792. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104793. /**
  104794. * Creates a webGL program
  104795. * @param pipelineContext defines the pipeline context to attach to
  104796. * @param vertexCode defines the vertex shader code to use
  104797. * @param fragmentCode defines the fragment shader code to use
  104798. * @param defines defines the string containing the defines to use to compile the shaders
  104799. * @param context defines the webGL context to use (if not set, the current one will be used)
  104800. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104801. * @returns the new webGL program
  104802. */
  104803. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104804. /**
  104805. * Creates a new pipeline context
  104806. * @returns the new pipeline
  104807. */
  104808. createPipelineContext(): IPipelineContext;
  104809. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104810. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104811. /** @hidden */
  104812. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104813. /** @hidden */
  104814. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104815. /** @hidden */
  104816. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104817. /**
  104818. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104819. * @param pipelineContext defines the pipeline context to use
  104820. * @param uniformsNames defines the list of uniform names
  104821. * @returns an array of webGL uniform locations
  104822. */
  104823. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104824. /**
  104825. * Gets the lsit of active attributes for a given webGL program
  104826. * @param pipelineContext defines the pipeline context to use
  104827. * @param attributesNames defines the list of attribute names to get
  104828. * @returns an array of indices indicating the offset of each attribute
  104829. */
  104830. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104831. /**
  104832. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104833. * @param effect defines the effect to activate
  104834. */
  104835. enableEffect(effect: Nullable<Effect>): void;
  104836. /**
  104837. * Set the value of an uniform to a number (int)
  104838. * @param uniform defines the webGL uniform location where to store the value
  104839. * @param value defines the int number to store
  104840. */
  104841. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104842. /**
  104843. * Set the value of an uniform to an array of int32
  104844. * @param uniform defines the webGL uniform location where to store the value
  104845. * @param array defines the array of int32 to store
  104846. */
  104847. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104848. /**
  104849. * Set the value of an uniform to an array of int32 (stored as vec2)
  104850. * @param uniform defines the webGL uniform location where to store the value
  104851. * @param array defines the array of int32 to store
  104852. */
  104853. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104854. /**
  104855. * Set the value of an uniform to an array of int32 (stored as vec3)
  104856. * @param uniform defines the webGL uniform location where to store the value
  104857. * @param array defines the array of int32 to store
  104858. */
  104859. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104860. /**
  104861. * Set the value of an uniform to an array of int32 (stored as vec4)
  104862. * @param uniform defines the webGL uniform location where to store the value
  104863. * @param array defines the array of int32 to store
  104864. */
  104865. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104866. /**
  104867. * Set the value of an uniform to an array of number
  104868. * @param uniform defines the webGL uniform location where to store the value
  104869. * @param array defines the array of number to store
  104870. */
  104871. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104872. /**
  104873. * Set the value of an uniform to an array of number (stored as vec2)
  104874. * @param uniform defines the webGL uniform location where to store the value
  104875. * @param array defines the array of number to store
  104876. */
  104877. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104878. /**
  104879. * Set the value of an uniform to an array of number (stored as vec3)
  104880. * @param uniform defines the webGL uniform location where to store the value
  104881. * @param array defines the array of number to store
  104882. */
  104883. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104884. /**
  104885. * Set the value of an uniform to an array of number (stored as vec4)
  104886. * @param uniform defines the webGL uniform location where to store the value
  104887. * @param array defines the array of number to store
  104888. */
  104889. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104890. /**
  104891. * Set the value of an uniform to an array of float32 (stored as matrices)
  104892. * @param uniform defines the webGL uniform location where to store the value
  104893. * @param matrices defines the array of float32 to store
  104894. */
  104895. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104896. /**
  104897. * Set the value of an uniform to a matrix (3x3)
  104898. * @param uniform defines the webGL uniform location where to store the value
  104899. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104900. */
  104901. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104902. /**
  104903. * Set the value of an uniform to a matrix (2x2)
  104904. * @param uniform defines the webGL uniform location where to store the value
  104905. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104906. */
  104907. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104908. /**
  104909. * Set the value of an uniform to a number (float)
  104910. * @param uniform defines the webGL uniform location where to store the value
  104911. * @param value defines the float number to store
  104912. */
  104913. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104914. /**
  104915. * Set the value of an uniform to a vec2
  104916. * @param uniform defines the webGL uniform location where to store the value
  104917. * @param x defines the 1st component of the value
  104918. * @param y defines the 2nd component of the value
  104919. */
  104920. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104921. /**
  104922. * Set the value of an uniform to a vec3
  104923. * @param uniform defines the webGL uniform location where to store the value
  104924. * @param x defines the 1st component of the value
  104925. * @param y defines the 2nd component of the value
  104926. * @param z defines the 3rd component of the value
  104927. */
  104928. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104929. /**
  104930. * Set the value of an uniform to a vec4
  104931. * @param uniform defines the webGL uniform location where to store the value
  104932. * @param x defines the 1st component of the value
  104933. * @param y defines the 2nd component of the value
  104934. * @param z defines the 3rd component of the value
  104935. * @param w defines the 4th component of the value
  104936. */
  104937. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104938. /**
  104939. * Apply all cached states (depth, culling, stencil and alpha)
  104940. */
  104941. applyStates(): void;
  104942. /**
  104943. * Enable or disable color writing
  104944. * @param enable defines the state to set
  104945. */
  104946. setColorWrite(enable: boolean): void;
  104947. /**
  104948. * Gets a boolean indicating if color writing is enabled
  104949. * @returns the current color writing state
  104950. */
  104951. getColorWrite(): boolean;
  104952. /**
  104953. * Gets the depth culling state manager
  104954. */
  104955. get depthCullingState(): DepthCullingState;
  104956. /**
  104957. * Gets the alpha state manager
  104958. */
  104959. get alphaState(): AlphaState;
  104960. /**
  104961. * Gets the stencil state manager
  104962. */
  104963. get stencilState(): StencilState;
  104964. /**
  104965. * Clears the list of texture accessible through engine.
  104966. * This can help preventing texture load conflict due to name collision.
  104967. */
  104968. clearInternalTexturesCache(): void;
  104969. /**
  104970. * Force the entire cache to be cleared
  104971. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104972. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104973. */
  104974. wipeCaches(bruteForce?: boolean): void;
  104975. /** @hidden */
  104976. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104977. min: number;
  104978. mag: number;
  104979. };
  104980. /** @hidden */
  104981. _createTexture(): WebGLTexture;
  104982. /**
  104983. * Usually called from Texture.ts.
  104984. * Passed information to create a WebGLTexture
  104985. * @param urlArg defines a value which contains one of the following:
  104986. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104987. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104988. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104989. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104990. * @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)
  104991. * @param scene needed for loading to the correct scene
  104992. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104993. * @param onLoad optional callback to be called upon successful completion
  104994. * @param onError optional callback to be called upon failure
  104995. * @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
  104996. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104997. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104998. * @param forcedExtension defines the extension to use to pick the right loader
  104999. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  105000. * @param mimeType defines an optional mime type
  105001. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105002. */
  105003. 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;
  105004. /**
  105005. * Loads an image as an HTMLImageElement.
  105006. * @param input url string, ArrayBuffer, or Blob to load
  105007. * @param onLoad callback called when the image successfully loads
  105008. * @param onError callback called when the image fails to load
  105009. * @param offlineProvider offline provider for caching
  105010. * @param mimeType optional mime type
  105011. * @returns the HTMLImageElement of the loaded image
  105012. * @hidden
  105013. */
  105014. 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>;
  105015. /**
  105016. * @hidden
  105017. */
  105018. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105019. /**
  105020. * Creates a raw texture
  105021. * @param data defines the data to store in the texture
  105022. * @param width defines the width of the texture
  105023. * @param height defines the height of the texture
  105024. * @param format defines the format of the data
  105025. * @param generateMipMaps defines if the engine should generate the mip levels
  105026. * @param invertY defines if data must be stored with Y axis inverted
  105027. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105028. * @param compression defines the compression used (null by default)
  105029. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105030. * @returns the raw texture inside an InternalTexture
  105031. */
  105032. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105033. /**
  105034. * Creates a new raw cube texture
  105035. * @param data defines the array of data to use to create each face
  105036. * @param size defines the size of the textures
  105037. * @param format defines the format of the data
  105038. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105039. * @param generateMipMaps defines if the engine should generate the mip levels
  105040. * @param invertY defines if data must be stored with Y axis inverted
  105041. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105042. * @param compression defines the compression used (null by default)
  105043. * @returns the cube texture as an InternalTexture
  105044. */
  105045. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105046. /**
  105047. * Creates a new raw 3D texture
  105048. * @param data defines the data used to create the texture
  105049. * @param width defines the width of the texture
  105050. * @param height defines the height of the texture
  105051. * @param depth defines the depth of the texture
  105052. * @param format defines the format of the texture
  105053. * @param generateMipMaps defines if the engine must generate mip levels
  105054. * @param invertY defines if data must be stored with Y axis inverted
  105055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105056. * @param compression defines the compressed used (can be null)
  105057. * @param textureType defines the compressed used (can be null)
  105058. * @returns a new raw 3D texture (stored in an InternalTexture)
  105059. */
  105060. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105061. /**
  105062. * Creates a new raw 2D array texture
  105063. * @param data defines the data used to create the texture
  105064. * @param width defines the width of the texture
  105065. * @param height defines the height of the texture
  105066. * @param depth defines the number of layers of the texture
  105067. * @param format defines the format of the texture
  105068. * @param generateMipMaps defines if the engine must generate mip levels
  105069. * @param invertY defines if data must be stored with Y axis inverted
  105070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105071. * @param compression defines the compressed used (can be null)
  105072. * @param textureType defines the compressed used (can be null)
  105073. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105074. */
  105075. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105076. private _unpackFlipYCached;
  105077. /**
  105078. * In case you are sharing the context with other applications, it might
  105079. * be interested to not cache the unpack flip y state to ensure a consistent
  105080. * value would be set.
  105081. */
  105082. enableUnpackFlipYCached: boolean;
  105083. /** @hidden */
  105084. _unpackFlipY(value: boolean): void;
  105085. /** @hidden */
  105086. _getUnpackAlignement(): number;
  105087. private _getTextureTarget;
  105088. /**
  105089. * Update the sampling mode of a given texture
  105090. * @param samplingMode defines the required sampling mode
  105091. * @param texture defines the texture to update
  105092. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105093. */
  105094. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105095. /**
  105096. * Update the sampling mode of a given texture
  105097. * @param texture defines the texture to update
  105098. * @param wrapU defines the texture wrap mode of the u coordinates
  105099. * @param wrapV defines the texture wrap mode of the v coordinates
  105100. * @param wrapR defines the texture wrap mode of the r coordinates
  105101. */
  105102. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105103. /** @hidden */
  105104. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105105. width: number;
  105106. height: number;
  105107. layers?: number;
  105108. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105109. /** @hidden */
  105110. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105111. /** @hidden */
  105112. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105113. /**
  105114. * Update a portion of an internal texture
  105115. * @param texture defines the texture to update
  105116. * @param imageData defines the data to store into the texture
  105117. * @param xOffset defines the x coordinates of the update rectangle
  105118. * @param yOffset defines the y coordinates of the update rectangle
  105119. * @param width defines the width of the update rectangle
  105120. * @param height defines the height of the update rectangle
  105121. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105122. * @param lod defines the lod level to update (0 by default)
  105123. */
  105124. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105125. /** @hidden */
  105126. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105127. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105128. private _prepareWebGLTexture;
  105129. /** @hidden */
  105130. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105131. private _getDepthStencilBuffer;
  105132. /** @hidden */
  105133. _releaseFramebufferObjects(texture: InternalTexture): void;
  105134. /** @hidden */
  105135. _releaseTexture(texture: InternalTexture): void;
  105136. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105137. protected _setProgram(program: WebGLProgram): void;
  105138. protected _boundUniforms: {
  105139. [key: number]: WebGLUniformLocation;
  105140. };
  105141. /**
  105142. * Binds an effect to the webGL context
  105143. * @param effect defines the effect to bind
  105144. */
  105145. bindSamplers(effect: Effect): void;
  105146. private _activateCurrentTexture;
  105147. /** @hidden */
  105148. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105149. /** @hidden */
  105150. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105151. /**
  105152. * Unbind all textures from the webGL context
  105153. */
  105154. unbindAllTextures(): void;
  105155. /**
  105156. * Sets a texture to the according uniform.
  105157. * @param channel The texture channel
  105158. * @param uniform The uniform to set
  105159. * @param texture The texture to apply
  105160. */
  105161. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105162. private _bindSamplerUniformToChannel;
  105163. private _getTextureWrapMode;
  105164. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105165. /**
  105166. * Sets an array of texture to the webGL context
  105167. * @param channel defines the channel where the texture array must be set
  105168. * @param uniform defines the associated uniform location
  105169. * @param textures defines the array of textures to bind
  105170. */
  105171. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105172. /** @hidden */
  105173. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105174. private _setTextureParameterFloat;
  105175. private _setTextureParameterInteger;
  105176. /**
  105177. * Unbind all vertex attributes from the webGL context
  105178. */
  105179. unbindAllAttributes(): void;
  105180. /**
  105181. * 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
  105182. */
  105183. releaseEffects(): void;
  105184. /**
  105185. * Dispose and release all associated resources
  105186. */
  105187. dispose(): void;
  105188. /**
  105189. * Attach a new callback raised when context lost event is fired
  105190. * @param callback defines the callback to call
  105191. */
  105192. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105193. /**
  105194. * Attach a new callback raised when context restored event is fired
  105195. * @param callback defines the callback to call
  105196. */
  105197. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105198. /**
  105199. * Get the current error code of the webGL context
  105200. * @returns the error code
  105201. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105202. */
  105203. getError(): number;
  105204. private _canRenderToFloatFramebuffer;
  105205. private _canRenderToHalfFloatFramebuffer;
  105206. private _canRenderToFramebuffer;
  105207. /** @hidden */
  105208. _getWebGLTextureType(type: number): number;
  105209. /** @hidden */
  105210. _getInternalFormat(format: number): number;
  105211. /** @hidden */
  105212. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105213. /** @hidden */
  105214. _getRGBAMultiSampleBufferFormat(type: number): number;
  105215. /** @hidden */
  105216. _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;
  105217. /**
  105218. * Loads a file from a url
  105219. * @param url url to load
  105220. * @param onSuccess callback called when the file successfully loads
  105221. * @param onProgress callback called while file is loading (if the server supports this mode)
  105222. * @param offlineProvider defines the offline provider for caching
  105223. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105224. * @param onError callback called when the file fails to load
  105225. * @returns a file request object
  105226. * @hidden
  105227. */
  105228. 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;
  105229. /**
  105230. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105231. * @param x defines the x coordinate of the rectangle where pixels must be read
  105232. * @param y defines the y coordinate of the rectangle where pixels must be read
  105233. * @param width defines the width of the rectangle where pixels must be read
  105234. * @param height defines the height of the rectangle where pixels must be read
  105235. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105236. * @returns a Uint8Array containing RGBA colors
  105237. */
  105238. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105239. private static _isSupported;
  105240. /**
  105241. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105242. * @returns true if the engine can be created
  105243. * @ignorenaming
  105244. */
  105245. static isSupported(): boolean;
  105246. /**
  105247. * Find the next highest power of two.
  105248. * @param x Number to start search from.
  105249. * @return Next highest power of two.
  105250. */
  105251. static CeilingPOT(x: number): number;
  105252. /**
  105253. * Find the next lowest power of two.
  105254. * @param x Number to start search from.
  105255. * @return Next lowest power of two.
  105256. */
  105257. static FloorPOT(x: number): number;
  105258. /**
  105259. * Find the nearest power of two.
  105260. * @param x Number to start search from.
  105261. * @return Next nearest power of two.
  105262. */
  105263. static NearestPOT(x: number): number;
  105264. /**
  105265. * Get the closest exponent of two
  105266. * @param value defines the value to approximate
  105267. * @param max defines the maximum value to return
  105268. * @param mode defines how to define the closest value
  105269. * @returns closest exponent of two of the given value
  105270. */
  105271. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105272. /**
  105273. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105274. * @param func - the function to be called
  105275. * @param requester - the object that will request the next frame. Falls back to window.
  105276. * @returns frame number
  105277. */
  105278. static QueueNewFrame(func: () => void, requester?: any): number;
  105279. /**
  105280. * Gets host document
  105281. * @returns the host document object
  105282. */
  105283. getHostDocument(): Nullable<Document>;
  105284. }
  105285. }
  105286. declare module BABYLON {
  105287. /**
  105288. * Class representing spherical harmonics coefficients to the 3rd degree
  105289. */
  105290. export class SphericalHarmonics {
  105291. /**
  105292. * Defines whether or not the harmonics have been prescaled for rendering.
  105293. */
  105294. preScaled: boolean;
  105295. /**
  105296. * The l0,0 coefficients of the spherical harmonics
  105297. */
  105298. l00: Vector3;
  105299. /**
  105300. * The l1,-1 coefficients of the spherical harmonics
  105301. */
  105302. l1_1: Vector3;
  105303. /**
  105304. * The l1,0 coefficients of the spherical harmonics
  105305. */
  105306. l10: Vector3;
  105307. /**
  105308. * The l1,1 coefficients of the spherical harmonics
  105309. */
  105310. l11: Vector3;
  105311. /**
  105312. * The l2,-2 coefficients of the spherical harmonics
  105313. */
  105314. l2_2: Vector3;
  105315. /**
  105316. * The l2,-1 coefficients of the spherical harmonics
  105317. */
  105318. l2_1: Vector3;
  105319. /**
  105320. * The l2,0 coefficients of the spherical harmonics
  105321. */
  105322. l20: Vector3;
  105323. /**
  105324. * The l2,1 coefficients of the spherical harmonics
  105325. */
  105326. l21: Vector3;
  105327. /**
  105328. * The l2,2 coefficients of the spherical harmonics
  105329. */
  105330. l22: Vector3;
  105331. /**
  105332. * Adds a light to the spherical harmonics
  105333. * @param direction the direction of the light
  105334. * @param color the color of the light
  105335. * @param deltaSolidAngle the delta solid angle of the light
  105336. */
  105337. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105338. /**
  105339. * Scales the spherical harmonics by the given amount
  105340. * @param scale the amount to scale
  105341. */
  105342. scaleInPlace(scale: number): void;
  105343. /**
  105344. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105345. *
  105346. * ```
  105347. * E_lm = A_l * L_lm
  105348. * ```
  105349. *
  105350. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105351. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105352. * the scaling factors are given in equation 9.
  105353. */
  105354. convertIncidentRadianceToIrradiance(): void;
  105355. /**
  105356. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105357. *
  105358. * ```
  105359. * L = (1/pi) * E * rho
  105360. * ```
  105361. *
  105362. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105363. */
  105364. convertIrradianceToLambertianRadiance(): void;
  105365. /**
  105366. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105367. * required operations at run time.
  105368. *
  105369. * This is simply done by scaling back the SH with Ylm constants parameter.
  105370. * The trigonometric part being applied by the shader at run time.
  105371. */
  105372. preScaleForRendering(): void;
  105373. /**
  105374. * Constructs a spherical harmonics from an array.
  105375. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105376. * @returns the spherical harmonics
  105377. */
  105378. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105379. /**
  105380. * Gets the spherical harmonics from polynomial
  105381. * @param polynomial the spherical polynomial
  105382. * @returns the spherical harmonics
  105383. */
  105384. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105385. }
  105386. /**
  105387. * Class representing spherical polynomial coefficients to the 3rd degree
  105388. */
  105389. export class SphericalPolynomial {
  105390. private _harmonics;
  105391. /**
  105392. * The spherical harmonics used to create the polynomials.
  105393. */
  105394. get preScaledHarmonics(): SphericalHarmonics;
  105395. /**
  105396. * The x coefficients of the spherical polynomial
  105397. */
  105398. x: Vector3;
  105399. /**
  105400. * The y coefficients of the spherical polynomial
  105401. */
  105402. y: Vector3;
  105403. /**
  105404. * The z coefficients of the spherical polynomial
  105405. */
  105406. z: Vector3;
  105407. /**
  105408. * The xx coefficients of the spherical polynomial
  105409. */
  105410. xx: Vector3;
  105411. /**
  105412. * The yy coefficients of the spherical polynomial
  105413. */
  105414. yy: Vector3;
  105415. /**
  105416. * The zz coefficients of the spherical polynomial
  105417. */
  105418. zz: Vector3;
  105419. /**
  105420. * The xy coefficients of the spherical polynomial
  105421. */
  105422. xy: Vector3;
  105423. /**
  105424. * The yz coefficients of the spherical polynomial
  105425. */
  105426. yz: Vector3;
  105427. /**
  105428. * The zx coefficients of the spherical polynomial
  105429. */
  105430. zx: Vector3;
  105431. /**
  105432. * Adds an ambient color to the spherical polynomial
  105433. * @param color the color to add
  105434. */
  105435. addAmbient(color: Color3): void;
  105436. /**
  105437. * Scales the spherical polynomial by the given amount
  105438. * @param scale the amount to scale
  105439. */
  105440. scaleInPlace(scale: number): void;
  105441. /**
  105442. * Gets the spherical polynomial from harmonics
  105443. * @param harmonics the spherical harmonics
  105444. * @returns the spherical polynomial
  105445. */
  105446. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105447. /**
  105448. * Constructs a spherical polynomial from an array.
  105449. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105450. * @returns the spherical polynomial
  105451. */
  105452. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105453. }
  105454. }
  105455. declare module BABYLON {
  105456. /**
  105457. * Defines the source of the internal texture
  105458. */
  105459. export enum InternalTextureSource {
  105460. /**
  105461. * The source of the texture data is unknown
  105462. */
  105463. Unknown = 0,
  105464. /**
  105465. * Texture data comes from an URL
  105466. */
  105467. Url = 1,
  105468. /**
  105469. * Texture data is only used for temporary storage
  105470. */
  105471. Temp = 2,
  105472. /**
  105473. * Texture data comes from raw data (ArrayBuffer)
  105474. */
  105475. Raw = 3,
  105476. /**
  105477. * Texture content is dynamic (video or dynamic texture)
  105478. */
  105479. Dynamic = 4,
  105480. /**
  105481. * Texture content is generated by rendering to it
  105482. */
  105483. RenderTarget = 5,
  105484. /**
  105485. * Texture content is part of a multi render target process
  105486. */
  105487. MultiRenderTarget = 6,
  105488. /**
  105489. * Texture data comes from a cube data file
  105490. */
  105491. Cube = 7,
  105492. /**
  105493. * Texture data comes from a raw cube data
  105494. */
  105495. CubeRaw = 8,
  105496. /**
  105497. * Texture data come from a prefiltered cube data file
  105498. */
  105499. CubePrefiltered = 9,
  105500. /**
  105501. * Texture content is raw 3D data
  105502. */
  105503. Raw3D = 10,
  105504. /**
  105505. * Texture content is raw 2D array data
  105506. */
  105507. Raw2DArray = 11,
  105508. /**
  105509. * Texture content is a depth texture
  105510. */
  105511. Depth = 12,
  105512. /**
  105513. * Texture data comes from a raw cube data encoded with RGBD
  105514. */
  105515. CubeRawRGBD = 13
  105516. }
  105517. /**
  105518. * Class used to store data associated with WebGL texture data for the engine
  105519. * This class should not be used directly
  105520. */
  105521. export class InternalTexture {
  105522. /** @hidden */
  105523. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105524. /**
  105525. * Defines if the texture is ready
  105526. */
  105527. isReady: boolean;
  105528. /**
  105529. * Defines if the texture is a cube texture
  105530. */
  105531. isCube: boolean;
  105532. /**
  105533. * Defines if the texture contains 3D data
  105534. */
  105535. is3D: boolean;
  105536. /**
  105537. * Defines if the texture contains 2D array data
  105538. */
  105539. is2DArray: boolean;
  105540. /**
  105541. * Defines if the texture contains multiview data
  105542. */
  105543. isMultiview: boolean;
  105544. /**
  105545. * Gets the URL used to load this texture
  105546. */
  105547. url: string;
  105548. /**
  105549. * Gets the sampling mode of the texture
  105550. */
  105551. samplingMode: number;
  105552. /**
  105553. * Gets a boolean indicating if the texture needs mipmaps generation
  105554. */
  105555. generateMipMaps: boolean;
  105556. /**
  105557. * Gets the number of samples used by the texture (WebGL2+ only)
  105558. */
  105559. samples: number;
  105560. /**
  105561. * Gets the type of the texture (int, float...)
  105562. */
  105563. type: number;
  105564. /**
  105565. * Gets the format of the texture (RGB, RGBA...)
  105566. */
  105567. format: number;
  105568. /**
  105569. * Observable called when the texture is loaded
  105570. */
  105571. onLoadedObservable: Observable<InternalTexture>;
  105572. /**
  105573. * Gets the width of the texture
  105574. */
  105575. width: number;
  105576. /**
  105577. * Gets the height of the texture
  105578. */
  105579. height: number;
  105580. /**
  105581. * Gets the depth of the texture
  105582. */
  105583. depth: number;
  105584. /**
  105585. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105586. */
  105587. baseWidth: number;
  105588. /**
  105589. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105590. */
  105591. baseHeight: number;
  105592. /**
  105593. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105594. */
  105595. baseDepth: number;
  105596. /**
  105597. * Gets a boolean indicating if the texture is inverted on Y axis
  105598. */
  105599. invertY: boolean;
  105600. /** @hidden */
  105601. _invertVScale: boolean;
  105602. /** @hidden */
  105603. _associatedChannel: number;
  105604. /** @hidden */
  105605. _source: InternalTextureSource;
  105606. /** @hidden */
  105607. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105608. /** @hidden */
  105609. _bufferView: Nullable<ArrayBufferView>;
  105610. /** @hidden */
  105611. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105612. /** @hidden */
  105613. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105614. /** @hidden */
  105615. _size: number;
  105616. /** @hidden */
  105617. _extension: string;
  105618. /** @hidden */
  105619. _files: Nullable<string[]>;
  105620. /** @hidden */
  105621. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105622. /** @hidden */
  105623. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105624. /** @hidden */
  105625. _framebuffer: Nullable<WebGLFramebuffer>;
  105626. /** @hidden */
  105627. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105628. /** @hidden */
  105629. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105630. /** @hidden */
  105631. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105632. /** @hidden */
  105633. _attachments: Nullable<number[]>;
  105634. /** @hidden */
  105635. _cachedCoordinatesMode: Nullable<number>;
  105636. /** @hidden */
  105637. _cachedWrapU: Nullable<number>;
  105638. /** @hidden */
  105639. _cachedWrapV: Nullable<number>;
  105640. /** @hidden */
  105641. _cachedWrapR: Nullable<number>;
  105642. /** @hidden */
  105643. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105644. /** @hidden */
  105645. _isDisabled: boolean;
  105646. /** @hidden */
  105647. _compression: Nullable<string>;
  105648. /** @hidden */
  105649. _generateStencilBuffer: boolean;
  105650. /** @hidden */
  105651. _generateDepthBuffer: boolean;
  105652. /** @hidden */
  105653. _comparisonFunction: number;
  105654. /** @hidden */
  105655. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105656. /** @hidden */
  105657. _lodGenerationScale: number;
  105658. /** @hidden */
  105659. _lodGenerationOffset: number;
  105660. /** @hidden */
  105661. _depthStencilTexture: Nullable<InternalTexture>;
  105662. /** @hidden */
  105663. _colorTextureArray: Nullable<WebGLTexture>;
  105664. /** @hidden */
  105665. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105666. /** @hidden */
  105667. _lodTextureHigh: Nullable<BaseTexture>;
  105668. /** @hidden */
  105669. _lodTextureMid: Nullable<BaseTexture>;
  105670. /** @hidden */
  105671. _lodTextureLow: Nullable<BaseTexture>;
  105672. /** @hidden */
  105673. _isRGBD: boolean;
  105674. /** @hidden */
  105675. _linearSpecularLOD: boolean;
  105676. /** @hidden */
  105677. _irradianceTexture: Nullable<BaseTexture>;
  105678. /** @hidden */
  105679. _webGLTexture: Nullable<WebGLTexture>;
  105680. /** @hidden */
  105681. _references: number;
  105682. private _engine;
  105683. /**
  105684. * Gets the Engine the texture belongs to.
  105685. * @returns The babylon engine
  105686. */
  105687. getEngine(): ThinEngine;
  105688. /**
  105689. * Gets the data source type of the texture
  105690. */
  105691. get source(): InternalTextureSource;
  105692. /**
  105693. * Creates a new InternalTexture
  105694. * @param engine defines the engine to use
  105695. * @param source defines the type of data that will be used
  105696. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105697. */
  105698. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105699. /**
  105700. * Increments the number of references (ie. the number of Texture that point to it)
  105701. */
  105702. incrementReferences(): void;
  105703. /**
  105704. * Change the size of the texture (not the size of the content)
  105705. * @param width defines the new width
  105706. * @param height defines the new height
  105707. * @param depth defines the new depth (1 by default)
  105708. */
  105709. updateSize(width: int, height: int, depth?: int): void;
  105710. /** @hidden */
  105711. _rebuild(): void;
  105712. /** @hidden */
  105713. _swapAndDie(target: InternalTexture): void;
  105714. /**
  105715. * Dispose the current allocated resources
  105716. */
  105717. dispose(): void;
  105718. }
  105719. }
  105720. declare module BABYLON {
  105721. /**
  105722. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105724. */
  105725. export class Analyser {
  105726. /**
  105727. * Gets or sets the smoothing
  105728. * @ignorenaming
  105729. */
  105730. SMOOTHING: number;
  105731. /**
  105732. * Gets or sets the FFT table size
  105733. * @ignorenaming
  105734. */
  105735. FFT_SIZE: number;
  105736. /**
  105737. * Gets or sets the bar graph amplitude
  105738. * @ignorenaming
  105739. */
  105740. BARGRAPHAMPLITUDE: number;
  105741. /**
  105742. * Gets or sets the position of the debug canvas
  105743. * @ignorenaming
  105744. */
  105745. DEBUGCANVASPOS: {
  105746. x: number;
  105747. y: number;
  105748. };
  105749. /**
  105750. * Gets or sets the debug canvas size
  105751. * @ignorenaming
  105752. */
  105753. DEBUGCANVASSIZE: {
  105754. width: number;
  105755. height: number;
  105756. };
  105757. private _byteFreqs;
  105758. private _byteTime;
  105759. private _floatFreqs;
  105760. private _webAudioAnalyser;
  105761. private _debugCanvas;
  105762. private _debugCanvasContext;
  105763. private _scene;
  105764. private _registerFunc;
  105765. private _audioEngine;
  105766. /**
  105767. * Creates a new analyser
  105768. * @param scene defines hosting scene
  105769. */
  105770. constructor(scene: Scene);
  105771. /**
  105772. * Get the number of data values you will have to play with for the visualization
  105773. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105774. * @returns a number
  105775. */
  105776. getFrequencyBinCount(): number;
  105777. /**
  105778. * Gets the current frequency data as a byte array
  105779. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105780. * @returns a Uint8Array
  105781. */
  105782. getByteFrequencyData(): Uint8Array;
  105783. /**
  105784. * Gets the current waveform as a byte array
  105785. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105786. * @returns a Uint8Array
  105787. */
  105788. getByteTimeDomainData(): Uint8Array;
  105789. /**
  105790. * Gets the current frequency data as a float array
  105791. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105792. * @returns a Float32Array
  105793. */
  105794. getFloatFrequencyData(): Float32Array;
  105795. /**
  105796. * Renders the debug canvas
  105797. */
  105798. drawDebugCanvas(): void;
  105799. /**
  105800. * Stops rendering the debug canvas and removes it
  105801. */
  105802. stopDebugCanvas(): void;
  105803. /**
  105804. * Connects two audio nodes
  105805. * @param inputAudioNode defines first node to connect
  105806. * @param outputAudioNode defines second node to connect
  105807. */
  105808. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105809. /**
  105810. * Releases all associated resources
  105811. */
  105812. dispose(): void;
  105813. }
  105814. }
  105815. declare module BABYLON {
  105816. /**
  105817. * This represents an audio engine and it is responsible
  105818. * to play, synchronize and analyse sounds throughout the application.
  105819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105820. */
  105821. export interface IAudioEngine extends IDisposable {
  105822. /**
  105823. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105824. */
  105825. readonly canUseWebAudio: boolean;
  105826. /**
  105827. * Gets the current AudioContext if available.
  105828. */
  105829. readonly audioContext: Nullable<AudioContext>;
  105830. /**
  105831. * The master gain node defines the global audio volume of your audio engine.
  105832. */
  105833. readonly masterGain: GainNode;
  105834. /**
  105835. * Gets whether or not mp3 are supported by your browser.
  105836. */
  105837. readonly isMP3supported: boolean;
  105838. /**
  105839. * Gets whether or not ogg are supported by your browser.
  105840. */
  105841. readonly isOGGsupported: boolean;
  105842. /**
  105843. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105844. * @ignoreNaming
  105845. */
  105846. WarnedWebAudioUnsupported: boolean;
  105847. /**
  105848. * Defines if the audio engine relies on a custom unlocked button.
  105849. * In this case, the embedded button will not be displayed.
  105850. */
  105851. useCustomUnlockedButton: boolean;
  105852. /**
  105853. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105854. */
  105855. readonly unlocked: boolean;
  105856. /**
  105857. * Event raised when audio has been unlocked on the browser.
  105858. */
  105859. onAudioUnlockedObservable: Observable<AudioEngine>;
  105860. /**
  105861. * Event raised when audio has been locked on the browser.
  105862. */
  105863. onAudioLockedObservable: Observable<AudioEngine>;
  105864. /**
  105865. * Flags the audio engine in Locked state.
  105866. * This happens due to new browser policies preventing audio to autoplay.
  105867. */
  105868. lock(): void;
  105869. /**
  105870. * Unlocks the audio engine once a user action has been done on the dom.
  105871. * This is helpful to resume play once browser policies have been satisfied.
  105872. */
  105873. unlock(): void;
  105874. }
  105875. /**
  105876. * This represents the default audio engine used in babylon.
  105877. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105879. */
  105880. export class AudioEngine implements IAudioEngine {
  105881. private _audioContext;
  105882. private _audioContextInitialized;
  105883. private _muteButton;
  105884. private _hostElement;
  105885. /**
  105886. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105887. */
  105888. canUseWebAudio: boolean;
  105889. /**
  105890. * The master gain node defines the global audio volume of your audio engine.
  105891. */
  105892. masterGain: GainNode;
  105893. /**
  105894. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105895. * @ignoreNaming
  105896. */
  105897. WarnedWebAudioUnsupported: boolean;
  105898. /**
  105899. * Gets whether or not mp3 are supported by your browser.
  105900. */
  105901. isMP3supported: boolean;
  105902. /**
  105903. * Gets whether or not ogg are supported by your browser.
  105904. */
  105905. isOGGsupported: boolean;
  105906. /**
  105907. * Gets whether audio has been unlocked on the device.
  105908. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105909. * a user interaction has happened.
  105910. */
  105911. unlocked: boolean;
  105912. /**
  105913. * Defines if the audio engine relies on a custom unlocked button.
  105914. * In this case, the embedded button will not be displayed.
  105915. */
  105916. useCustomUnlockedButton: boolean;
  105917. /**
  105918. * Event raised when audio has been unlocked on the browser.
  105919. */
  105920. onAudioUnlockedObservable: Observable<AudioEngine>;
  105921. /**
  105922. * Event raised when audio has been locked on the browser.
  105923. */
  105924. onAudioLockedObservable: Observable<AudioEngine>;
  105925. /**
  105926. * Gets the current AudioContext if available.
  105927. */
  105928. get audioContext(): Nullable<AudioContext>;
  105929. private _connectedAnalyser;
  105930. /**
  105931. * Instantiates a new audio engine.
  105932. *
  105933. * There should be only one per page as some browsers restrict the number
  105934. * of audio contexts you can create.
  105935. * @param hostElement defines the host element where to display the mute icon if necessary
  105936. */
  105937. constructor(hostElement?: Nullable<HTMLElement>);
  105938. /**
  105939. * Flags the audio engine in Locked state.
  105940. * This happens due to new browser policies preventing audio to autoplay.
  105941. */
  105942. lock(): void;
  105943. /**
  105944. * Unlocks the audio engine once a user action has been done on the dom.
  105945. * This is helpful to resume play once browser policies have been satisfied.
  105946. */
  105947. unlock(): void;
  105948. private _resumeAudioContext;
  105949. private _initializeAudioContext;
  105950. private _tryToRun;
  105951. private _triggerRunningState;
  105952. private _triggerSuspendedState;
  105953. private _displayMuteButton;
  105954. private _moveButtonToTopLeft;
  105955. private _onResize;
  105956. private _hideMuteButton;
  105957. /**
  105958. * Destroy and release the resources associated with the audio ccontext.
  105959. */
  105960. dispose(): void;
  105961. /**
  105962. * Gets the global volume sets on the master gain.
  105963. * @returns the global volume if set or -1 otherwise
  105964. */
  105965. getGlobalVolume(): number;
  105966. /**
  105967. * Sets the global volume of your experience (sets on the master gain).
  105968. * @param newVolume Defines the new global volume of the application
  105969. */
  105970. setGlobalVolume(newVolume: number): void;
  105971. /**
  105972. * Connect the audio engine to an audio analyser allowing some amazing
  105973. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105975. * @param analyser The analyser to connect to the engine
  105976. */
  105977. connectToAnalyser(analyser: Analyser): void;
  105978. }
  105979. }
  105980. declare module BABYLON {
  105981. /**
  105982. * Interface used to present a loading screen while loading a scene
  105983. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105984. */
  105985. export interface ILoadingScreen {
  105986. /**
  105987. * Function called to display the loading screen
  105988. */
  105989. displayLoadingUI: () => void;
  105990. /**
  105991. * Function called to hide the loading screen
  105992. */
  105993. hideLoadingUI: () => void;
  105994. /**
  105995. * Gets or sets the color to use for the background
  105996. */
  105997. loadingUIBackgroundColor: string;
  105998. /**
  105999. * Gets or sets the text to display while loading
  106000. */
  106001. loadingUIText: string;
  106002. }
  106003. /**
  106004. * Class used for the default loading screen
  106005. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106006. */
  106007. export class DefaultLoadingScreen implements ILoadingScreen {
  106008. private _renderingCanvas;
  106009. private _loadingText;
  106010. private _loadingDivBackgroundColor;
  106011. private _loadingDiv;
  106012. private _loadingTextDiv;
  106013. /** Gets or sets the logo url to use for the default loading screen */
  106014. static DefaultLogoUrl: string;
  106015. /** Gets or sets the spinner url to use for the default loading screen */
  106016. static DefaultSpinnerUrl: string;
  106017. /**
  106018. * Creates a new default loading screen
  106019. * @param _renderingCanvas defines the canvas used to render the scene
  106020. * @param _loadingText defines the default text to display
  106021. * @param _loadingDivBackgroundColor defines the default background color
  106022. */
  106023. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106024. /**
  106025. * Function called to display the loading screen
  106026. */
  106027. displayLoadingUI(): void;
  106028. /**
  106029. * Function called to hide the loading screen
  106030. */
  106031. hideLoadingUI(): void;
  106032. /**
  106033. * Gets or sets the text to display while loading
  106034. */
  106035. set loadingUIText(text: string);
  106036. get loadingUIText(): string;
  106037. /**
  106038. * Gets or sets the color to use for the background
  106039. */
  106040. get loadingUIBackgroundColor(): string;
  106041. set loadingUIBackgroundColor(color: string);
  106042. private _resizeLoadingUI;
  106043. }
  106044. }
  106045. declare module BABYLON {
  106046. /**
  106047. * Interface for any object that can request an animation frame
  106048. */
  106049. export interface ICustomAnimationFrameRequester {
  106050. /**
  106051. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106052. */
  106053. renderFunction?: Function;
  106054. /**
  106055. * Called to request the next frame to render to
  106056. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106057. */
  106058. requestAnimationFrame: Function;
  106059. /**
  106060. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106061. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106062. */
  106063. requestID?: number;
  106064. }
  106065. }
  106066. declare module BABYLON {
  106067. /**
  106068. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106069. */
  106070. export class PerformanceMonitor {
  106071. private _enabled;
  106072. private _rollingFrameTime;
  106073. private _lastFrameTimeMs;
  106074. /**
  106075. * constructor
  106076. * @param frameSampleSize The number of samples required to saturate the sliding window
  106077. */
  106078. constructor(frameSampleSize?: number);
  106079. /**
  106080. * Samples current frame
  106081. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106082. */
  106083. sampleFrame(timeMs?: number): void;
  106084. /**
  106085. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106086. */
  106087. get averageFrameTime(): number;
  106088. /**
  106089. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106090. */
  106091. get averageFrameTimeVariance(): number;
  106092. /**
  106093. * Returns the frame time of the most recent frame
  106094. */
  106095. get instantaneousFrameTime(): number;
  106096. /**
  106097. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106098. */
  106099. get averageFPS(): number;
  106100. /**
  106101. * Returns the average framerate in frames per second using the most recent frame time
  106102. */
  106103. get instantaneousFPS(): number;
  106104. /**
  106105. * Returns true if enough samples have been taken to completely fill the sliding window
  106106. */
  106107. get isSaturated(): boolean;
  106108. /**
  106109. * Enables contributions to the sliding window sample set
  106110. */
  106111. enable(): void;
  106112. /**
  106113. * Disables contributions to the sliding window sample set
  106114. * Samples will not be interpolated over the disabled period
  106115. */
  106116. disable(): void;
  106117. /**
  106118. * Returns true if sampling is enabled
  106119. */
  106120. get isEnabled(): boolean;
  106121. /**
  106122. * Resets performance monitor
  106123. */
  106124. reset(): void;
  106125. }
  106126. /**
  106127. * RollingAverage
  106128. *
  106129. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106130. */
  106131. export class RollingAverage {
  106132. /**
  106133. * Current average
  106134. */
  106135. average: number;
  106136. /**
  106137. * Current variance
  106138. */
  106139. variance: number;
  106140. protected _samples: Array<number>;
  106141. protected _sampleCount: number;
  106142. protected _pos: number;
  106143. protected _m2: number;
  106144. /**
  106145. * constructor
  106146. * @param length The number of samples required to saturate the sliding window
  106147. */
  106148. constructor(length: number);
  106149. /**
  106150. * Adds a sample to the sample set
  106151. * @param v The sample value
  106152. */
  106153. add(v: number): void;
  106154. /**
  106155. * Returns previously added values or null if outside of history or outside the sliding window domain
  106156. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106157. * @return Value previously recorded with add() or null if outside of range
  106158. */
  106159. history(i: number): number;
  106160. /**
  106161. * Returns true if enough samples have been taken to completely fill the sliding window
  106162. * @return true if sample-set saturated
  106163. */
  106164. isSaturated(): boolean;
  106165. /**
  106166. * Resets the rolling average (equivalent to 0 samples taken so far)
  106167. */
  106168. reset(): void;
  106169. /**
  106170. * Wraps a value around the sample range boundaries
  106171. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106172. * @return Wrapped position in sample range
  106173. */
  106174. protected _wrapPosition(i: number): number;
  106175. }
  106176. }
  106177. declare module BABYLON {
  106178. /**
  106179. * This class is used to track a performance counter which is number based.
  106180. * The user has access to many properties which give statistics of different nature.
  106181. *
  106182. * The implementer can track two kinds of Performance Counter: time and count.
  106183. * 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.
  106184. * 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.
  106185. */
  106186. export class PerfCounter {
  106187. /**
  106188. * Gets or sets a global boolean to turn on and off all the counters
  106189. */
  106190. static Enabled: boolean;
  106191. /**
  106192. * Returns the smallest value ever
  106193. */
  106194. get min(): number;
  106195. /**
  106196. * Returns the biggest value ever
  106197. */
  106198. get max(): number;
  106199. /**
  106200. * Returns the average value since the performance counter is running
  106201. */
  106202. get average(): number;
  106203. /**
  106204. * Returns the average value of the last second the counter was monitored
  106205. */
  106206. get lastSecAverage(): number;
  106207. /**
  106208. * Returns the current value
  106209. */
  106210. get current(): number;
  106211. /**
  106212. * Gets the accumulated total
  106213. */
  106214. get total(): number;
  106215. /**
  106216. * Gets the total value count
  106217. */
  106218. get count(): number;
  106219. /**
  106220. * Creates a new counter
  106221. */
  106222. constructor();
  106223. /**
  106224. * Call this method to start monitoring a new frame.
  106225. * 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.
  106226. */
  106227. fetchNewFrame(): void;
  106228. /**
  106229. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106230. * @param newCount the count value to add to the monitored count
  106231. * @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.
  106232. */
  106233. addCount(newCount: number, fetchResult: boolean): void;
  106234. /**
  106235. * Start monitoring this performance counter
  106236. */
  106237. beginMonitoring(): void;
  106238. /**
  106239. * Compute the time lapsed since the previous beginMonitoring() call.
  106240. * @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
  106241. */
  106242. endMonitoring(newFrame?: boolean): void;
  106243. private _fetchResult;
  106244. private _startMonitoringTime;
  106245. private _min;
  106246. private _max;
  106247. private _average;
  106248. private _current;
  106249. private _totalValueCount;
  106250. private _totalAccumulated;
  106251. private _lastSecAverage;
  106252. private _lastSecAccumulated;
  106253. private _lastSecTime;
  106254. private _lastSecValueCount;
  106255. }
  106256. }
  106257. declare module BABYLON {
  106258. interface ThinEngine {
  106259. /**
  106260. * Sets alpha constants used by some alpha blending modes
  106261. * @param r defines the red component
  106262. * @param g defines the green component
  106263. * @param b defines the blue component
  106264. * @param a defines the alpha component
  106265. */
  106266. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106267. /**
  106268. * Sets the current alpha mode
  106269. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106270. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106271. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106272. */
  106273. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106274. /**
  106275. * Gets the current alpha mode
  106276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106277. * @returns the current alpha mode
  106278. */
  106279. getAlphaMode(): number;
  106280. /**
  106281. * Sets the current alpha equation
  106282. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106283. */
  106284. setAlphaEquation(equation: number): void;
  106285. /**
  106286. * Gets the current alpha equation.
  106287. * @returns the current alpha equation
  106288. */
  106289. getAlphaEquation(): number;
  106290. }
  106291. }
  106292. declare module BABYLON {
  106293. /**
  106294. * Defines the interface used by display changed events
  106295. */
  106296. export interface IDisplayChangedEventArgs {
  106297. /** Gets the vrDisplay object (if any) */
  106298. vrDisplay: Nullable<any>;
  106299. /** Gets a boolean indicating if webVR is supported */
  106300. vrSupported: boolean;
  106301. }
  106302. /**
  106303. * Defines the interface used by objects containing a viewport (like a camera)
  106304. */
  106305. interface IViewportOwnerLike {
  106306. /**
  106307. * Gets or sets the viewport
  106308. */
  106309. viewport: IViewportLike;
  106310. }
  106311. /**
  106312. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106313. */
  106314. export class Engine extends ThinEngine {
  106315. /** Defines that alpha blending is disabled */
  106316. static readonly ALPHA_DISABLE: number;
  106317. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106318. static readonly ALPHA_ADD: number;
  106319. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106320. static readonly ALPHA_COMBINE: number;
  106321. /** Defines that alpha blending to DEST - SRC * DEST */
  106322. static readonly ALPHA_SUBTRACT: number;
  106323. /** Defines that alpha blending to SRC * DEST */
  106324. static readonly ALPHA_MULTIPLY: number;
  106325. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106326. static readonly ALPHA_MAXIMIZED: number;
  106327. /** Defines that alpha blending to SRC + DEST */
  106328. static readonly ALPHA_ONEONE: number;
  106329. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106330. static readonly ALPHA_PREMULTIPLIED: number;
  106331. /**
  106332. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106333. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106334. */
  106335. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106336. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106337. static readonly ALPHA_INTERPOLATE: number;
  106338. /**
  106339. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106340. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106341. */
  106342. static readonly ALPHA_SCREENMODE: number;
  106343. /** Defines that the ressource is not delayed*/
  106344. static readonly DELAYLOADSTATE_NONE: number;
  106345. /** Defines that the ressource was successfully delay loaded */
  106346. static readonly DELAYLOADSTATE_LOADED: number;
  106347. /** Defines that the ressource is currently delay loading */
  106348. static readonly DELAYLOADSTATE_LOADING: number;
  106349. /** Defines that the ressource is delayed and has not started loading */
  106350. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106352. static readonly NEVER: number;
  106353. /** 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 */
  106354. static readonly ALWAYS: number;
  106355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106356. static readonly LESS: number;
  106357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106358. static readonly EQUAL: number;
  106359. /** 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 */
  106360. static readonly LEQUAL: number;
  106361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106362. static readonly GREATER: number;
  106363. /** 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 */
  106364. static readonly GEQUAL: number;
  106365. /** 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 */
  106366. static readonly NOTEQUAL: number;
  106367. /** Passed to stencilOperation to specify that stencil value must be kept */
  106368. static readonly KEEP: number;
  106369. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106370. static readonly REPLACE: number;
  106371. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106372. static readonly INCR: number;
  106373. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106374. static readonly DECR: number;
  106375. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106376. static readonly INVERT: number;
  106377. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106378. static readonly INCR_WRAP: number;
  106379. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106380. static readonly DECR_WRAP: number;
  106381. /** Texture is not repeating outside of 0..1 UVs */
  106382. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106383. /** Texture is repeating outside of 0..1 UVs */
  106384. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106385. /** Texture is repeating and mirrored */
  106386. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106387. /** ALPHA */
  106388. static readonly TEXTUREFORMAT_ALPHA: number;
  106389. /** LUMINANCE */
  106390. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106391. /** LUMINANCE_ALPHA */
  106392. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106393. /** RGB */
  106394. static readonly TEXTUREFORMAT_RGB: number;
  106395. /** RGBA */
  106396. static readonly TEXTUREFORMAT_RGBA: number;
  106397. /** RED */
  106398. static readonly TEXTUREFORMAT_RED: number;
  106399. /** RED (2nd reference) */
  106400. static readonly TEXTUREFORMAT_R: number;
  106401. /** RG */
  106402. static readonly TEXTUREFORMAT_RG: number;
  106403. /** RED_INTEGER */
  106404. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106405. /** RED_INTEGER (2nd reference) */
  106406. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106407. /** RG_INTEGER */
  106408. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106409. /** RGB_INTEGER */
  106410. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106411. /** RGBA_INTEGER */
  106412. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106413. /** UNSIGNED_BYTE */
  106414. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106415. /** UNSIGNED_BYTE (2nd reference) */
  106416. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106417. /** FLOAT */
  106418. static readonly TEXTURETYPE_FLOAT: number;
  106419. /** HALF_FLOAT */
  106420. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106421. /** BYTE */
  106422. static readonly TEXTURETYPE_BYTE: number;
  106423. /** SHORT */
  106424. static readonly TEXTURETYPE_SHORT: number;
  106425. /** UNSIGNED_SHORT */
  106426. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106427. /** INT */
  106428. static readonly TEXTURETYPE_INT: number;
  106429. /** UNSIGNED_INT */
  106430. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106431. /** UNSIGNED_SHORT_4_4_4_4 */
  106432. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106433. /** UNSIGNED_SHORT_5_5_5_1 */
  106434. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106435. /** UNSIGNED_SHORT_5_6_5 */
  106436. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106437. /** UNSIGNED_INT_2_10_10_10_REV */
  106438. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106439. /** UNSIGNED_INT_24_8 */
  106440. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106441. /** UNSIGNED_INT_10F_11F_11F_REV */
  106442. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106443. /** UNSIGNED_INT_5_9_9_9_REV */
  106444. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106445. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106446. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106447. /** nearest is mag = nearest and min = nearest and mip = linear */
  106448. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106449. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106450. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106451. /** Trilinear is mag = linear and min = linear and mip = linear */
  106452. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106453. /** nearest is mag = nearest and min = nearest and mip = linear */
  106454. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106455. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106456. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106457. /** Trilinear is mag = linear and min = linear and mip = linear */
  106458. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106459. /** mag = nearest and min = nearest and mip = nearest */
  106460. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106461. /** mag = nearest and min = linear and mip = nearest */
  106462. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106463. /** mag = nearest and min = linear and mip = linear */
  106464. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106465. /** mag = nearest and min = linear and mip = none */
  106466. static readonly TEXTURE_NEAREST_LINEAR: number;
  106467. /** mag = nearest and min = nearest and mip = none */
  106468. static readonly TEXTURE_NEAREST_NEAREST: number;
  106469. /** mag = linear and min = nearest and mip = nearest */
  106470. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106471. /** mag = linear and min = nearest and mip = linear */
  106472. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106473. /** mag = linear and min = linear and mip = none */
  106474. static readonly TEXTURE_LINEAR_LINEAR: number;
  106475. /** mag = linear and min = nearest and mip = none */
  106476. static readonly TEXTURE_LINEAR_NEAREST: number;
  106477. /** Explicit coordinates mode */
  106478. static readonly TEXTURE_EXPLICIT_MODE: number;
  106479. /** Spherical coordinates mode */
  106480. static readonly TEXTURE_SPHERICAL_MODE: number;
  106481. /** Planar coordinates mode */
  106482. static readonly TEXTURE_PLANAR_MODE: number;
  106483. /** Cubic coordinates mode */
  106484. static readonly TEXTURE_CUBIC_MODE: number;
  106485. /** Projection coordinates mode */
  106486. static readonly TEXTURE_PROJECTION_MODE: number;
  106487. /** Skybox coordinates mode */
  106488. static readonly TEXTURE_SKYBOX_MODE: number;
  106489. /** Inverse Cubic coordinates mode */
  106490. static readonly TEXTURE_INVCUBIC_MODE: number;
  106491. /** Equirectangular coordinates mode */
  106492. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106493. /** Equirectangular Fixed coordinates mode */
  106494. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106495. /** Equirectangular Fixed Mirrored coordinates mode */
  106496. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106497. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106498. static readonly SCALEMODE_FLOOR: number;
  106499. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106500. static readonly SCALEMODE_NEAREST: number;
  106501. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106502. static readonly SCALEMODE_CEILING: number;
  106503. /**
  106504. * Returns the current npm package of the sdk
  106505. */
  106506. static get NpmPackage(): string;
  106507. /**
  106508. * Returns the current version of the framework
  106509. */
  106510. static get Version(): string;
  106511. /** Gets the list of created engines */
  106512. static get Instances(): Engine[];
  106513. /**
  106514. * Gets the latest created engine
  106515. */
  106516. static get LastCreatedEngine(): Nullable<Engine>;
  106517. /**
  106518. * Gets the latest created scene
  106519. */
  106520. static get LastCreatedScene(): Nullable<Scene>;
  106521. /**
  106522. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106523. * @param flag defines which part of the materials must be marked as dirty
  106524. * @param predicate defines a predicate used to filter which materials should be affected
  106525. */
  106526. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106527. /**
  106528. * Method called to create the default loading screen.
  106529. * This can be overriden in your own app.
  106530. * @param canvas The rendering canvas element
  106531. * @returns The loading screen
  106532. */
  106533. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106534. /**
  106535. * Method called to create the default rescale post process on each engine.
  106536. */
  106537. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106538. /**
  106539. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106540. **/
  106541. enableOfflineSupport: boolean;
  106542. /**
  106543. * 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)
  106544. **/
  106545. disableManifestCheck: boolean;
  106546. /**
  106547. * Gets the list of created scenes
  106548. */
  106549. scenes: Scene[];
  106550. /**
  106551. * Event raised when a new scene is created
  106552. */
  106553. onNewSceneAddedObservable: Observable<Scene>;
  106554. /**
  106555. * Gets the list of created postprocesses
  106556. */
  106557. postProcesses: PostProcess[];
  106558. /**
  106559. * Gets a boolean indicating if the pointer is currently locked
  106560. */
  106561. isPointerLock: boolean;
  106562. /**
  106563. * Observable event triggered each time the rendering canvas is resized
  106564. */
  106565. onResizeObservable: Observable<Engine>;
  106566. /**
  106567. * Observable event triggered each time the canvas loses focus
  106568. */
  106569. onCanvasBlurObservable: Observable<Engine>;
  106570. /**
  106571. * Observable event triggered each time the canvas gains focus
  106572. */
  106573. onCanvasFocusObservable: Observable<Engine>;
  106574. /**
  106575. * Observable event triggered each time the canvas receives pointerout event
  106576. */
  106577. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106578. /**
  106579. * Observable raised when the engine begins a new frame
  106580. */
  106581. onBeginFrameObservable: Observable<Engine>;
  106582. /**
  106583. * If set, will be used to request the next animation frame for the render loop
  106584. */
  106585. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106586. /**
  106587. * Observable raised when the engine ends the current frame
  106588. */
  106589. onEndFrameObservable: Observable<Engine>;
  106590. /**
  106591. * Observable raised when the engine is about to compile a shader
  106592. */
  106593. onBeforeShaderCompilationObservable: Observable<Engine>;
  106594. /**
  106595. * Observable raised when the engine has jsut compiled a shader
  106596. */
  106597. onAfterShaderCompilationObservable: Observable<Engine>;
  106598. /**
  106599. * Gets the audio engine
  106600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106601. * @ignorenaming
  106602. */
  106603. static audioEngine: IAudioEngine;
  106604. /**
  106605. * Default AudioEngine factory responsible of creating the Audio Engine.
  106606. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106607. */
  106608. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106609. /**
  106610. * Default offline support factory responsible of creating a tool used to store data locally.
  106611. * By default, this will create a Database object if the workload has been embedded.
  106612. */
  106613. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106614. private _loadingScreen;
  106615. private _pointerLockRequested;
  106616. private _dummyFramebuffer;
  106617. private _rescalePostProcess;
  106618. private _deterministicLockstep;
  106619. private _lockstepMaxSteps;
  106620. private _timeStep;
  106621. protected get _supportsHardwareTextureRescaling(): boolean;
  106622. private _fps;
  106623. private _deltaTime;
  106624. /** @hidden */
  106625. _drawCalls: PerfCounter;
  106626. /** 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 */
  106627. canvasTabIndex: number;
  106628. /**
  106629. * Turn this value on if you want to pause FPS computation when in background
  106630. */
  106631. disablePerformanceMonitorInBackground: boolean;
  106632. private _performanceMonitor;
  106633. /**
  106634. * Gets the performance monitor attached to this engine
  106635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106636. */
  106637. get performanceMonitor(): PerformanceMonitor;
  106638. private _onFocus;
  106639. private _onBlur;
  106640. private _onCanvasPointerOut;
  106641. private _onCanvasBlur;
  106642. private _onCanvasFocus;
  106643. private _onFullscreenChange;
  106644. private _onPointerLockChange;
  106645. /**
  106646. * Gets the HTML element used to attach event listeners
  106647. * @returns a HTML element
  106648. */
  106649. getInputElement(): Nullable<HTMLElement>;
  106650. /**
  106651. * Creates a new engine
  106652. * @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
  106653. * @param antialias defines enable antialiasing (default: false)
  106654. * @param options defines further options to be sent to the getContext() function
  106655. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106656. */
  106657. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106658. /**
  106659. * Gets current aspect ratio
  106660. * @param viewportOwner defines the camera to use to get the aspect ratio
  106661. * @param useScreen defines if screen size must be used (or the current render target if any)
  106662. * @returns a number defining the aspect ratio
  106663. */
  106664. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106665. /**
  106666. * Gets current screen aspect ratio
  106667. * @returns a number defining the aspect ratio
  106668. */
  106669. getScreenAspectRatio(): number;
  106670. /**
  106671. * Gets the client rect of the HTML canvas attached with the current webGL context
  106672. * @returns a client rectanglee
  106673. */
  106674. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106675. /**
  106676. * Gets the client rect of the HTML element used for events
  106677. * @returns a client rectanglee
  106678. */
  106679. getInputElementClientRect(): Nullable<ClientRect>;
  106680. /**
  106681. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106682. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106683. * @returns true if engine is in deterministic lock step mode
  106684. */
  106685. isDeterministicLockStep(): boolean;
  106686. /**
  106687. * Gets the max steps when engine is running in deterministic lock step
  106688. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106689. * @returns the max steps
  106690. */
  106691. getLockstepMaxSteps(): number;
  106692. /**
  106693. * Returns the time in ms between steps when using deterministic lock step.
  106694. * @returns time step in (ms)
  106695. */
  106696. getTimeStep(): number;
  106697. /**
  106698. * Force the mipmap generation for the given render target texture
  106699. * @param texture defines the render target texture to use
  106700. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106701. */
  106702. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106703. /** States */
  106704. /**
  106705. * Set various states to the webGL context
  106706. * @param culling defines backface culling state
  106707. * @param zOffset defines the value to apply to zOffset (0 by default)
  106708. * @param force defines if states must be applied even if cache is up to date
  106709. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106710. */
  106711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106712. /**
  106713. * Set the z offset to apply to current rendering
  106714. * @param value defines the offset to apply
  106715. */
  106716. setZOffset(value: number): void;
  106717. /**
  106718. * Gets the current value of the zOffset
  106719. * @returns the current zOffset state
  106720. */
  106721. getZOffset(): number;
  106722. /**
  106723. * Enable or disable depth buffering
  106724. * @param enable defines the state to set
  106725. */
  106726. setDepthBuffer(enable: boolean): void;
  106727. /**
  106728. * Gets a boolean indicating if depth writing is enabled
  106729. * @returns the current depth writing state
  106730. */
  106731. getDepthWrite(): boolean;
  106732. /**
  106733. * Enable or disable depth writing
  106734. * @param enable defines the state to set
  106735. */
  106736. setDepthWrite(enable: boolean): void;
  106737. /**
  106738. * Gets a boolean indicating if stencil buffer is enabled
  106739. * @returns the current stencil buffer state
  106740. */
  106741. getStencilBuffer(): boolean;
  106742. /**
  106743. * Enable or disable the stencil buffer
  106744. * @param enable defines if the stencil buffer must be enabled or disabled
  106745. */
  106746. setStencilBuffer(enable: boolean): void;
  106747. /**
  106748. * Gets the current stencil mask
  106749. * @returns a number defining the new stencil mask to use
  106750. */
  106751. getStencilMask(): number;
  106752. /**
  106753. * Sets the current stencil mask
  106754. * @param mask defines the new stencil mask to use
  106755. */
  106756. setStencilMask(mask: number): void;
  106757. /**
  106758. * Gets the current stencil function
  106759. * @returns a number defining the stencil function to use
  106760. */
  106761. getStencilFunction(): number;
  106762. /**
  106763. * Gets the current stencil reference value
  106764. * @returns a number defining the stencil reference value to use
  106765. */
  106766. getStencilFunctionReference(): number;
  106767. /**
  106768. * Gets the current stencil mask
  106769. * @returns a number defining the stencil mask to use
  106770. */
  106771. getStencilFunctionMask(): number;
  106772. /**
  106773. * Sets the current stencil function
  106774. * @param stencilFunc defines the new stencil function to use
  106775. */
  106776. setStencilFunction(stencilFunc: number): void;
  106777. /**
  106778. * Sets the current stencil reference
  106779. * @param reference defines the new stencil reference to use
  106780. */
  106781. setStencilFunctionReference(reference: number): void;
  106782. /**
  106783. * Sets the current stencil mask
  106784. * @param mask defines the new stencil mask to use
  106785. */
  106786. setStencilFunctionMask(mask: number): void;
  106787. /**
  106788. * Gets the current stencil operation when stencil fails
  106789. * @returns a number defining stencil operation to use when stencil fails
  106790. */
  106791. getStencilOperationFail(): number;
  106792. /**
  106793. * Gets the current stencil operation when depth fails
  106794. * @returns a number defining stencil operation to use when depth fails
  106795. */
  106796. getStencilOperationDepthFail(): number;
  106797. /**
  106798. * Gets the current stencil operation when stencil passes
  106799. * @returns a number defining stencil operation to use when stencil passes
  106800. */
  106801. getStencilOperationPass(): number;
  106802. /**
  106803. * Sets the stencil operation to use when stencil fails
  106804. * @param operation defines the stencil operation to use when stencil fails
  106805. */
  106806. setStencilOperationFail(operation: number): void;
  106807. /**
  106808. * Sets the stencil operation to use when depth fails
  106809. * @param operation defines the stencil operation to use when depth fails
  106810. */
  106811. setStencilOperationDepthFail(operation: number): void;
  106812. /**
  106813. * Sets the stencil operation to use when stencil passes
  106814. * @param operation defines the stencil operation to use when stencil passes
  106815. */
  106816. setStencilOperationPass(operation: number): void;
  106817. /**
  106818. * Sets a boolean indicating if the dithering state is enabled or disabled
  106819. * @param value defines the dithering state
  106820. */
  106821. setDitheringState(value: boolean): void;
  106822. /**
  106823. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106824. * @param value defines the rasterizer state
  106825. */
  106826. setRasterizerState(value: boolean): void;
  106827. /**
  106828. * Gets the current depth function
  106829. * @returns a number defining the depth function
  106830. */
  106831. getDepthFunction(): Nullable<number>;
  106832. /**
  106833. * Sets the current depth function
  106834. * @param depthFunc defines the function to use
  106835. */
  106836. setDepthFunction(depthFunc: number): void;
  106837. /**
  106838. * Sets the current depth function to GREATER
  106839. */
  106840. setDepthFunctionToGreater(): void;
  106841. /**
  106842. * Sets the current depth function to GEQUAL
  106843. */
  106844. setDepthFunctionToGreaterOrEqual(): void;
  106845. /**
  106846. * Sets the current depth function to LESS
  106847. */
  106848. setDepthFunctionToLess(): void;
  106849. /**
  106850. * Sets the current depth function to LEQUAL
  106851. */
  106852. setDepthFunctionToLessOrEqual(): void;
  106853. private _cachedStencilBuffer;
  106854. private _cachedStencilFunction;
  106855. private _cachedStencilMask;
  106856. private _cachedStencilOperationPass;
  106857. private _cachedStencilOperationFail;
  106858. private _cachedStencilOperationDepthFail;
  106859. private _cachedStencilReference;
  106860. /**
  106861. * Caches the the state of the stencil buffer
  106862. */
  106863. cacheStencilState(): void;
  106864. /**
  106865. * Restores the state of the stencil buffer
  106866. */
  106867. restoreStencilState(): void;
  106868. /**
  106869. * Directly set the WebGL Viewport
  106870. * @param x defines the x coordinate of the viewport (in screen space)
  106871. * @param y defines the y coordinate of the viewport (in screen space)
  106872. * @param width defines the width of the viewport (in screen space)
  106873. * @param height defines the height of the viewport (in screen space)
  106874. * @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
  106875. */
  106876. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106877. /**
  106878. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106879. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106880. * @param y defines the y-coordinate of the corner of the clear rectangle
  106881. * @param width defines the width of the clear rectangle
  106882. * @param height defines the height of the clear rectangle
  106883. * @param clearColor defines the clear color
  106884. */
  106885. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106886. /**
  106887. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106888. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106889. * @param y defines the y-coordinate of the corner of the clear rectangle
  106890. * @param width defines the width of the clear rectangle
  106891. * @param height defines the height of the clear rectangle
  106892. */
  106893. enableScissor(x: number, y: number, width: number, height: number): void;
  106894. /**
  106895. * Disable previously set scissor test rectangle
  106896. */
  106897. disableScissor(): void;
  106898. protected _reportDrawCall(): void;
  106899. /**
  106900. * Initializes a webVR display and starts listening to display change events
  106901. * The onVRDisplayChangedObservable will be notified upon these changes
  106902. * @returns The onVRDisplayChangedObservable
  106903. */
  106904. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106905. /** @hidden */
  106906. _prepareVRComponent(): void;
  106907. /** @hidden */
  106908. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106909. /** @hidden */
  106910. _submitVRFrame(): void;
  106911. /**
  106912. * Call this function to leave webVR mode
  106913. * Will do nothing if webVR is not supported or if there is no webVR device
  106914. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106915. */
  106916. disableVR(): void;
  106917. /**
  106918. * Gets a boolean indicating that the system is in VR mode and is presenting
  106919. * @returns true if VR mode is engaged
  106920. */
  106921. isVRPresenting(): boolean;
  106922. /** @hidden */
  106923. _requestVRFrame(): void;
  106924. /** @hidden */
  106925. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106926. /**
  106927. * Gets the source code of the vertex shader associated with a specific webGL program
  106928. * @param program defines the program to use
  106929. * @returns a string containing the source code of the vertex shader associated with the program
  106930. */
  106931. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106932. /**
  106933. * Gets the source code of the fragment shader associated with a specific webGL program
  106934. * @param program defines the program to use
  106935. * @returns a string containing the source code of the fragment shader associated with the program
  106936. */
  106937. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106938. /**
  106939. * Sets a depth stencil texture from a render target to the according uniform.
  106940. * @param channel The texture channel
  106941. * @param uniform The uniform to set
  106942. * @param texture The render target texture containing the depth stencil texture to apply
  106943. */
  106944. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106945. /**
  106946. * Sets a texture to the webGL context from a postprocess
  106947. * @param channel defines the channel to use
  106948. * @param postProcess defines the source postprocess
  106949. */
  106950. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106951. /**
  106952. * Binds the output of the passed in post process to the texture channel specified
  106953. * @param channel The channel the texture should be bound to
  106954. * @param postProcess The post process which's output should be bound
  106955. */
  106956. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106957. /** @hidden */
  106958. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106959. protected _rebuildBuffers(): void;
  106960. /** @hidden */
  106961. _renderFrame(): void;
  106962. _renderLoop(): void;
  106963. /** @hidden */
  106964. _renderViews(): boolean;
  106965. /**
  106966. * Toggle full screen mode
  106967. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106968. */
  106969. switchFullscreen(requestPointerLock: boolean): void;
  106970. /**
  106971. * Enters full screen mode
  106972. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106973. */
  106974. enterFullscreen(requestPointerLock: boolean): void;
  106975. /**
  106976. * Exits full screen mode
  106977. */
  106978. exitFullscreen(): void;
  106979. /**
  106980. * Enters Pointerlock mode
  106981. */
  106982. enterPointerlock(): void;
  106983. /**
  106984. * Exits Pointerlock mode
  106985. */
  106986. exitPointerlock(): void;
  106987. /**
  106988. * Begin a new frame
  106989. */
  106990. beginFrame(): void;
  106991. /**
  106992. * Enf the current frame
  106993. */
  106994. endFrame(): void;
  106995. resize(): void;
  106996. /**
  106997. * Set the compressed texture format to use, based on the formats you have, and the formats
  106998. * supported by the hardware / browser.
  106999. *
  107000. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  107001. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  107002. * to API arguments needed to compressed textures. This puts the burden on the container
  107003. * generator to house the arcane code for determining these for current & future formats.
  107004. *
  107005. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  107006. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  107007. *
  107008. * Note: The result of this call is not taken into account when a texture is base64.
  107009. *
  107010. * @param formatsAvailable defines the list of those format families you have created
  107011. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  107012. *
  107013. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  107014. * @returns The extension selected.
  107015. */
  107016. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  107017. /**
  107018. * Set the compressed texture extensions or file names to skip.
  107019. *
  107020. * @param skippedFiles defines the list of those texture files you want to skip
  107021. * Example: [".dds", ".env", "myfile.png"]
  107022. */
  107023. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  107024. /**
  107025. * Force a specific size of the canvas
  107026. * @param width defines the new canvas' width
  107027. * @param height defines the new canvas' height
  107028. */
  107029. setSize(width: number, height: number): void;
  107030. /**
  107031. * Updates a dynamic vertex buffer.
  107032. * @param vertexBuffer the vertex buffer to update
  107033. * @param data the data used to update the vertex buffer
  107034. * @param byteOffset the byte offset of the data
  107035. * @param byteLength the byte length of the data
  107036. */
  107037. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107038. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107039. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107040. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107041. _releaseTexture(texture: InternalTexture): void;
  107042. /**
  107043. * @hidden
  107044. * Rescales a texture
  107045. * @param source input texutre
  107046. * @param destination destination texture
  107047. * @param scene scene to use to render the resize
  107048. * @param internalFormat format to use when resizing
  107049. * @param onComplete callback to be called when resize has completed
  107050. */
  107051. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107052. /**
  107053. * Gets the current framerate
  107054. * @returns a number representing the framerate
  107055. */
  107056. getFps(): number;
  107057. /**
  107058. * Gets the time spent between current and previous frame
  107059. * @returns a number representing the delta time in ms
  107060. */
  107061. getDeltaTime(): number;
  107062. private _measureFps;
  107063. /** @hidden */
  107064. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107065. /**
  107066. * Update a dynamic index buffer
  107067. * @param indexBuffer defines the target index buffer
  107068. * @param indices defines the data to update
  107069. * @param offset defines the offset in the target index buffer where update should start
  107070. */
  107071. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107072. /**
  107073. * Updates the sample count of a render target texture
  107074. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107075. * @param texture defines the texture to update
  107076. * @param samples defines the sample count to set
  107077. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107078. */
  107079. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107080. /**
  107081. * Updates a depth texture Comparison Mode and Function.
  107082. * If the comparison Function is equal to 0, the mode will be set to none.
  107083. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107084. * @param texture The texture to set the comparison function for
  107085. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107086. */
  107087. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107088. /**
  107089. * Creates a webGL buffer to use with instanciation
  107090. * @param capacity defines the size of the buffer
  107091. * @returns the webGL buffer
  107092. */
  107093. createInstancesBuffer(capacity: number): DataBuffer;
  107094. /**
  107095. * Delete a webGL buffer used with instanciation
  107096. * @param buffer defines the webGL buffer to delete
  107097. */
  107098. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107099. /** @hidden */
  107100. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107101. dispose(): void;
  107102. private _disableTouchAction;
  107103. /**
  107104. * Display the loading screen
  107105. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107106. */
  107107. displayLoadingUI(): void;
  107108. /**
  107109. * Hide the loading screen
  107110. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107111. */
  107112. hideLoadingUI(): void;
  107113. /**
  107114. * Gets the current loading screen object
  107115. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107116. */
  107117. get loadingScreen(): ILoadingScreen;
  107118. /**
  107119. * Sets the current loading screen object
  107120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107121. */
  107122. set loadingScreen(loadingScreen: ILoadingScreen);
  107123. /**
  107124. * Sets the current loading screen text
  107125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107126. */
  107127. set loadingUIText(text: string);
  107128. /**
  107129. * Sets the current loading screen background color
  107130. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107131. */
  107132. set loadingUIBackgroundColor(color: string);
  107133. /** Pointerlock and fullscreen */
  107134. /**
  107135. * Ask the browser to promote the current element to pointerlock mode
  107136. * @param element defines the DOM element to promote
  107137. */
  107138. static _RequestPointerlock(element: HTMLElement): void;
  107139. /**
  107140. * Asks the browser to exit pointerlock mode
  107141. */
  107142. static _ExitPointerlock(): void;
  107143. /**
  107144. * Ask the browser to promote the current element to fullscreen rendering mode
  107145. * @param element defines the DOM element to promote
  107146. */
  107147. static _RequestFullscreen(element: HTMLElement): void;
  107148. /**
  107149. * Asks the browser to exit fullscreen mode
  107150. */
  107151. static _ExitFullscreen(): void;
  107152. }
  107153. }
  107154. declare module BABYLON {
  107155. /**
  107156. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107157. * during the life time of the application.
  107158. */
  107159. export class EngineStore {
  107160. /** Gets the list of created engines */
  107161. static Instances: Engine[];
  107162. /** @hidden */
  107163. static _LastCreatedScene: Nullable<Scene>;
  107164. /**
  107165. * Gets the latest created engine
  107166. */
  107167. static get LastCreatedEngine(): Nullable<Engine>;
  107168. /**
  107169. * Gets the latest created scene
  107170. */
  107171. static get LastCreatedScene(): Nullable<Scene>;
  107172. /**
  107173. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107174. * @ignorenaming
  107175. */
  107176. static UseFallbackTexture: boolean;
  107177. /**
  107178. * Texture content used if a texture cannot loaded
  107179. * @ignorenaming
  107180. */
  107181. static FallbackTexture: string;
  107182. }
  107183. }
  107184. declare module BABYLON {
  107185. /**
  107186. * Helper class that provides a small promise polyfill
  107187. */
  107188. export class PromisePolyfill {
  107189. /**
  107190. * Static function used to check if the polyfill is required
  107191. * If this is the case then the function will inject the polyfill to window.Promise
  107192. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107193. */
  107194. static Apply(force?: boolean): void;
  107195. }
  107196. }
  107197. declare module BABYLON {
  107198. /**
  107199. * Interface for screenshot methods with describe argument called `size` as object with options
  107200. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107201. */
  107202. export interface IScreenshotSize {
  107203. /**
  107204. * number in pixels for canvas height
  107205. */
  107206. height?: number;
  107207. /**
  107208. * multiplier allowing render at a higher or lower resolution
  107209. * If value is defined then height and width will be ignored and taken from camera
  107210. */
  107211. precision?: number;
  107212. /**
  107213. * number in pixels for canvas width
  107214. */
  107215. width?: number;
  107216. }
  107217. }
  107218. declare module BABYLON {
  107219. interface IColor4Like {
  107220. r: float;
  107221. g: float;
  107222. b: float;
  107223. a: float;
  107224. }
  107225. /**
  107226. * Class containing a set of static utilities functions
  107227. */
  107228. export class Tools {
  107229. /**
  107230. * Gets or sets the base URL to use to load assets
  107231. */
  107232. static get BaseUrl(): string;
  107233. static set BaseUrl(value: string);
  107234. /**
  107235. * Enable/Disable Custom HTTP Request Headers globally.
  107236. * default = false
  107237. * @see CustomRequestHeaders
  107238. */
  107239. static UseCustomRequestHeaders: boolean;
  107240. /**
  107241. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107242. * i.e. when loading files, where the server/service expects an Authorization header
  107243. */
  107244. static CustomRequestHeaders: {
  107245. [key: string]: string;
  107246. };
  107247. /**
  107248. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107249. */
  107250. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107251. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107252. /**
  107253. * Default behaviour for cors in the application.
  107254. * It can be a string if the expected behavior is identical in the entire app.
  107255. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107256. */
  107257. static CorsBehavior: string | ((url: string | string[]) => string);
  107258. /**
  107259. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107260. * @ignorenaming
  107261. */
  107262. static get UseFallbackTexture(): boolean;
  107263. static set UseFallbackTexture(value: boolean);
  107264. /**
  107265. * Use this object to register external classes like custom textures or material
  107266. * to allow the laoders to instantiate them
  107267. */
  107268. static get RegisteredExternalClasses(): {
  107269. [key: string]: Object;
  107270. };
  107271. static set RegisteredExternalClasses(classes: {
  107272. [key: string]: Object;
  107273. });
  107274. /**
  107275. * Texture content used if a texture cannot loaded
  107276. * @ignorenaming
  107277. */
  107278. static get fallbackTexture(): string;
  107279. static set fallbackTexture(value: string);
  107280. /**
  107281. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107282. * @param u defines the coordinate on X axis
  107283. * @param v defines the coordinate on Y axis
  107284. * @param width defines the width of the source data
  107285. * @param height defines the height of the source data
  107286. * @param pixels defines the source byte array
  107287. * @param color defines the output color
  107288. */
  107289. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107290. /**
  107291. * Interpolates between a and b via alpha
  107292. * @param a The lower value (returned when alpha = 0)
  107293. * @param b The upper value (returned when alpha = 1)
  107294. * @param alpha The interpolation-factor
  107295. * @return The mixed value
  107296. */
  107297. static Mix(a: number, b: number, alpha: number): number;
  107298. /**
  107299. * Tries to instantiate a new object from a given class name
  107300. * @param className defines the class name to instantiate
  107301. * @returns the new object or null if the system was not able to do the instantiation
  107302. */
  107303. static Instantiate(className: string): any;
  107304. /**
  107305. * Provides a slice function that will work even on IE
  107306. * @param data defines the array to slice
  107307. * @param start defines the start of the data (optional)
  107308. * @param end defines the end of the data (optional)
  107309. * @returns the new sliced array
  107310. */
  107311. static Slice<T>(data: T, start?: number, end?: number): T;
  107312. /**
  107313. * Polyfill for setImmediate
  107314. * @param action defines the action to execute after the current execution block
  107315. */
  107316. static SetImmediate(action: () => void): void;
  107317. /**
  107318. * Function indicating if a number is an exponent of 2
  107319. * @param value defines the value to test
  107320. * @returns true if the value is an exponent of 2
  107321. */
  107322. static IsExponentOfTwo(value: number): boolean;
  107323. private static _tmpFloatArray;
  107324. /**
  107325. * Returns the nearest 32-bit single precision float representation of a Number
  107326. * @param value A Number. If the parameter is of a different type, it will get converted
  107327. * to a number or to NaN if it cannot be converted
  107328. * @returns number
  107329. */
  107330. static FloatRound(value: number): number;
  107331. /**
  107332. * Extracts the filename from a path
  107333. * @param path defines the path to use
  107334. * @returns the filename
  107335. */
  107336. static GetFilename(path: string): string;
  107337. /**
  107338. * Extracts the "folder" part of a path (everything before the filename).
  107339. * @param uri The URI to extract the info from
  107340. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107341. * @returns The "folder" part of the path
  107342. */
  107343. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107344. /**
  107345. * Extracts text content from a DOM element hierarchy
  107346. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107347. */
  107348. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107349. /**
  107350. * Convert an angle in radians to degrees
  107351. * @param angle defines the angle to convert
  107352. * @returns the angle in degrees
  107353. */
  107354. static ToDegrees(angle: number): number;
  107355. /**
  107356. * Convert an angle in degrees to radians
  107357. * @param angle defines the angle to convert
  107358. * @returns the angle in radians
  107359. */
  107360. static ToRadians(angle: number): number;
  107361. /**
  107362. * Returns an array if obj is not an array
  107363. * @param obj defines the object to evaluate as an array
  107364. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107365. * @returns either obj directly if obj is an array or a new array containing obj
  107366. */
  107367. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107368. /**
  107369. * Gets the pointer prefix to use
  107370. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107371. */
  107372. static GetPointerPrefix(): string;
  107373. /**
  107374. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107375. * @param url define the url we are trying
  107376. * @param element define the dom element where to configure the cors policy
  107377. */
  107378. static SetCorsBehavior(url: string | string[], element: {
  107379. crossOrigin: string | null;
  107380. }): void;
  107381. /**
  107382. * Removes unwanted characters from an url
  107383. * @param url defines the url to clean
  107384. * @returns the cleaned url
  107385. */
  107386. static CleanUrl(url: string): string;
  107387. /**
  107388. * Gets or sets a function used to pre-process url before using them to load assets
  107389. */
  107390. static get PreprocessUrl(): (url: string) => string;
  107391. static set PreprocessUrl(processor: (url: string) => string);
  107392. /**
  107393. * Loads an image as an HTMLImageElement.
  107394. * @param input url string, ArrayBuffer, or Blob to load
  107395. * @param onLoad callback called when the image successfully loads
  107396. * @param onError callback called when the image fails to load
  107397. * @param offlineProvider offline provider for caching
  107398. * @param mimeType optional mime type
  107399. * @returns the HTMLImageElement of the loaded image
  107400. */
  107401. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107402. /**
  107403. * Loads a file from a url
  107404. * @param url url string, ArrayBuffer, or Blob to load
  107405. * @param onSuccess callback called when the file successfully loads
  107406. * @param onProgress callback called while file is loading (if the server supports this mode)
  107407. * @param offlineProvider defines the offline provider for caching
  107408. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107409. * @param onError callback called when the file fails to load
  107410. * @returns a file request object
  107411. */
  107412. 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;
  107413. /**
  107414. * Loads a file from a url
  107415. * @param url the file url to load
  107416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107417. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107418. */
  107419. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107420. /**
  107421. * Load a script (identified by an url). When the url returns, the
  107422. * content of this file is added into a new script element, attached to the DOM (body element)
  107423. * @param scriptUrl defines the url of the script to laod
  107424. * @param onSuccess defines the callback called when the script is loaded
  107425. * @param onError defines the callback to call if an error occurs
  107426. * @param scriptId defines the id of the script element
  107427. */
  107428. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107429. /**
  107430. * Load an asynchronous script (identified by an url). When the url returns, the
  107431. * content of this file is added into a new script element, attached to the DOM (body element)
  107432. * @param scriptUrl defines the url of the script to laod
  107433. * @param scriptId defines the id of the script element
  107434. * @returns a promise request object
  107435. */
  107436. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107437. /**
  107438. * Loads a file from a blob
  107439. * @param fileToLoad defines the blob to use
  107440. * @param callback defines the callback to call when data is loaded
  107441. * @param progressCallback defines the callback to call during loading process
  107442. * @returns a file request object
  107443. */
  107444. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107445. /**
  107446. * Reads a file from a File object
  107447. * @param file defines the file to load
  107448. * @param onSuccess defines the callback to call when data is loaded
  107449. * @param onProgress defines the callback to call during loading process
  107450. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107451. * @param onError defines the callback to call when an error occurs
  107452. * @returns a file request object
  107453. */
  107454. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107455. /**
  107456. * Creates a data url from a given string content
  107457. * @param content defines the content to convert
  107458. * @returns the new data url link
  107459. */
  107460. static FileAsURL(content: string): string;
  107461. /**
  107462. * Format the given number to a specific decimal format
  107463. * @param value defines the number to format
  107464. * @param decimals defines the number of decimals to use
  107465. * @returns the formatted string
  107466. */
  107467. static Format(value: number, decimals?: number): string;
  107468. /**
  107469. * Tries to copy an object by duplicating every property
  107470. * @param source defines the source object
  107471. * @param destination defines the target object
  107472. * @param doNotCopyList defines a list of properties to avoid
  107473. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107474. */
  107475. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107476. /**
  107477. * Gets a boolean indicating if the given object has no own property
  107478. * @param obj defines the object to test
  107479. * @returns true if object has no own property
  107480. */
  107481. static IsEmpty(obj: any): boolean;
  107482. /**
  107483. * Function used to register events at window level
  107484. * @param windowElement defines the Window object to use
  107485. * @param events defines the events to register
  107486. */
  107487. static RegisterTopRootEvents(windowElement: Window, events: {
  107488. name: string;
  107489. handler: Nullable<(e: FocusEvent) => any>;
  107490. }[]): void;
  107491. /**
  107492. * Function used to unregister events from window level
  107493. * @param windowElement defines the Window object to use
  107494. * @param events defines the events to unregister
  107495. */
  107496. static UnregisterTopRootEvents(windowElement: Window, events: {
  107497. name: string;
  107498. handler: Nullable<(e: FocusEvent) => any>;
  107499. }[]): void;
  107500. /**
  107501. * @ignore
  107502. */
  107503. static _ScreenshotCanvas: HTMLCanvasElement;
  107504. /**
  107505. * Dumps the current bound framebuffer
  107506. * @param width defines the rendering width
  107507. * @param height defines the rendering height
  107508. * @param engine defines the hosting engine
  107509. * @param successCallback defines the callback triggered once the data are available
  107510. * @param mimeType defines the mime type of the result
  107511. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107512. */
  107513. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107514. /**
  107515. * Converts the canvas data to blob.
  107516. * This acts as a polyfill for browsers not supporting the to blob function.
  107517. * @param canvas Defines the canvas to extract the data from
  107518. * @param successCallback Defines the callback triggered once the data are available
  107519. * @param mimeType Defines the mime type of the result
  107520. */
  107521. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107522. /**
  107523. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107524. * @param successCallback defines the callback triggered once the data are available
  107525. * @param mimeType defines the mime type of the result
  107526. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107527. */
  107528. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107529. /**
  107530. * Downloads a blob in the browser
  107531. * @param blob defines the blob to download
  107532. * @param fileName defines the name of the downloaded file
  107533. */
  107534. static Download(blob: Blob, fileName: string): void;
  107535. /**
  107536. * Captures a screenshot of the current rendering
  107537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107538. * @param engine defines the rendering engine
  107539. * @param camera defines the source camera
  107540. * @param size This parameter can be set to a single number or to an object with the
  107541. * following (optional) properties: precision, width, height. If a single number is passed,
  107542. * it will be used for both width and height. If an object is passed, the screenshot size
  107543. * will be derived from the parameters. The precision property is a multiplier allowing
  107544. * rendering at a higher or lower resolution
  107545. * @param successCallback defines the callback receives a single parameter which contains the
  107546. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107547. * src parameter of an <img> to display it
  107548. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107549. * Check your browser for supported MIME types
  107550. */
  107551. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107552. /**
  107553. * Captures a screenshot of the current rendering
  107554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107555. * @param engine defines the rendering engine
  107556. * @param camera defines the source camera
  107557. * @param size This parameter can be set to a single number or to an object with the
  107558. * following (optional) properties: precision, width, height. If a single number is passed,
  107559. * it will be used for both width and height. If an object is passed, the screenshot size
  107560. * will be derived from the parameters. The precision property is a multiplier allowing
  107561. * rendering at a higher or lower resolution
  107562. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107563. * Check your browser for supported MIME types
  107564. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107565. * to the src parameter of an <img> to display it
  107566. */
  107567. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107568. /**
  107569. * Generates an image screenshot from the specified camera.
  107570. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107571. * @param engine The engine to use for rendering
  107572. * @param camera The camera to use for rendering
  107573. * @param size This parameter can be set to a single number or to an object with the
  107574. * following (optional) properties: precision, width, height. If a single number is passed,
  107575. * it will be used for both width and height. If an object is passed, the screenshot size
  107576. * will be derived from the parameters. The precision property is a multiplier allowing
  107577. * rendering at a higher or lower resolution
  107578. * @param successCallback The callback receives a single parameter which contains the
  107579. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107580. * src parameter of an <img> to display it
  107581. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107582. * Check your browser for supported MIME types
  107583. * @param samples Texture samples (default: 1)
  107584. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107585. * @param fileName A name for for the downloaded file.
  107586. */
  107587. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107588. /**
  107589. * Generates an image screenshot from the specified camera.
  107590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107591. * @param engine The engine to use for rendering
  107592. * @param camera The camera to use for rendering
  107593. * @param size This parameter can be set to a single number or to an object with the
  107594. * following (optional) properties: precision, width, height. If a single number is passed,
  107595. * it will be used for both width and height. If an object is passed, the screenshot size
  107596. * will be derived from the parameters. The precision property is a multiplier allowing
  107597. * rendering at a higher or lower resolution
  107598. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107599. * Check your browser for supported MIME types
  107600. * @param samples Texture samples (default: 1)
  107601. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107602. * @param fileName A name for for the downloaded file.
  107603. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107604. * to the src parameter of an <img> to display it
  107605. */
  107606. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107607. /**
  107608. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107609. * Be aware Math.random() could cause collisions, but:
  107610. * "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"
  107611. * @returns a pseudo random id
  107612. */
  107613. static RandomId(): string;
  107614. /**
  107615. * Test if the given uri is a base64 string
  107616. * @param uri The uri to test
  107617. * @return True if the uri is a base64 string or false otherwise
  107618. */
  107619. static IsBase64(uri: string): boolean;
  107620. /**
  107621. * Decode the given base64 uri.
  107622. * @param uri The uri to decode
  107623. * @return The decoded base64 data.
  107624. */
  107625. static DecodeBase64(uri: string): ArrayBuffer;
  107626. /**
  107627. * Gets the absolute url.
  107628. * @param url the input url
  107629. * @return the absolute url
  107630. */
  107631. static GetAbsoluteUrl(url: string): string;
  107632. /**
  107633. * No log
  107634. */
  107635. static readonly NoneLogLevel: number;
  107636. /**
  107637. * Only message logs
  107638. */
  107639. static readonly MessageLogLevel: number;
  107640. /**
  107641. * Only warning logs
  107642. */
  107643. static readonly WarningLogLevel: number;
  107644. /**
  107645. * Only error logs
  107646. */
  107647. static readonly ErrorLogLevel: number;
  107648. /**
  107649. * All logs
  107650. */
  107651. static readonly AllLogLevel: number;
  107652. /**
  107653. * Gets a value indicating the number of loading errors
  107654. * @ignorenaming
  107655. */
  107656. static get errorsCount(): number;
  107657. /**
  107658. * Callback called when a new log is added
  107659. */
  107660. static OnNewCacheEntry: (entry: string) => void;
  107661. /**
  107662. * Log a message to the console
  107663. * @param message defines the message to log
  107664. */
  107665. static Log(message: string): void;
  107666. /**
  107667. * Write a warning message to the console
  107668. * @param message defines the message to log
  107669. */
  107670. static Warn(message: string): void;
  107671. /**
  107672. * Write an error message to the console
  107673. * @param message defines the message to log
  107674. */
  107675. static Error(message: string): void;
  107676. /**
  107677. * Gets current log cache (list of logs)
  107678. */
  107679. static get LogCache(): string;
  107680. /**
  107681. * Clears the log cache
  107682. */
  107683. static ClearLogCache(): void;
  107684. /**
  107685. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107686. */
  107687. static set LogLevels(level: number);
  107688. /**
  107689. * Checks if the window object exists
  107690. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107691. */
  107692. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107693. /**
  107694. * No performance log
  107695. */
  107696. static readonly PerformanceNoneLogLevel: number;
  107697. /**
  107698. * Use user marks to log performance
  107699. */
  107700. static readonly PerformanceUserMarkLogLevel: number;
  107701. /**
  107702. * Log performance to the console
  107703. */
  107704. static readonly PerformanceConsoleLogLevel: number;
  107705. private static _performance;
  107706. /**
  107707. * Sets the current performance log level
  107708. */
  107709. static set PerformanceLogLevel(level: number);
  107710. private static _StartPerformanceCounterDisabled;
  107711. private static _EndPerformanceCounterDisabled;
  107712. private static _StartUserMark;
  107713. private static _EndUserMark;
  107714. private static _StartPerformanceConsole;
  107715. private static _EndPerformanceConsole;
  107716. /**
  107717. * Starts a performance counter
  107718. */
  107719. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107720. /**
  107721. * Ends a specific performance coutner
  107722. */
  107723. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107724. /**
  107725. * Gets either window.performance.now() if supported or Date.now() else
  107726. */
  107727. static get Now(): number;
  107728. /**
  107729. * This method will return the name of the class used to create the instance of the given object.
  107730. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107731. * @param object the object to get the class name from
  107732. * @param isType defines if the object is actually a type
  107733. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107734. */
  107735. static GetClassName(object: any, isType?: boolean): string;
  107736. /**
  107737. * Gets the first element of an array satisfying a given predicate
  107738. * @param array defines the array to browse
  107739. * @param predicate defines the predicate to use
  107740. * @returns null if not found or the element
  107741. */
  107742. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107743. /**
  107744. * This method will return the name of the full name of the class, including its owning module (if any).
  107745. * 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).
  107746. * @param object the object to get the class name from
  107747. * @param isType defines if the object is actually a type
  107748. * @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.
  107749. * @ignorenaming
  107750. */
  107751. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107752. /**
  107753. * Returns a promise that resolves after the given amount of time.
  107754. * @param delay Number of milliseconds to delay
  107755. * @returns Promise that resolves after the given amount of time
  107756. */
  107757. static DelayAsync(delay: number): Promise<void>;
  107758. /**
  107759. * Utility function to detect if the current user agent is Safari
  107760. * @returns whether or not the current user agent is safari
  107761. */
  107762. static IsSafari(): boolean;
  107763. }
  107764. /**
  107765. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107766. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107767. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107768. * @param name The name of the class, case should be preserved
  107769. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107770. */
  107771. export function className(name: string, module?: string): (target: Object) => void;
  107772. /**
  107773. * An implementation of a loop for asynchronous functions.
  107774. */
  107775. export class AsyncLoop {
  107776. /**
  107777. * Defines the number of iterations for the loop
  107778. */
  107779. iterations: number;
  107780. /**
  107781. * Defines the current index of the loop.
  107782. */
  107783. index: number;
  107784. private _done;
  107785. private _fn;
  107786. private _successCallback;
  107787. /**
  107788. * Constructor.
  107789. * @param iterations the number of iterations.
  107790. * @param func the function to run each iteration
  107791. * @param successCallback the callback that will be called upon succesful execution
  107792. * @param offset starting offset.
  107793. */
  107794. constructor(
  107795. /**
  107796. * Defines the number of iterations for the loop
  107797. */
  107798. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107799. /**
  107800. * Execute the next iteration. Must be called after the last iteration was finished.
  107801. */
  107802. executeNext(): void;
  107803. /**
  107804. * Break the loop and run the success callback.
  107805. */
  107806. breakLoop(): void;
  107807. /**
  107808. * Create and run an async loop.
  107809. * @param iterations the number of iterations.
  107810. * @param fn the function to run each iteration
  107811. * @param successCallback the callback that will be called upon succesful execution
  107812. * @param offset starting offset.
  107813. * @returns the created async loop object
  107814. */
  107815. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107816. /**
  107817. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107818. * @param iterations total number of iterations
  107819. * @param syncedIterations number of synchronous iterations in each async iteration.
  107820. * @param fn the function to call each iteration.
  107821. * @param callback a success call back that will be called when iterating stops.
  107822. * @param breakFunction a break condition (optional)
  107823. * @param timeout timeout settings for the setTimeout function. default - 0.
  107824. * @returns the created async loop object
  107825. */
  107826. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107827. }
  107828. }
  107829. declare module BABYLON {
  107830. /**
  107831. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107832. * The underlying implementation relies on an associative array to ensure the best performances.
  107833. * The value can be anything including 'null' but except 'undefined'
  107834. */
  107835. export class StringDictionary<T> {
  107836. /**
  107837. * This will clear this dictionary and copy the content from the 'source' one.
  107838. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107839. * @param source the dictionary to take the content from and copy to this dictionary
  107840. */
  107841. copyFrom(source: StringDictionary<T>): void;
  107842. /**
  107843. * Get a value based from its key
  107844. * @param key the given key to get the matching value from
  107845. * @return the value if found, otherwise undefined is returned
  107846. */
  107847. get(key: string): T | undefined;
  107848. /**
  107849. * Get a value from its key or add it if it doesn't exist.
  107850. * This method will ensure you that a given key/data will be present in the dictionary.
  107851. * @param key the given key to get the matching value from
  107852. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107853. * The factory will only be invoked if there's no data for the given key.
  107854. * @return the value corresponding to the key.
  107855. */
  107856. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107857. /**
  107858. * Get a value from its key if present in the dictionary otherwise add it
  107859. * @param key the key to get the value from
  107860. * @param val if there's no such key/value pair in the dictionary add it with this value
  107861. * @return the value corresponding to the key
  107862. */
  107863. getOrAdd(key: string, val: T): T;
  107864. /**
  107865. * Check if there's a given key in the dictionary
  107866. * @param key the key to check for
  107867. * @return true if the key is present, false otherwise
  107868. */
  107869. contains(key: string): boolean;
  107870. /**
  107871. * Add a new key and its corresponding value
  107872. * @param key the key to add
  107873. * @param value the value corresponding to the key
  107874. * @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
  107875. */
  107876. add(key: string, value: T): boolean;
  107877. /**
  107878. * Update a specific value associated to a key
  107879. * @param key defines the key to use
  107880. * @param value defines the value to store
  107881. * @returns true if the value was updated (or false if the key was not found)
  107882. */
  107883. set(key: string, value: T): boolean;
  107884. /**
  107885. * Get the element of the given key and remove it from the dictionary
  107886. * @param key defines the key to search
  107887. * @returns the value associated with the key or null if not found
  107888. */
  107889. getAndRemove(key: string): Nullable<T>;
  107890. /**
  107891. * Remove a key/value from the dictionary.
  107892. * @param key the key to remove
  107893. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107894. */
  107895. remove(key: string): boolean;
  107896. /**
  107897. * Clear the whole content of the dictionary
  107898. */
  107899. clear(): void;
  107900. /**
  107901. * Gets the current count
  107902. */
  107903. get count(): number;
  107904. /**
  107905. * Execute a callback on each key/val of the dictionary.
  107906. * Note that you can remove any element in this dictionary in the callback implementation
  107907. * @param callback the callback to execute on a given key/value pair
  107908. */
  107909. forEach(callback: (key: string, val: T) => void): void;
  107910. /**
  107911. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107912. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107913. * Note that you can remove any element in this dictionary in the callback implementation
  107914. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107915. * @returns the first item
  107916. */
  107917. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107918. private _count;
  107919. private _data;
  107920. }
  107921. }
  107922. declare module BABYLON {
  107923. /** @hidden */
  107924. export interface ICollisionCoordinator {
  107925. createCollider(): Collider;
  107926. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107927. init(scene: Scene): void;
  107928. }
  107929. /** @hidden */
  107930. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107931. private _scene;
  107932. private _scaledPosition;
  107933. private _scaledVelocity;
  107934. private _finalPosition;
  107935. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107936. createCollider(): Collider;
  107937. init(scene: Scene): void;
  107938. private _collideWithWorld;
  107939. }
  107940. }
  107941. declare module BABYLON {
  107942. /**
  107943. * Class used to manage all inputs for the scene.
  107944. */
  107945. export class InputManager {
  107946. /** The distance in pixel that you have to move to prevent some events */
  107947. static DragMovementThreshold: number;
  107948. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107949. static LongPressDelay: number;
  107950. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107951. static DoubleClickDelay: number;
  107952. /** If you need to check double click without raising a single click at first click, enable this flag */
  107953. static ExclusiveDoubleClickMode: boolean;
  107954. private _wheelEventName;
  107955. private _onPointerMove;
  107956. private _onPointerDown;
  107957. private _onPointerUp;
  107958. private _initClickEvent;
  107959. private _initActionManager;
  107960. private _delayedSimpleClick;
  107961. private _delayedSimpleClickTimeout;
  107962. private _previousDelayedSimpleClickTimeout;
  107963. private _meshPickProceed;
  107964. private _previousButtonPressed;
  107965. private _currentPickResult;
  107966. private _previousPickResult;
  107967. private _totalPointersPressed;
  107968. private _doubleClickOccured;
  107969. private _pointerOverMesh;
  107970. private _pickedDownMesh;
  107971. private _pickedUpMesh;
  107972. private _pointerX;
  107973. private _pointerY;
  107974. private _unTranslatedPointerX;
  107975. private _unTranslatedPointerY;
  107976. private _startingPointerPosition;
  107977. private _previousStartingPointerPosition;
  107978. private _startingPointerTime;
  107979. private _previousStartingPointerTime;
  107980. private _pointerCaptures;
  107981. private _onKeyDown;
  107982. private _onKeyUp;
  107983. private _onCanvasFocusObserver;
  107984. private _onCanvasBlurObserver;
  107985. private _scene;
  107986. /**
  107987. * Creates a new InputManager
  107988. * @param scene defines the hosting scene
  107989. */
  107990. constructor(scene: Scene);
  107991. /**
  107992. * Gets the mesh that is currently under the pointer
  107993. */
  107994. get meshUnderPointer(): Nullable<AbstractMesh>;
  107995. /**
  107996. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107997. */
  107998. get unTranslatedPointer(): Vector2;
  107999. /**
  108000. * Gets or sets the current on-screen X position of the pointer
  108001. */
  108002. get pointerX(): number;
  108003. set pointerX(value: number);
  108004. /**
  108005. * Gets or sets the current on-screen Y position of the pointer
  108006. */
  108007. get pointerY(): number;
  108008. set pointerY(value: number);
  108009. private _updatePointerPosition;
  108010. private _processPointerMove;
  108011. private _setRayOnPointerInfo;
  108012. private _checkPrePointerObservable;
  108013. /**
  108014. * Use this method to simulate a pointer move on a mesh
  108015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108018. */
  108019. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108020. /**
  108021. * Use this method to simulate a pointer down on a mesh
  108022. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108023. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108024. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108025. */
  108026. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108027. private _processPointerDown;
  108028. /** @hidden */
  108029. _isPointerSwiping(): boolean;
  108030. /**
  108031. * Use this method to simulate a pointer up on a mesh
  108032. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108033. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108034. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108035. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108036. */
  108037. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108038. private _processPointerUp;
  108039. /**
  108040. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108041. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108042. * @returns true if the pointer was captured
  108043. */
  108044. isPointerCaptured(pointerId?: number): boolean;
  108045. /**
  108046. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108047. * @param attachUp defines if you want to attach events to pointerup
  108048. * @param attachDown defines if you want to attach events to pointerdown
  108049. * @param attachMove defines if you want to attach events to pointermove
  108050. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108051. */
  108052. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108053. /**
  108054. * Detaches all event handlers
  108055. */
  108056. detachControl(): void;
  108057. /**
  108058. * Force the value of meshUnderPointer
  108059. * @param mesh defines the mesh to use
  108060. */
  108061. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108062. /**
  108063. * Gets the mesh under the pointer
  108064. * @returns a Mesh or null if no mesh is under the pointer
  108065. */
  108066. getPointerOverMesh(): Nullable<AbstractMesh>;
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. /**
  108071. * Helper class used to generate session unique ID
  108072. */
  108073. export class UniqueIdGenerator {
  108074. private static _UniqueIdCounter;
  108075. /**
  108076. * Gets an unique (relatively to the current scene) Id
  108077. */
  108078. static get UniqueId(): number;
  108079. }
  108080. }
  108081. declare module BABYLON {
  108082. /**
  108083. * This class defines the direct association between an animation and a target
  108084. */
  108085. export class TargetedAnimation {
  108086. /**
  108087. * Animation to perform
  108088. */
  108089. animation: Animation;
  108090. /**
  108091. * Target to animate
  108092. */
  108093. target: any;
  108094. /**
  108095. * Serialize the object
  108096. * @returns the JSON object representing the current entity
  108097. */
  108098. serialize(): any;
  108099. }
  108100. /**
  108101. * Use this class to create coordinated animations on multiple targets
  108102. */
  108103. export class AnimationGroup implements IDisposable {
  108104. /** The name of the animation group */
  108105. name: string;
  108106. private _scene;
  108107. private _targetedAnimations;
  108108. private _animatables;
  108109. private _from;
  108110. private _to;
  108111. private _isStarted;
  108112. private _isPaused;
  108113. private _speedRatio;
  108114. private _loopAnimation;
  108115. /**
  108116. * Gets or sets the unique id of the node
  108117. */
  108118. uniqueId: number;
  108119. /**
  108120. * This observable will notify when one animation have ended
  108121. */
  108122. onAnimationEndObservable: Observable<TargetedAnimation>;
  108123. /**
  108124. * Observer raised when one animation loops
  108125. */
  108126. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108127. /**
  108128. * Observer raised when all animations have looped
  108129. */
  108130. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108131. /**
  108132. * This observable will notify when all animations have ended.
  108133. */
  108134. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108135. /**
  108136. * This observable will notify when all animations have paused.
  108137. */
  108138. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108139. /**
  108140. * This observable will notify when all animations are playing.
  108141. */
  108142. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108143. /**
  108144. * Gets the first frame
  108145. */
  108146. get from(): number;
  108147. /**
  108148. * Gets the last frame
  108149. */
  108150. get to(): number;
  108151. /**
  108152. * Define if the animations are started
  108153. */
  108154. get isStarted(): boolean;
  108155. /**
  108156. * Gets a value indicating that the current group is playing
  108157. */
  108158. get isPlaying(): boolean;
  108159. /**
  108160. * Gets or sets the speed ratio to use for all animations
  108161. */
  108162. get speedRatio(): number;
  108163. /**
  108164. * Gets or sets the speed ratio to use for all animations
  108165. */
  108166. set speedRatio(value: number);
  108167. /**
  108168. * Gets or sets if all animations should loop or not
  108169. */
  108170. get loopAnimation(): boolean;
  108171. set loopAnimation(value: boolean);
  108172. /**
  108173. * Gets the targeted animations for this animation group
  108174. */
  108175. get targetedAnimations(): Array<TargetedAnimation>;
  108176. /**
  108177. * returning the list of animatables controlled by this animation group.
  108178. */
  108179. get animatables(): Array<Animatable>;
  108180. /**
  108181. * Instantiates a new Animation Group.
  108182. * This helps managing several animations at once.
  108183. * @see http://doc.babylonjs.com/how_to/group
  108184. * @param name Defines the name of the group
  108185. * @param scene Defines the scene the group belongs to
  108186. */
  108187. constructor(
  108188. /** The name of the animation group */
  108189. name: string, scene?: Nullable<Scene>);
  108190. /**
  108191. * Add an animation (with its target) in the group
  108192. * @param animation defines the animation we want to add
  108193. * @param target defines the target of the animation
  108194. * @returns the TargetedAnimation object
  108195. */
  108196. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108197. /**
  108198. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108199. * It can add constant keys at begin or end
  108200. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108201. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108202. * @returns the animation group
  108203. */
  108204. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108205. private _animationLoopCount;
  108206. private _animationLoopFlags;
  108207. private _processLoop;
  108208. /**
  108209. * Start all animations on given targets
  108210. * @param loop defines if animations must loop
  108211. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108212. * @param from defines the from key (optional)
  108213. * @param to defines the to key (optional)
  108214. * @returns the current animation group
  108215. */
  108216. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108217. /**
  108218. * Pause all animations
  108219. * @returns the animation group
  108220. */
  108221. pause(): AnimationGroup;
  108222. /**
  108223. * Play all animations to initial state
  108224. * This function will start() the animations if they were not started or will restart() them if they were paused
  108225. * @param loop defines if animations must loop
  108226. * @returns the animation group
  108227. */
  108228. play(loop?: boolean): AnimationGroup;
  108229. /**
  108230. * Reset all animations to initial state
  108231. * @returns the animation group
  108232. */
  108233. reset(): AnimationGroup;
  108234. /**
  108235. * Restart animations from key 0
  108236. * @returns the animation group
  108237. */
  108238. restart(): AnimationGroup;
  108239. /**
  108240. * Stop all animations
  108241. * @returns the animation group
  108242. */
  108243. stop(): AnimationGroup;
  108244. /**
  108245. * Set animation weight for all animatables
  108246. * @param weight defines the weight to use
  108247. * @return the animationGroup
  108248. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108249. */
  108250. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108251. /**
  108252. * Synchronize and normalize all animatables with a source animatable
  108253. * @param root defines the root animatable to synchronize with
  108254. * @return the animationGroup
  108255. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108256. */
  108257. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108258. /**
  108259. * Goes to a specific frame in this animation group
  108260. * @param frame the frame number to go to
  108261. * @return the animationGroup
  108262. */
  108263. goToFrame(frame: number): AnimationGroup;
  108264. /**
  108265. * Dispose all associated resources
  108266. */
  108267. dispose(): void;
  108268. private _checkAnimationGroupEnded;
  108269. /**
  108270. * Clone the current animation group and returns a copy
  108271. * @param newName defines the name of the new group
  108272. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108273. * @returns the new aniamtion group
  108274. */
  108275. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108276. /**
  108277. * Serializes the animationGroup to an object
  108278. * @returns Serialized object
  108279. */
  108280. serialize(): any;
  108281. /**
  108282. * Returns a new AnimationGroup object parsed from the source provided.
  108283. * @param parsedAnimationGroup defines the source
  108284. * @param scene defines the scene that will receive the animationGroup
  108285. * @returns a new AnimationGroup
  108286. */
  108287. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108288. /**
  108289. * Returns the string "AnimationGroup"
  108290. * @returns "AnimationGroup"
  108291. */
  108292. getClassName(): string;
  108293. /**
  108294. * Creates a detailled string about the object
  108295. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108296. * @returns a string representing the object
  108297. */
  108298. toString(fullDetails?: boolean): string;
  108299. }
  108300. }
  108301. declare module BABYLON {
  108302. /**
  108303. * Define an interface for all classes that will hold resources
  108304. */
  108305. export interface IDisposable {
  108306. /**
  108307. * Releases all held resources
  108308. */
  108309. dispose(): void;
  108310. }
  108311. /** Interface defining initialization parameters for Scene class */
  108312. export interface SceneOptions {
  108313. /**
  108314. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108315. * It will improve performance when the number of geometries becomes important.
  108316. */
  108317. useGeometryUniqueIdsMap?: boolean;
  108318. /**
  108319. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108320. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108321. */
  108322. useMaterialMeshMap?: boolean;
  108323. /**
  108324. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108325. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108326. */
  108327. useClonedMeshMap?: boolean;
  108328. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108329. virtual?: boolean;
  108330. }
  108331. /**
  108332. * Represents a scene to be rendered by the engine.
  108333. * @see http://doc.babylonjs.com/features/scene
  108334. */
  108335. export class Scene extends AbstractScene implements IAnimatable {
  108336. /** The fog is deactivated */
  108337. static readonly FOGMODE_NONE: number;
  108338. /** The fog density is following an exponential function */
  108339. static readonly FOGMODE_EXP: number;
  108340. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108341. static readonly FOGMODE_EXP2: number;
  108342. /** The fog density is following a linear function. */
  108343. static readonly FOGMODE_LINEAR: number;
  108344. /**
  108345. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108346. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108347. */
  108348. static MinDeltaTime: number;
  108349. /**
  108350. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108352. */
  108353. static MaxDeltaTime: number;
  108354. /**
  108355. * Factory used to create the default material.
  108356. * @param name The name of the material to create
  108357. * @param scene The scene to create the material for
  108358. * @returns The default material
  108359. */
  108360. static DefaultMaterialFactory(scene: Scene): Material;
  108361. /**
  108362. * Factory used to create the a collision coordinator.
  108363. * @returns The collision coordinator
  108364. */
  108365. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108366. /** @hidden */
  108367. _inputManager: InputManager;
  108368. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108369. cameraToUseForPointers: Nullable<Camera>;
  108370. /** @hidden */
  108371. readonly _isScene: boolean;
  108372. /** @hidden */
  108373. _blockEntityCollection: boolean;
  108374. /**
  108375. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108376. */
  108377. autoClear: boolean;
  108378. /**
  108379. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108380. */
  108381. autoClearDepthAndStencil: boolean;
  108382. /**
  108383. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108384. */
  108385. clearColor: Color4;
  108386. /**
  108387. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108388. */
  108389. ambientColor: Color3;
  108390. /**
  108391. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108392. * It should only be one of the following (if not the default embedded one):
  108393. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108394. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108395. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108396. * The material properties need to be setup according to the type of texture in use.
  108397. */
  108398. environmentBRDFTexture: BaseTexture;
  108399. /** @hidden */
  108400. protected _environmentTexture: Nullable<BaseTexture>;
  108401. /**
  108402. * Texture used in all pbr material as the reflection texture.
  108403. * As in the majority of the scene they are the same (exception for multi room and so on),
  108404. * this is easier to reference from here than from all the materials.
  108405. */
  108406. get environmentTexture(): Nullable<BaseTexture>;
  108407. /**
  108408. * Texture used in all pbr material as the reflection texture.
  108409. * As in the majority of the scene they are the same (exception for multi room and so on),
  108410. * this is easier to set here than in all the materials.
  108411. */
  108412. set environmentTexture(value: Nullable<BaseTexture>);
  108413. /** @hidden */
  108414. protected _environmentIntensity: number;
  108415. /**
  108416. * Intensity of the environment in all pbr material.
  108417. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108418. * As in the majority of the scene they are the same (exception for multi room and so on),
  108419. * this is easier to reference from here than from all the materials.
  108420. */
  108421. get environmentIntensity(): number;
  108422. /**
  108423. * Intensity of the environment in all pbr material.
  108424. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108425. * As in the majority of the scene they are the same (exception for multi room and so on),
  108426. * this is easier to set here than in all the materials.
  108427. */
  108428. set environmentIntensity(value: number);
  108429. /** @hidden */
  108430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108431. /**
  108432. * Default image processing configuration used either in the rendering
  108433. * Forward main pass or through the imageProcessingPostProcess if present.
  108434. * As in the majority of the scene they are the same (exception for multi camera),
  108435. * this is easier to reference from here than from all the materials and post process.
  108436. *
  108437. * No setter as we it is a shared configuration, you can set the values instead.
  108438. */
  108439. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108440. private _forceWireframe;
  108441. /**
  108442. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108443. */
  108444. set forceWireframe(value: boolean);
  108445. get forceWireframe(): boolean;
  108446. private _skipFrustumClipping;
  108447. /**
  108448. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108449. */
  108450. set skipFrustumClipping(value: boolean);
  108451. get skipFrustumClipping(): boolean;
  108452. private _forcePointsCloud;
  108453. /**
  108454. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108455. */
  108456. set forcePointsCloud(value: boolean);
  108457. get forcePointsCloud(): boolean;
  108458. /**
  108459. * Gets or sets the active clipplane 1
  108460. */
  108461. clipPlane: Nullable<Plane>;
  108462. /**
  108463. * Gets or sets the active clipplane 2
  108464. */
  108465. clipPlane2: Nullable<Plane>;
  108466. /**
  108467. * Gets or sets the active clipplane 3
  108468. */
  108469. clipPlane3: Nullable<Plane>;
  108470. /**
  108471. * Gets or sets the active clipplane 4
  108472. */
  108473. clipPlane4: Nullable<Plane>;
  108474. /**
  108475. * Gets or sets the active clipplane 5
  108476. */
  108477. clipPlane5: Nullable<Plane>;
  108478. /**
  108479. * Gets or sets the active clipplane 6
  108480. */
  108481. clipPlane6: Nullable<Plane>;
  108482. /**
  108483. * Gets or sets a boolean indicating if animations are enabled
  108484. */
  108485. animationsEnabled: boolean;
  108486. private _animationPropertiesOverride;
  108487. /**
  108488. * Gets or sets the animation properties override
  108489. */
  108490. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108491. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108492. /**
  108493. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108494. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108495. */
  108496. useConstantAnimationDeltaTime: boolean;
  108497. /**
  108498. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108499. * Please note that it requires to run a ray cast through the scene on every frame
  108500. */
  108501. constantlyUpdateMeshUnderPointer: boolean;
  108502. /**
  108503. * Defines the HTML cursor to use when hovering over interactive elements
  108504. */
  108505. hoverCursor: string;
  108506. /**
  108507. * Defines the HTML default cursor to use (empty by default)
  108508. */
  108509. defaultCursor: string;
  108510. /**
  108511. * Defines whether cursors are handled by the scene.
  108512. */
  108513. doNotHandleCursors: boolean;
  108514. /**
  108515. * This is used to call preventDefault() on pointer down
  108516. * in order to block unwanted artifacts like system double clicks
  108517. */
  108518. preventDefaultOnPointerDown: boolean;
  108519. /**
  108520. * This is used to call preventDefault() on pointer up
  108521. * in order to block unwanted artifacts like system double clicks
  108522. */
  108523. preventDefaultOnPointerUp: boolean;
  108524. /**
  108525. * Gets or sets user defined metadata
  108526. */
  108527. metadata: any;
  108528. /**
  108529. * For internal use only. Please do not use.
  108530. */
  108531. reservedDataStore: any;
  108532. /**
  108533. * Gets the name of the plugin used to load this scene (null by default)
  108534. */
  108535. loadingPluginName: string;
  108536. /**
  108537. * Use this array to add regular expressions used to disable offline support for specific urls
  108538. */
  108539. disableOfflineSupportExceptionRules: RegExp[];
  108540. /**
  108541. * An event triggered when the scene is disposed.
  108542. */
  108543. onDisposeObservable: Observable<Scene>;
  108544. private _onDisposeObserver;
  108545. /** Sets a function to be executed when this scene is disposed. */
  108546. set onDispose(callback: () => void);
  108547. /**
  108548. * An event triggered before rendering the scene (right after animations and physics)
  108549. */
  108550. onBeforeRenderObservable: Observable<Scene>;
  108551. private _onBeforeRenderObserver;
  108552. /** Sets a function to be executed before rendering this scene */
  108553. set beforeRender(callback: Nullable<() => void>);
  108554. /**
  108555. * An event triggered after rendering the scene
  108556. */
  108557. onAfterRenderObservable: Observable<Scene>;
  108558. /**
  108559. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108560. */
  108561. onAfterRenderCameraObservable: Observable<Camera>;
  108562. private _onAfterRenderObserver;
  108563. /** Sets a function to be executed after rendering this scene */
  108564. set afterRender(callback: Nullable<() => void>);
  108565. /**
  108566. * An event triggered before animating the scene
  108567. */
  108568. onBeforeAnimationsObservable: Observable<Scene>;
  108569. /**
  108570. * An event triggered after animations processing
  108571. */
  108572. onAfterAnimationsObservable: Observable<Scene>;
  108573. /**
  108574. * An event triggered before draw calls are ready to be sent
  108575. */
  108576. onBeforeDrawPhaseObservable: Observable<Scene>;
  108577. /**
  108578. * An event triggered after draw calls have been sent
  108579. */
  108580. onAfterDrawPhaseObservable: Observable<Scene>;
  108581. /**
  108582. * An event triggered when the scene is ready
  108583. */
  108584. onReadyObservable: Observable<Scene>;
  108585. /**
  108586. * An event triggered before rendering a camera
  108587. */
  108588. onBeforeCameraRenderObservable: Observable<Camera>;
  108589. private _onBeforeCameraRenderObserver;
  108590. /** Sets a function to be executed before rendering a camera*/
  108591. set beforeCameraRender(callback: () => void);
  108592. /**
  108593. * An event triggered after rendering a camera
  108594. */
  108595. onAfterCameraRenderObservable: Observable<Camera>;
  108596. private _onAfterCameraRenderObserver;
  108597. /** Sets a function to be executed after rendering a camera*/
  108598. set afterCameraRender(callback: () => void);
  108599. /**
  108600. * An event triggered when active meshes evaluation is about to start
  108601. */
  108602. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108603. /**
  108604. * An event triggered when active meshes evaluation is done
  108605. */
  108606. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108607. /**
  108608. * An event triggered when particles rendering is about to start
  108609. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108610. */
  108611. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108612. /**
  108613. * An event triggered when particles rendering is done
  108614. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108615. */
  108616. onAfterParticlesRenderingObservable: Observable<Scene>;
  108617. /**
  108618. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108619. */
  108620. onDataLoadedObservable: Observable<Scene>;
  108621. /**
  108622. * An event triggered when a camera is created
  108623. */
  108624. onNewCameraAddedObservable: Observable<Camera>;
  108625. /**
  108626. * An event triggered when a camera is removed
  108627. */
  108628. onCameraRemovedObservable: Observable<Camera>;
  108629. /**
  108630. * An event triggered when a light is created
  108631. */
  108632. onNewLightAddedObservable: Observable<Light>;
  108633. /**
  108634. * An event triggered when a light is removed
  108635. */
  108636. onLightRemovedObservable: Observable<Light>;
  108637. /**
  108638. * An event triggered when a geometry is created
  108639. */
  108640. onNewGeometryAddedObservable: Observable<Geometry>;
  108641. /**
  108642. * An event triggered when a geometry is removed
  108643. */
  108644. onGeometryRemovedObservable: Observable<Geometry>;
  108645. /**
  108646. * An event triggered when a transform node is created
  108647. */
  108648. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108649. /**
  108650. * An event triggered when a transform node is removed
  108651. */
  108652. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108653. /**
  108654. * An event triggered when a mesh is created
  108655. */
  108656. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108657. /**
  108658. * An event triggered when a mesh is removed
  108659. */
  108660. onMeshRemovedObservable: Observable<AbstractMesh>;
  108661. /**
  108662. * An event triggered when a skeleton is created
  108663. */
  108664. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108665. /**
  108666. * An event triggered when a skeleton is removed
  108667. */
  108668. onSkeletonRemovedObservable: Observable<Skeleton>;
  108669. /**
  108670. * An event triggered when a material is created
  108671. */
  108672. onNewMaterialAddedObservable: Observable<Material>;
  108673. /**
  108674. * An event triggered when a material is removed
  108675. */
  108676. onMaterialRemovedObservable: Observable<Material>;
  108677. /**
  108678. * An event triggered when a texture is created
  108679. */
  108680. onNewTextureAddedObservable: Observable<BaseTexture>;
  108681. /**
  108682. * An event triggered when a texture is removed
  108683. */
  108684. onTextureRemovedObservable: Observable<BaseTexture>;
  108685. /**
  108686. * An event triggered when render targets are about to be rendered
  108687. * Can happen multiple times per frame.
  108688. */
  108689. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108690. /**
  108691. * An event triggered when render targets were rendered.
  108692. * Can happen multiple times per frame.
  108693. */
  108694. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108695. /**
  108696. * An event triggered before calculating deterministic simulation step
  108697. */
  108698. onBeforeStepObservable: Observable<Scene>;
  108699. /**
  108700. * An event triggered after calculating deterministic simulation step
  108701. */
  108702. onAfterStepObservable: Observable<Scene>;
  108703. /**
  108704. * An event triggered when the activeCamera property is updated
  108705. */
  108706. onActiveCameraChanged: Observable<Scene>;
  108707. /**
  108708. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108709. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108710. * 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)
  108711. */
  108712. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108713. /**
  108714. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108715. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108716. * 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)
  108717. */
  108718. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108719. /**
  108720. * This Observable will when a mesh has been imported into the scene.
  108721. */
  108722. onMeshImportedObservable: Observable<AbstractMesh>;
  108723. /**
  108724. * This Observable will when an animation file has been imported into the scene.
  108725. */
  108726. onAnimationFileImportedObservable: Observable<Scene>;
  108727. /**
  108728. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108729. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108730. */
  108731. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108732. /** @hidden */
  108733. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108734. /**
  108735. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108736. */
  108737. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108738. /**
  108739. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108740. */
  108741. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108742. /**
  108743. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108744. */
  108745. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108746. /** Callback called when a pointer move is detected */
  108747. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108748. /** Callback called when a pointer down is detected */
  108749. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108750. /** Callback called when a pointer up is detected */
  108751. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108752. /** Callback called when a pointer pick is detected */
  108753. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108754. /**
  108755. * 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).
  108756. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108757. */
  108758. onPrePointerObservable: Observable<PointerInfoPre>;
  108759. /**
  108760. * Observable event triggered each time an input event is received from the rendering canvas
  108761. */
  108762. onPointerObservable: Observable<PointerInfo>;
  108763. /**
  108764. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108765. */
  108766. get unTranslatedPointer(): Vector2;
  108767. /**
  108768. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108769. */
  108770. static get DragMovementThreshold(): number;
  108771. static set DragMovementThreshold(value: number);
  108772. /**
  108773. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108774. */
  108775. static get LongPressDelay(): number;
  108776. static set LongPressDelay(value: number);
  108777. /**
  108778. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108779. */
  108780. static get DoubleClickDelay(): number;
  108781. static set DoubleClickDelay(value: number);
  108782. /** If you need to check double click without raising a single click at first click, enable this flag */
  108783. static get ExclusiveDoubleClickMode(): boolean;
  108784. static set ExclusiveDoubleClickMode(value: boolean);
  108785. /** @hidden */
  108786. _mirroredCameraPosition: Nullable<Vector3>;
  108787. /**
  108788. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108789. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108790. */
  108791. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108792. /**
  108793. * Observable event triggered each time an keyboard event is received from the hosting window
  108794. */
  108795. onKeyboardObservable: Observable<KeyboardInfo>;
  108796. private _useRightHandedSystem;
  108797. /**
  108798. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108799. */
  108800. set useRightHandedSystem(value: boolean);
  108801. get useRightHandedSystem(): boolean;
  108802. private _timeAccumulator;
  108803. private _currentStepId;
  108804. private _currentInternalStep;
  108805. /**
  108806. * Sets the step Id used by deterministic lock step
  108807. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108808. * @param newStepId defines the step Id
  108809. */
  108810. setStepId(newStepId: number): void;
  108811. /**
  108812. * Gets the step Id used by deterministic lock step
  108813. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108814. * @returns the step Id
  108815. */
  108816. getStepId(): number;
  108817. /**
  108818. * Gets the internal step used by deterministic lock step
  108819. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108820. * @returns the internal step
  108821. */
  108822. getInternalStep(): number;
  108823. private _fogEnabled;
  108824. /**
  108825. * Gets or sets a boolean indicating if fog is enabled on this scene
  108826. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108827. * (Default is true)
  108828. */
  108829. set fogEnabled(value: boolean);
  108830. get fogEnabled(): boolean;
  108831. private _fogMode;
  108832. /**
  108833. * Gets or sets the fog mode to use
  108834. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108835. * | mode | value |
  108836. * | --- | --- |
  108837. * | FOGMODE_NONE | 0 |
  108838. * | FOGMODE_EXP | 1 |
  108839. * | FOGMODE_EXP2 | 2 |
  108840. * | FOGMODE_LINEAR | 3 |
  108841. */
  108842. set fogMode(value: number);
  108843. get fogMode(): number;
  108844. /**
  108845. * Gets or sets the fog color to use
  108846. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108847. * (Default is Color3(0.2, 0.2, 0.3))
  108848. */
  108849. fogColor: Color3;
  108850. /**
  108851. * Gets or sets the fog density to use
  108852. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108853. * (Default is 0.1)
  108854. */
  108855. fogDensity: number;
  108856. /**
  108857. * Gets or sets the fog start distance to use
  108858. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108859. * (Default is 0)
  108860. */
  108861. fogStart: number;
  108862. /**
  108863. * Gets or sets the fog end distance to use
  108864. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108865. * (Default is 1000)
  108866. */
  108867. fogEnd: number;
  108868. private _shadowsEnabled;
  108869. /**
  108870. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108871. */
  108872. set shadowsEnabled(value: boolean);
  108873. get shadowsEnabled(): boolean;
  108874. private _lightsEnabled;
  108875. /**
  108876. * Gets or sets a boolean indicating if lights are enabled on this scene
  108877. */
  108878. set lightsEnabled(value: boolean);
  108879. get lightsEnabled(): boolean;
  108880. /** All of the active cameras added to this scene. */
  108881. activeCameras: Camera[];
  108882. /** @hidden */
  108883. _activeCamera: Nullable<Camera>;
  108884. /** Gets or sets the current active camera */
  108885. get activeCamera(): Nullable<Camera>;
  108886. set activeCamera(value: Nullable<Camera>);
  108887. private _defaultMaterial;
  108888. /** The default material used on meshes when no material is affected */
  108889. get defaultMaterial(): Material;
  108890. /** The default material used on meshes when no material is affected */
  108891. set defaultMaterial(value: Material);
  108892. private _texturesEnabled;
  108893. /**
  108894. * Gets or sets a boolean indicating if textures are enabled on this scene
  108895. */
  108896. set texturesEnabled(value: boolean);
  108897. get texturesEnabled(): boolean;
  108898. /**
  108899. * Gets or sets a boolean indicating if particles are enabled on this scene
  108900. */
  108901. particlesEnabled: boolean;
  108902. /**
  108903. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108904. */
  108905. spritesEnabled: boolean;
  108906. private _skeletonsEnabled;
  108907. /**
  108908. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108909. */
  108910. set skeletonsEnabled(value: boolean);
  108911. get skeletonsEnabled(): boolean;
  108912. /**
  108913. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108914. */
  108915. lensFlaresEnabled: boolean;
  108916. /**
  108917. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108918. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108919. */
  108920. collisionsEnabled: boolean;
  108921. private _collisionCoordinator;
  108922. /** @hidden */
  108923. get collisionCoordinator(): ICollisionCoordinator;
  108924. /**
  108925. * Defines the gravity applied to this scene (used only for collisions)
  108926. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108927. */
  108928. gravity: Vector3;
  108929. /**
  108930. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108931. */
  108932. postProcessesEnabled: boolean;
  108933. /**
  108934. * The list of postprocesses added to the scene
  108935. */
  108936. postProcesses: PostProcess[];
  108937. /**
  108938. * Gets the current postprocess manager
  108939. */
  108940. postProcessManager: PostProcessManager;
  108941. /**
  108942. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108943. */
  108944. renderTargetsEnabled: boolean;
  108945. /**
  108946. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108947. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108948. */
  108949. dumpNextRenderTargets: boolean;
  108950. /**
  108951. * The list of user defined render targets added to the scene
  108952. */
  108953. customRenderTargets: RenderTargetTexture[];
  108954. /**
  108955. * Defines if texture loading must be delayed
  108956. * If true, textures will only be loaded when they need to be rendered
  108957. */
  108958. useDelayedTextureLoading: boolean;
  108959. /**
  108960. * Gets the list of meshes imported to the scene through SceneLoader
  108961. */
  108962. importedMeshesFiles: String[];
  108963. /**
  108964. * Gets or sets a boolean indicating if probes are enabled on this scene
  108965. */
  108966. probesEnabled: boolean;
  108967. /**
  108968. * Gets or sets the current offline provider to use to store scene data
  108969. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108970. */
  108971. offlineProvider: IOfflineProvider;
  108972. /**
  108973. * Gets or sets the action manager associated with the scene
  108974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108975. */
  108976. actionManager: AbstractActionManager;
  108977. private _meshesForIntersections;
  108978. /**
  108979. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108980. */
  108981. proceduralTexturesEnabled: boolean;
  108982. private _engine;
  108983. private _totalVertices;
  108984. /** @hidden */
  108985. _activeIndices: PerfCounter;
  108986. /** @hidden */
  108987. _activeParticles: PerfCounter;
  108988. /** @hidden */
  108989. _activeBones: PerfCounter;
  108990. private _animationRatio;
  108991. /** @hidden */
  108992. _animationTimeLast: number;
  108993. /** @hidden */
  108994. _animationTime: number;
  108995. /**
  108996. * Gets or sets a general scale for animation speed
  108997. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108998. */
  108999. animationTimeScale: number;
  109000. /** @hidden */
  109001. _cachedMaterial: Nullable<Material>;
  109002. /** @hidden */
  109003. _cachedEffect: Nullable<Effect>;
  109004. /** @hidden */
  109005. _cachedVisibility: Nullable<number>;
  109006. private _renderId;
  109007. private _frameId;
  109008. private _executeWhenReadyTimeoutId;
  109009. private _intermediateRendering;
  109010. private _viewUpdateFlag;
  109011. private _projectionUpdateFlag;
  109012. /** @hidden */
  109013. _toBeDisposed: Nullable<IDisposable>[];
  109014. private _activeRequests;
  109015. /** @hidden */
  109016. _pendingData: any[];
  109017. private _isDisposed;
  109018. /**
  109019. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109020. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109021. */
  109022. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109023. private _activeMeshes;
  109024. private _processedMaterials;
  109025. private _renderTargets;
  109026. /** @hidden */
  109027. _activeParticleSystems: SmartArray<IParticleSystem>;
  109028. private _activeSkeletons;
  109029. private _softwareSkinnedMeshes;
  109030. private _renderingManager;
  109031. /** @hidden */
  109032. _activeAnimatables: Animatable[];
  109033. private _transformMatrix;
  109034. private _sceneUbo;
  109035. /** @hidden */
  109036. _viewMatrix: Matrix;
  109037. private _projectionMatrix;
  109038. /** @hidden */
  109039. _forcedViewPosition: Nullable<Vector3>;
  109040. /** @hidden */
  109041. _frustumPlanes: Plane[];
  109042. /**
  109043. * Gets the list of frustum planes (built from the active camera)
  109044. */
  109045. get frustumPlanes(): Plane[];
  109046. /**
  109047. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109048. * This is useful if there are more lights that the maximum simulteanous authorized
  109049. */
  109050. requireLightSorting: boolean;
  109051. /** @hidden */
  109052. readonly useMaterialMeshMap: boolean;
  109053. /** @hidden */
  109054. readonly useClonedMeshMap: boolean;
  109055. private _externalData;
  109056. private _uid;
  109057. /**
  109058. * @hidden
  109059. * Backing store of defined scene components.
  109060. */
  109061. _components: ISceneComponent[];
  109062. /**
  109063. * @hidden
  109064. * Backing store of defined scene components.
  109065. */
  109066. _serializableComponents: ISceneSerializableComponent[];
  109067. /**
  109068. * List of components to register on the next registration step.
  109069. */
  109070. private _transientComponents;
  109071. /**
  109072. * Registers the transient components if needed.
  109073. */
  109074. private _registerTransientComponents;
  109075. /**
  109076. * @hidden
  109077. * Add a component to the scene.
  109078. * Note that the ccomponent could be registered on th next frame if this is called after
  109079. * the register component stage.
  109080. * @param component Defines the component to add to the scene
  109081. */
  109082. _addComponent(component: ISceneComponent): void;
  109083. /**
  109084. * @hidden
  109085. * Gets a component from the scene.
  109086. * @param name defines the name of the component to retrieve
  109087. * @returns the component or null if not present
  109088. */
  109089. _getComponent(name: string): Nullable<ISceneComponent>;
  109090. /**
  109091. * @hidden
  109092. * Defines the actions happening before camera updates.
  109093. */
  109094. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109095. /**
  109096. * @hidden
  109097. * Defines the actions happening before clear the canvas.
  109098. */
  109099. _beforeClearStage: Stage<SimpleStageAction>;
  109100. /**
  109101. * @hidden
  109102. * Defines the actions when collecting render targets for the frame.
  109103. */
  109104. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109105. /**
  109106. * @hidden
  109107. * Defines the actions happening for one camera in the frame.
  109108. */
  109109. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109110. /**
  109111. * @hidden
  109112. * Defines the actions happening during the per mesh ready checks.
  109113. */
  109114. _isReadyForMeshStage: Stage<MeshStageAction>;
  109115. /**
  109116. * @hidden
  109117. * Defines the actions happening before evaluate active mesh checks.
  109118. */
  109119. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109120. /**
  109121. * @hidden
  109122. * Defines the actions happening during the evaluate sub mesh checks.
  109123. */
  109124. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109125. /**
  109126. * @hidden
  109127. * Defines the actions happening during the active mesh stage.
  109128. */
  109129. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109130. /**
  109131. * @hidden
  109132. * Defines the actions happening during the per camera render target step.
  109133. */
  109134. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109135. /**
  109136. * @hidden
  109137. * Defines the actions happening just before the active camera is drawing.
  109138. */
  109139. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109140. /**
  109141. * @hidden
  109142. * Defines the actions happening just before a render target is drawing.
  109143. */
  109144. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109145. /**
  109146. * @hidden
  109147. * Defines the actions happening just before a rendering group is drawing.
  109148. */
  109149. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109150. /**
  109151. * @hidden
  109152. * Defines the actions happening just before a mesh is drawing.
  109153. */
  109154. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109155. /**
  109156. * @hidden
  109157. * Defines the actions happening just after a mesh has been drawn.
  109158. */
  109159. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109160. /**
  109161. * @hidden
  109162. * Defines the actions happening just after a rendering group has been drawn.
  109163. */
  109164. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109165. /**
  109166. * @hidden
  109167. * Defines the actions happening just after the active camera has been drawn.
  109168. */
  109169. _afterCameraDrawStage: Stage<CameraStageAction>;
  109170. /**
  109171. * @hidden
  109172. * Defines the actions happening just after a render target has been drawn.
  109173. */
  109174. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109175. /**
  109176. * @hidden
  109177. * Defines the actions happening just after rendering all cameras and computing intersections.
  109178. */
  109179. _afterRenderStage: Stage<SimpleStageAction>;
  109180. /**
  109181. * @hidden
  109182. * Defines the actions happening when a pointer move event happens.
  109183. */
  109184. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109185. /**
  109186. * @hidden
  109187. * Defines the actions happening when a pointer down event happens.
  109188. */
  109189. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109190. /**
  109191. * @hidden
  109192. * Defines the actions happening when a pointer up event happens.
  109193. */
  109194. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109195. /**
  109196. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109197. */
  109198. private geometriesByUniqueId;
  109199. /**
  109200. * Creates a new Scene
  109201. * @param engine defines the engine to use to render this scene
  109202. * @param options defines the scene options
  109203. */
  109204. constructor(engine: Engine, options?: SceneOptions);
  109205. /**
  109206. * Gets a string idenfifying the name of the class
  109207. * @returns "Scene" string
  109208. */
  109209. getClassName(): string;
  109210. private _defaultMeshCandidates;
  109211. /**
  109212. * @hidden
  109213. */
  109214. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109215. private _defaultSubMeshCandidates;
  109216. /**
  109217. * @hidden
  109218. */
  109219. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109220. /**
  109221. * Sets the default candidate providers for the scene.
  109222. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109223. * and getCollidingSubMeshCandidates to their default function
  109224. */
  109225. setDefaultCandidateProviders(): void;
  109226. /**
  109227. * Gets the mesh that is currently under the pointer
  109228. */
  109229. get meshUnderPointer(): Nullable<AbstractMesh>;
  109230. /**
  109231. * Gets or sets the current on-screen X position of the pointer
  109232. */
  109233. get pointerX(): number;
  109234. set pointerX(value: number);
  109235. /**
  109236. * Gets or sets the current on-screen Y position of the pointer
  109237. */
  109238. get pointerY(): number;
  109239. set pointerY(value: number);
  109240. /**
  109241. * Gets the cached material (ie. the latest rendered one)
  109242. * @returns the cached material
  109243. */
  109244. getCachedMaterial(): Nullable<Material>;
  109245. /**
  109246. * Gets the cached effect (ie. the latest rendered one)
  109247. * @returns the cached effect
  109248. */
  109249. getCachedEffect(): Nullable<Effect>;
  109250. /**
  109251. * Gets the cached visibility state (ie. the latest rendered one)
  109252. * @returns the cached visibility state
  109253. */
  109254. getCachedVisibility(): Nullable<number>;
  109255. /**
  109256. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109257. * @param material defines the current material
  109258. * @param effect defines the current effect
  109259. * @param visibility defines the current visibility state
  109260. * @returns true if one parameter is not cached
  109261. */
  109262. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109263. /**
  109264. * Gets the engine associated with the scene
  109265. * @returns an Engine
  109266. */
  109267. getEngine(): Engine;
  109268. /**
  109269. * Gets the total number of vertices rendered per frame
  109270. * @returns the total number of vertices rendered per frame
  109271. */
  109272. getTotalVertices(): number;
  109273. /**
  109274. * Gets the performance counter for total vertices
  109275. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109276. */
  109277. get totalVerticesPerfCounter(): PerfCounter;
  109278. /**
  109279. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109280. * @returns the total number of active indices rendered per frame
  109281. */
  109282. getActiveIndices(): number;
  109283. /**
  109284. * Gets the performance counter for active indices
  109285. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109286. */
  109287. get totalActiveIndicesPerfCounter(): PerfCounter;
  109288. /**
  109289. * Gets the total number of active particles rendered per frame
  109290. * @returns the total number of active particles rendered per frame
  109291. */
  109292. getActiveParticles(): number;
  109293. /**
  109294. * Gets the performance counter for active particles
  109295. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109296. */
  109297. get activeParticlesPerfCounter(): PerfCounter;
  109298. /**
  109299. * Gets the total number of active bones rendered per frame
  109300. * @returns the total number of active bones rendered per frame
  109301. */
  109302. getActiveBones(): number;
  109303. /**
  109304. * Gets the performance counter for active bones
  109305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109306. */
  109307. get activeBonesPerfCounter(): PerfCounter;
  109308. /**
  109309. * Gets the array of active meshes
  109310. * @returns an array of AbstractMesh
  109311. */
  109312. getActiveMeshes(): SmartArray<AbstractMesh>;
  109313. /**
  109314. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109315. * @returns a number
  109316. */
  109317. getAnimationRatio(): number;
  109318. /**
  109319. * Gets an unique Id for the current render phase
  109320. * @returns a number
  109321. */
  109322. getRenderId(): number;
  109323. /**
  109324. * Gets an unique Id for the current frame
  109325. * @returns a number
  109326. */
  109327. getFrameId(): number;
  109328. /** Call this function if you want to manually increment the render Id*/
  109329. incrementRenderId(): void;
  109330. private _createUbo;
  109331. /**
  109332. * Use this method to simulate a pointer move on a mesh
  109333. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109334. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109335. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109336. * @returns the current scene
  109337. */
  109338. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109339. /**
  109340. * Use this method to simulate a pointer down on a mesh
  109341. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109342. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109343. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109344. * @returns the current scene
  109345. */
  109346. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109347. /**
  109348. * Use this method to simulate a pointer up on a mesh
  109349. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109350. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109351. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109352. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109353. * @returns the current scene
  109354. */
  109355. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109356. /**
  109357. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109358. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109359. * @returns true if the pointer was captured
  109360. */
  109361. isPointerCaptured(pointerId?: number): boolean;
  109362. /**
  109363. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109364. * @param attachUp defines if you want to attach events to pointerup
  109365. * @param attachDown defines if you want to attach events to pointerdown
  109366. * @param attachMove defines if you want to attach events to pointermove
  109367. */
  109368. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109369. /** Detaches all event handlers*/
  109370. detachControl(): void;
  109371. /**
  109372. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109373. * Delay loaded resources are not taking in account
  109374. * @return true if all required resources are ready
  109375. */
  109376. isReady(): boolean;
  109377. /** Resets all cached information relative to material (including effect and visibility) */
  109378. resetCachedMaterial(): void;
  109379. /**
  109380. * Registers a function to be called before every frame render
  109381. * @param func defines the function to register
  109382. */
  109383. registerBeforeRender(func: () => void): void;
  109384. /**
  109385. * Unregisters a function called before every frame render
  109386. * @param func defines the function to unregister
  109387. */
  109388. unregisterBeforeRender(func: () => void): void;
  109389. /**
  109390. * Registers a function to be called after every frame render
  109391. * @param func defines the function to register
  109392. */
  109393. registerAfterRender(func: () => void): void;
  109394. /**
  109395. * Unregisters a function called after every frame render
  109396. * @param func defines the function to unregister
  109397. */
  109398. unregisterAfterRender(func: () => void): void;
  109399. private _executeOnceBeforeRender;
  109400. /**
  109401. * The provided function will run before render once and will be disposed afterwards.
  109402. * A timeout delay can be provided so that the function will be executed in N ms.
  109403. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109404. * @param func The function to be executed.
  109405. * @param timeout optional delay in ms
  109406. */
  109407. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109408. /** @hidden */
  109409. _addPendingData(data: any): void;
  109410. /** @hidden */
  109411. _removePendingData(data: any): void;
  109412. /**
  109413. * Returns the number of items waiting to be loaded
  109414. * @returns the number of items waiting to be loaded
  109415. */
  109416. getWaitingItemsCount(): number;
  109417. /**
  109418. * Returns a boolean indicating if the scene is still loading data
  109419. */
  109420. get isLoading(): boolean;
  109421. /**
  109422. * Registers a function to be executed when the scene is ready
  109423. * @param {Function} func - the function to be executed
  109424. */
  109425. executeWhenReady(func: () => void): void;
  109426. /**
  109427. * Returns a promise that resolves when the scene is ready
  109428. * @returns A promise that resolves when the scene is ready
  109429. */
  109430. whenReadyAsync(): Promise<void>;
  109431. /** @hidden */
  109432. _checkIsReady(): void;
  109433. /**
  109434. * Gets all animatable attached to the scene
  109435. */
  109436. get animatables(): Animatable[];
  109437. /**
  109438. * Resets the last animation time frame.
  109439. * Useful to override when animations start running when loading a scene for the first time.
  109440. */
  109441. resetLastAnimationTimeFrame(): void;
  109442. /**
  109443. * Gets the current view matrix
  109444. * @returns a Matrix
  109445. */
  109446. getViewMatrix(): Matrix;
  109447. /**
  109448. * Gets the current projection matrix
  109449. * @returns a Matrix
  109450. */
  109451. getProjectionMatrix(): Matrix;
  109452. /**
  109453. * Gets the current transform matrix
  109454. * @returns a Matrix made of View * Projection
  109455. */
  109456. getTransformMatrix(): Matrix;
  109457. /**
  109458. * Sets the current transform matrix
  109459. * @param viewL defines the View matrix to use
  109460. * @param projectionL defines the Projection matrix to use
  109461. * @param viewR defines the right View matrix to use (if provided)
  109462. * @param projectionR defines the right Projection matrix to use (if provided)
  109463. */
  109464. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109465. /**
  109466. * Gets the uniform buffer used to store scene data
  109467. * @returns a UniformBuffer
  109468. */
  109469. getSceneUniformBuffer(): UniformBuffer;
  109470. /**
  109471. * Gets an unique (relatively to the current scene) Id
  109472. * @returns an unique number for the scene
  109473. */
  109474. getUniqueId(): number;
  109475. /**
  109476. * Add a mesh to the list of scene's meshes
  109477. * @param newMesh defines the mesh to add
  109478. * @param recursive if all child meshes should also be added to the scene
  109479. */
  109480. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109481. /**
  109482. * Remove a mesh for the list of scene's meshes
  109483. * @param toRemove defines the mesh to remove
  109484. * @param recursive if all child meshes should also be removed from the scene
  109485. * @returns the index where the mesh was in the mesh list
  109486. */
  109487. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109488. /**
  109489. * Add a transform node to the list of scene's transform nodes
  109490. * @param newTransformNode defines the transform node to add
  109491. */
  109492. addTransformNode(newTransformNode: TransformNode): void;
  109493. /**
  109494. * Remove a transform node for the list of scene's transform nodes
  109495. * @param toRemove defines the transform node to remove
  109496. * @returns the index where the transform node was in the transform node list
  109497. */
  109498. removeTransformNode(toRemove: TransformNode): number;
  109499. /**
  109500. * Remove a skeleton for the list of scene's skeletons
  109501. * @param toRemove defines the skeleton to remove
  109502. * @returns the index where the skeleton was in the skeleton list
  109503. */
  109504. removeSkeleton(toRemove: Skeleton): number;
  109505. /**
  109506. * Remove a morph target for the list of scene's morph targets
  109507. * @param toRemove defines the morph target to remove
  109508. * @returns the index where the morph target was in the morph target list
  109509. */
  109510. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109511. /**
  109512. * Remove a light for the list of scene's lights
  109513. * @param toRemove defines the light to remove
  109514. * @returns the index where the light was in the light list
  109515. */
  109516. removeLight(toRemove: Light): number;
  109517. /**
  109518. * Remove a camera for the list of scene's cameras
  109519. * @param toRemove defines the camera to remove
  109520. * @returns the index where the camera was in the camera list
  109521. */
  109522. removeCamera(toRemove: Camera): number;
  109523. /**
  109524. * Remove a particle system for the list of scene's particle systems
  109525. * @param toRemove defines the particle system to remove
  109526. * @returns the index where the particle system was in the particle system list
  109527. */
  109528. removeParticleSystem(toRemove: IParticleSystem): number;
  109529. /**
  109530. * Remove a animation for the list of scene's animations
  109531. * @param toRemove defines the animation to remove
  109532. * @returns the index where the animation was in the animation list
  109533. */
  109534. removeAnimation(toRemove: Animation): number;
  109535. /**
  109536. * Will stop the animation of the given target
  109537. * @param target - the target
  109538. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109539. * @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)
  109540. */
  109541. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109542. /**
  109543. * Removes the given animation group from this scene.
  109544. * @param toRemove The animation group to remove
  109545. * @returns The index of the removed animation group
  109546. */
  109547. removeAnimationGroup(toRemove: AnimationGroup): number;
  109548. /**
  109549. * Removes the given multi-material from this scene.
  109550. * @param toRemove The multi-material to remove
  109551. * @returns The index of the removed multi-material
  109552. */
  109553. removeMultiMaterial(toRemove: MultiMaterial): number;
  109554. /**
  109555. * Removes the given material from this scene.
  109556. * @param toRemove The material to remove
  109557. * @returns The index of the removed material
  109558. */
  109559. removeMaterial(toRemove: Material): number;
  109560. /**
  109561. * Removes the given action manager from this scene.
  109562. * @param toRemove The action manager to remove
  109563. * @returns The index of the removed action manager
  109564. */
  109565. removeActionManager(toRemove: AbstractActionManager): number;
  109566. /**
  109567. * Removes the given texture from this scene.
  109568. * @param toRemove The texture to remove
  109569. * @returns The index of the removed texture
  109570. */
  109571. removeTexture(toRemove: BaseTexture): number;
  109572. /**
  109573. * Adds the given light to this scene
  109574. * @param newLight The light to add
  109575. */
  109576. addLight(newLight: Light): void;
  109577. /**
  109578. * Sorts the list list based on light priorities
  109579. */
  109580. sortLightsByPriority(): void;
  109581. /**
  109582. * Adds the given camera to this scene
  109583. * @param newCamera The camera to add
  109584. */
  109585. addCamera(newCamera: Camera): void;
  109586. /**
  109587. * Adds the given skeleton to this scene
  109588. * @param newSkeleton The skeleton to add
  109589. */
  109590. addSkeleton(newSkeleton: Skeleton): void;
  109591. /**
  109592. * Adds the given particle system to this scene
  109593. * @param newParticleSystem The particle system to add
  109594. */
  109595. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109596. /**
  109597. * Adds the given animation to this scene
  109598. * @param newAnimation The animation to add
  109599. */
  109600. addAnimation(newAnimation: Animation): void;
  109601. /**
  109602. * Adds the given animation group to this scene.
  109603. * @param newAnimationGroup The animation group to add
  109604. */
  109605. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109606. /**
  109607. * Adds the given multi-material to this scene
  109608. * @param newMultiMaterial The multi-material to add
  109609. */
  109610. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109611. /**
  109612. * Adds the given material to this scene
  109613. * @param newMaterial The material to add
  109614. */
  109615. addMaterial(newMaterial: Material): void;
  109616. /**
  109617. * Adds the given morph target to this scene
  109618. * @param newMorphTargetManager The morph target to add
  109619. */
  109620. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109621. /**
  109622. * Adds the given geometry to this scene
  109623. * @param newGeometry The geometry to add
  109624. */
  109625. addGeometry(newGeometry: Geometry): void;
  109626. /**
  109627. * Adds the given action manager to this scene
  109628. * @param newActionManager The action manager to add
  109629. */
  109630. addActionManager(newActionManager: AbstractActionManager): void;
  109631. /**
  109632. * Adds the given texture to this scene.
  109633. * @param newTexture The texture to add
  109634. */
  109635. addTexture(newTexture: BaseTexture): void;
  109636. /**
  109637. * Switch active camera
  109638. * @param newCamera defines the new active camera
  109639. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109640. */
  109641. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109642. /**
  109643. * sets the active camera of the scene using its ID
  109644. * @param id defines the camera's ID
  109645. * @return the new active camera or null if none found.
  109646. */
  109647. setActiveCameraByID(id: string): Nullable<Camera>;
  109648. /**
  109649. * sets the active camera of the scene using its name
  109650. * @param name defines the camera's name
  109651. * @returns the new active camera or null if none found.
  109652. */
  109653. setActiveCameraByName(name: string): Nullable<Camera>;
  109654. /**
  109655. * get an animation group using its name
  109656. * @param name defines the material's name
  109657. * @return the animation group or null if none found.
  109658. */
  109659. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109660. /**
  109661. * Get a material using its unique id
  109662. * @param uniqueId defines the material's unique id
  109663. * @return the material or null if none found.
  109664. */
  109665. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109666. /**
  109667. * get a material using its id
  109668. * @param id defines the material's ID
  109669. * @return the material or null if none found.
  109670. */
  109671. getMaterialByID(id: string): Nullable<Material>;
  109672. /**
  109673. * Gets a the last added material using a given id
  109674. * @param id defines the material's ID
  109675. * @return the last material with the given id or null if none found.
  109676. */
  109677. getLastMaterialByID(id: string): Nullable<Material>;
  109678. /**
  109679. * Gets a material using its name
  109680. * @param name defines the material's name
  109681. * @return the material or null if none found.
  109682. */
  109683. getMaterialByName(name: string): Nullable<Material>;
  109684. /**
  109685. * Get a texture using its unique id
  109686. * @param uniqueId defines the texture's unique id
  109687. * @return the texture or null if none found.
  109688. */
  109689. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109690. /**
  109691. * Gets a camera using its id
  109692. * @param id defines the id to look for
  109693. * @returns the camera or null if not found
  109694. */
  109695. getCameraByID(id: string): Nullable<Camera>;
  109696. /**
  109697. * Gets a camera using its unique id
  109698. * @param uniqueId defines the unique id to look for
  109699. * @returns the camera or null if not found
  109700. */
  109701. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109702. /**
  109703. * Gets a camera using its name
  109704. * @param name defines the camera's name
  109705. * @return the camera or null if none found.
  109706. */
  109707. getCameraByName(name: string): Nullable<Camera>;
  109708. /**
  109709. * Gets a bone using its id
  109710. * @param id defines the bone's id
  109711. * @return the bone or null if not found
  109712. */
  109713. getBoneByID(id: string): Nullable<Bone>;
  109714. /**
  109715. * Gets a bone using its id
  109716. * @param name defines the bone's name
  109717. * @return the bone or null if not found
  109718. */
  109719. getBoneByName(name: string): Nullable<Bone>;
  109720. /**
  109721. * Gets a light node using its name
  109722. * @param name defines the the light's name
  109723. * @return the light or null if none found.
  109724. */
  109725. getLightByName(name: string): Nullable<Light>;
  109726. /**
  109727. * Gets a light node using its id
  109728. * @param id defines the light's id
  109729. * @return the light or null if none found.
  109730. */
  109731. getLightByID(id: string): Nullable<Light>;
  109732. /**
  109733. * Gets a light node using its scene-generated unique ID
  109734. * @param uniqueId defines the light's unique id
  109735. * @return the light or null if none found.
  109736. */
  109737. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109738. /**
  109739. * Gets a particle system by id
  109740. * @param id defines the particle system id
  109741. * @return the corresponding system or null if none found
  109742. */
  109743. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109744. /**
  109745. * Gets a geometry using its ID
  109746. * @param id defines the geometry's id
  109747. * @return the geometry or null if none found.
  109748. */
  109749. getGeometryByID(id: string): Nullable<Geometry>;
  109750. private _getGeometryByUniqueID;
  109751. /**
  109752. * Add a new geometry to this scene
  109753. * @param geometry defines the geometry to be added to the scene.
  109754. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109755. * @return a boolean defining if the geometry was added or not
  109756. */
  109757. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109758. /**
  109759. * Removes an existing geometry
  109760. * @param geometry defines the geometry to be removed from the scene
  109761. * @return a boolean defining if the geometry was removed or not
  109762. */
  109763. removeGeometry(geometry: Geometry): boolean;
  109764. /**
  109765. * Gets the list of geometries attached to the scene
  109766. * @returns an array of Geometry
  109767. */
  109768. getGeometries(): Geometry[];
  109769. /**
  109770. * Gets the first added mesh found of a given ID
  109771. * @param id defines the id to search for
  109772. * @return the mesh found or null if not found at all
  109773. */
  109774. getMeshByID(id: string): Nullable<AbstractMesh>;
  109775. /**
  109776. * Gets a list of meshes using their id
  109777. * @param id defines the id to search for
  109778. * @returns a list of meshes
  109779. */
  109780. getMeshesByID(id: string): Array<AbstractMesh>;
  109781. /**
  109782. * Gets the first added transform node found of a given ID
  109783. * @param id defines the id to search for
  109784. * @return the found transform node or null if not found at all.
  109785. */
  109786. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109787. /**
  109788. * Gets a transform node with its auto-generated unique id
  109789. * @param uniqueId efines the unique id to search for
  109790. * @return the found transform node or null if not found at all.
  109791. */
  109792. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109793. /**
  109794. * Gets a list of transform nodes using their id
  109795. * @param id defines the id to search for
  109796. * @returns a list of transform nodes
  109797. */
  109798. getTransformNodesByID(id: string): Array<TransformNode>;
  109799. /**
  109800. * Gets a mesh with its auto-generated unique id
  109801. * @param uniqueId defines the unique id to search for
  109802. * @return the found mesh or null if not found at all.
  109803. */
  109804. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109805. /**
  109806. * Gets a the last added mesh using a given id
  109807. * @param id defines the id to search for
  109808. * @return the found mesh or null if not found at all.
  109809. */
  109810. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109811. /**
  109812. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109813. * @param id defines the id to search for
  109814. * @return the found node or null if not found at all
  109815. */
  109816. getLastEntryByID(id: string): Nullable<Node>;
  109817. /**
  109818. * Gets a node (Mesh, Camera, Light) using a given id
  109819. * @param id defines the id to search for
  109820. * @return the found node or null if not found at all
  109821. */
  109822. getNodeByID(id: string): Nullable<Node>;
  109823. /**
  109824. * Gets a node (Mesh, Camera, Light) using a given name
  109825. * @param name defines the name to search for
  109826. * @return the found node or null if not found at all.
  109827. */
  109828. getNodeByName(name: string): Nullable<Node>;
  109829. /**
  109830. * Gets a mesh using a given name
  109831. * @param name defines the name to search for
  109832. * @return the found mesh or null if not found at all.
  109833. */
  109834. getMeshByName(name: string): Nullable<AbstractMesh>;
  109835. /**
  109836. * Gets a transform node using a given name
  109837. * @param name defines the name to search for
  109838. * @return the found transform node or null if not found at all.
  109839. */
  109840. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109841. /**
  109842. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109843. * @param id defines the id to search for
  109844. * @return the found skeleton or null if not found at all.
  109845. */
  109846. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109847. /**
  109848. * Gets a skeleton using a given auto generated unique id
  109849. * @param uniqueId defines the unique id to search for
  109850. * @return the found skeleton or null if not found at all.
  109851. */
  109852. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109853. /**
  109854. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109855. * @param id defines the id to search for
  109856. * @return the found skeleton or null if not found at all.
  109857. */
  109858. getSkeletonById(id: string): Nullable<Skeleton>;
  109859. /**
  109860. * Gets a skeleton using a given name
  109861. * @param name defines the name to search for
  109862. * @return the found skeleton or null if not found at all.
  109863. */
  109864. getSkeletonByName(name: string): Nullable<Skeleton>;
  109865. /**
  109866. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109867. * @param id defines the id to search for
  109868. * @return the found morph target manager or null if not found at all.
  109869. */
  109870. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109871. /**
  109872. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109873. * @param id defines the id to search for
  109874. * @return the found morph target or null if not found at all.
  109875. */
  109876. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109877. /**
  109878. * Gets a boolean indicating if the given mesh is active
  109879. * @param mesh defines the mesh to look for
  109880. * @returns true if the mesh is in the active list
  109881. */
  109882. isActiveMesh(mesh: AbstractMesh): boolean;
  109883. /**
  109884. * Return a unique id as a string which can serve as an identifier for the scene
  109885. */
  109886. get uid(): string;
  109887. /**
  109888. * Add an externaly attached data from its key.
  109889. * This method call will fail and return false, if such key already exists.
  109890. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109891. * @param key the unique key that identifies the data
  109892. * @param data the data object to associate to the key for this Engine instance
  109893. * @return true if no such key were already present and the data was added successfully, false otherwise
  109894. */
  109895. addExternalData<T>(key: string, data: T): boolean;
  109896. /**
  109897. * Get an externaly attached data from its key
  109898. * @param key the unique key that identifies the data
  109899. * @return the associated data, if present (can be null), or undefined if not present
  109900. */
  109901. getExternalData<T>(key: string): Nullable<T>;
  109902. /**
  109903. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109904. * @param key the unique key that identifies the data
  109905. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109906. * @return the associated data, can be null if the factory returned null.
  109907. */
  109908. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109909. /**
  109910. * Remove an externaly attached data from the Engine instance
  109911. * @param key the unique key that identifies the data
  109912. * @return true if the data was successfully removed, false if it doesn't exist
  109913. */
  109914. removeExternalData(key: string): boolean;
  109915. private _evaluateSubMesh;
  109916. /**
  109917. * Clear the processed materials smart array preventing retention point in material dispose.
  109918. */
  109919. freeProcessedMaterials(): void;
  109920. private _preventFreeActiveMeshesAndRenderingGroups;
  109921. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109922. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109923. * when disposing several meshes in a row or a hierarchy of meshes.
  109924. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109925. */
  109926. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109927. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109928. /**
  109929. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109930. */
  109931. freeActiveMeshes(): void;
  109932. /**
  109933. * Clear the info related to rendering groups preventing retention points during dispose.
  109934. */
  109935. freeRenderingGroups(): void;
  109936. /** @hidden */
  109937. _isInIntermediateRendering(): boolean;
  109938. /**
  109939. * Lambda returning the list of potentially active meshes.
  109940. */
  109941. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109942. /**
  109943. * Lambda returning the list of potentially active sub meshes.
  109944. */
  109945. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109946. /**
  109947. * Lambda returning the list of potentially intersecting sub meshes.
  109948. */
  109949. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109950. /**
  109951. * Lambda returning the list of potentially colliding sub meshes.
  109952. */
  109953. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109954. private _activeMeshesFrozen;
  109955. private _skipEvaluateActiveMeshesCompletely;
  109956. /**
  109957. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109958. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109959. * @returns the current scene
  109960. */
  109961. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109962. /**
  109963. * Use this function to restart evaluating active meshes on every frame
  109964. * @returns the current scene
  109965. */
  109966. unfreezeActiveMeshes(): Scene;
  109967. private _evaluateActiveMeshes;
  109968. private _activeMesh;
  109969. /**
  109970. * Update the transform matrix to update from the current active camera
  109971. * @param force defines a boolean used to force the update even if cache is up to date
  109972. */
  109973. updateTransformMatrix(force?: boolean): void;
  109974. private _bindFrameBuffer;
  109975. /** @hidden */
  109976. _allowPostProcessClearColor: boolean;
  109977. /** @hidden */
  109978. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109979. private _processSubCameras;
  109980. private _checkIntersections;
  109981. /** @hidden */
  109982. _advancePhysicsEngineStep(step: number): void;
  109983. /**
  109984. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109985. */
  109986. getDeterministicFrameTime: () => number;
  109987. /** @hidden */
  109988. _animate(): void;
  109989. /** Execute all animations (for a frame) */
  109990. animate(): void;
  109991. /**
  109992. * Render the scene
  109993. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109994. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109995. */
  109996. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109997. /**
  109998. * Freeze all materials
  109999. * A frozen material will not be updatable but should be faster to render
  110000. */
  110001. freezeMaterials(): void;
  110002. /**
  110003. * Unfreeze all materials
  110004. * A frozen material will not be updatable but should be faster to render
  110005. */
  110006. unfreezeMaterials(): void;
  110007. /**
  110008. * Releases all held ressources
  110009. */
  110010. dispose(): void;
  110011. /**
  110012. * Gets if the scene is already disposed
  110013. */
  110014. get isDisposed(): boolean;
  110015. /**
  110016. * Call this function to reduce memory footprint of the scene.
  110017. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110018. */
  110019. clearCachedVertexData(): void;
  110020. /**
  110021. * This function will remove the local cached buffer data from texture.
  110022. * It will save memory but will prevent the texture from being rebuilt
  110023. */
  110024. cleanCachedTextureBuffer(): void;
  110025. /**
  110026. * Get the world extend vectors with an optional filter
  110027. *
  110028. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110029. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110030. */
  110031. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110032. min: Vector3;
  110033. max: Vector3;
  110034. };
  110035. /**
  110036. * Creates a ray that can be used to pick in the scene
  110037. * @param x defines the x coordinate of the origin (on-screen)
  110038. * @param y defines the y coordinate of the origin (on-screen)
  110039. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110040. * @param camera defines the camera to use for the picking
  110041. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110042. * @returns a Ray
  110043. */
  110044. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110045. /**
  110046. * Creates a ray that can be used to pick in the scene
  110047. * @param x defines the x coordinate of the origin (on-screen)
  110048. * @param y defines the y coordinate of the origin (on-screen)
  110049. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110050. * @param result defines the ray where to store the picking ray
  110051. * @param camera defines the camera to use for the picking
  110052. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110053. * @returns the current scene
  110054. */
  110055. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110056. /**
  110057. * Creates a ray that can be used to pick in the scene
  110058. * @param x defines the x coordinate of the origin (on-screen)
  110059. * @param y defines the y coordinate of the origin (on-screen)
  110060. * @param camera defines the camera to use for the picking
  110061. * @returns a Ray
  110062. */
  110063. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110064. /**
  110065. * Creates a ray that can be used to pick in the scene
  110066. * @param x defines the x coordinate of the origin (on-screen)
  110067. * @param y defines the y coordinate of the origin (on-screen)
  110068. * @param result defines the ray where to store the picking ray
  110069. * @param camera defines the camera to use for the picking
  110070. * @returns the current scene
  110071. */
  110072. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110073. /** Launch a ray to try to pick a mesh in the scene
  110074. * @param x position on screen
  110075. * @param y position on screen
  110076. * @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
  110077. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110078. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110079. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110080. * @returns a PickingInfo
  110081. */
  110082. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110083. /** Use the given ray to pick a mesh in the scene
  110084. * @param ray The ray to use to pick meshes
  110085. * @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
  110086. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110087. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110088. * @returns a PickingInfo
  110089. */
  110090. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110091. /**
  110092. * Launch a ray to try to pick a mesh in the scene
  110093. * @param x X position on screen
  110094. * @param y Y position on screen
  110095. * @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
  110096. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110097. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110098. * @returns an array of PickingInfo
  110099. */
  110100. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110101. /**
  110102. * Launch a ray to try to pick a mesh in the scene
  110103. * @param ray Ray to use
  110104. * @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
  110105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110106. * @returns an array of PickingInfo
  110107. */
  110108. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110109. /**
  110110. * Force the value of meshUnderPointer
  110111. * @param mesh defines the mesh to use
  110112. */
  110113. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110114. /**
  110115. * Gets the mesh under the pointer
  110116. * @returns a Mesh or null if no mesh is under the pointer
  110117. */
  110118. getPointerOverMesh(): Nullable<AbstractMesh>;
  110119. /** @hidden */
  110120. _rebuildGeometries(): void;
  110121. /** @hidden */
  110122. _rebuildTextures(): void;
  110123. private _getByTags;
  110124. /**
  110125. * Get a list of meshes by tags
  110126. * @param tagsQuery defines the tags query to use
  110127. * @param forEach defines a predicate used to filter results
  110128. * @returns an array of Mesh
  110129. */
  110130. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110131. /**
  110132. * Get a list of cameras by tags
  110133. * @param tagsQuery defines the tags query to use
  110134. * @param forEach defines a predicate used to filter results
  110135. * @returns an array of Camera
  110136. */
  110137. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110138. /**
  110139. * Get a list of lights by tags
  110140. * @param tagsQuery defines the tags query to use
  110141. * @param forEach defines a predicate used to filter results
  110142. * @returns an array of Light
  110143. */
  110144. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110145. /**
  110146. * Get a list of materials by tags
  110147. * @param tagsQuery defines the tags query to use
  110148. * @param forEach defines a predicate used to filter results
  110149. * @returns an array of Material
  110150. */
  110151. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110152. /**
  110153. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110154. * This allowed control for front to back rendering or reversly depending of the special needs.
  110155. *
  110156. * @param renderingGroupId The rendering group id corresponding to its index
  110157. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110158. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110159. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110160. */
  110161. 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;
  110162. /**
  110163. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110164. *
  110165. * @param renderingGroupId The rendering group id corresponding to its index
  110166. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110167. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110168. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110169. */
  110170. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110171. /**
  110172. * Gets the current auto clear configuration for one rendering group of the rendering
  110173. * manager.
  110174. * @param index the rendering group index to get the information for
  110175. * @returns The auto clear setup for the requested rendering group
  110176. */
  110177. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110178. private _blockMaterialDirtyMechanism;
  110179. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110180. get blockMaterialDirtyMechanism(): boolean;
  110181. set blockMaterialDirtyMechanism(value: boolean);
  110182. /**
  110183. * Will flag all materials as dirty to trigger new shader compilation
  110184. * @param flag defines the flag used to specify which material part must be marked as dirty
  110185. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110186. */
  110187. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110188. /** @hidden */
  110189. _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;
  110190. /** @hidden */
  110191. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110192. /** @hidden */
  110193. _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;
  110194. /** @hidden */
  110195. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110196. /** @hidden */
  110197. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110198. /** @hidden */
  110199. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110200. }
  110201. }
  110202. declare module BABYLON {
  110203. /**
  110204. * Set of assets to keep when moving a scene into an asset container.
  110205. */
  110206. export class KeepAssets extends AbstractScene {
  110207. }
  110208. /**
  110209. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110210. */
  110211. export class InstantiatedEntries {
  110212. /**
  110213. * List of new root nodes (eg. nodes with no parent)
  110214. */
  110215. rootNodes: TransformNode[];
  110216. /**
  110217. * List of new skeletons
  110218. */
  110219. skeletons: Skeleton[];
  110220. /**
  110221. * List of new animation groups
  110222. */
  110223. animationGroups: AnimationGroup[];
  110224. }
  110225. /**
  110226. * Container with a set of assets that can be added or removed from a scene.
  110227. */
  110228. export class AssetContainer extends AbstractScene {
  110229. private _wasAddedToScene;
  110230. /**
  110231. * The scene the AssetContainer belongs to.
  110232. */
  110233. scene: Scene;
  110234. /**
  110235. * Instantiates an AssetContainer.
  110236. * @param scene The scene the AssetContainer belongs to.
  110237. */
  110238. constructor(scene: Scene);
  110239. /**
  110240. * Instantiate or clone all meshes and add the new ones to the scene.
  110241. * Skeletons and animation groups will all be cloned
  110242. * @param nameFunction defines an optional function used to get new names for clones
  110243. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110244. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110245. */
  110246. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110247. /**
  110248. * Adds all the assets from the container to the scene.
  110249. */
  110250. addAllToScene(): void;
  110251. /**
  110252. * Removes all the assets in the container from the scene
  110253. */
  110254. removeAllFromScene(): void;
  110255. /**
  110256. * Disposes all the assets in the container
  110257. */
  110258. dispose(): void;
  110259. private _moveAssets;
  110260. /**
  110261. * Removes all the assets contained in the scene and adds them to the container.
  110262. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110263. */
  110264. moveAllFromScene(keepAssets?: KeepAssets): void;
  110265. /**
  110266. * 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.
  110267. * @returns the root mesh
  110268. */
  110269. createRootMesh(): Mesh;
  110270. /**
  110271. * Merge animations from this asset container into a scene
  110272. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110273. * @param animatables set of animatables to retarget to a node from the scene
  110274. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110275. */
  110276. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110277. }
  110278. }
  110279. declare module BABYLON {
  110280. /**
  110281. * Defines how the parser contract is defined.
  110282. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110283. */
  110284. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110285. /**
  110286. * Defines how the individual parser contract is defined.
  110287. * These parser can parse an individual asset
  110288. */
  110289. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110290. /**
  110291. * Base class of the scene acting as a container for the different elements composing a scene.
  110292. * This class is dynamically extended by the different components of the scene increasing
  110293. * flexibility and reducing coupling
  110294. */
  110295. export abstract class AbstractScene {
  110296. /**
  110297. * Stores the list of available parsers in the application.
  110298. */
  110299. private static _BabylonFileParsers;
  110300. /**
  110301. * Stores the list of available individual parsers in the application.
  110302. */
  110303. private static _IndividualBabylonFileParsers;
  110304. /**
  110305. * Adds a parser in the list of available ones
  110306. * @param name Defines the name of the parser
  110307. * @param parser Defines the parser to add
  110308. */
  110309. static AddParser(name: string, parser: BabylonFileParser): void;
  110310. /**
  110311. * Gets a general parser from the list of avaialble ones
  110312. * @param name Defines the name of the parser
  110313. * @returns the requested parser or null
  110314. */
  110315. static GetParser(name: string): Nullable<BabylonFileParser>;
  110316. /**
  110317. * Adds n individual parser in the list of available ones
  110318. * @param name Defines the name of the parser
  110319. * @param parser Defines the parser to add
  110320. */
  110321. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110322. /**
  110323. * Gets an individual parser from the list of avaialble ones
  110324. * @param name Defines the name of the parser
  110325. * @returns the requested parser or null
  110326. */
  110327. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110328. /**
  110329. * Parser json data and populate both a scene and its associated container object
  110330. * @param jsonData Defines the data to parse
  110331. * @param scene Defines the scene to parse the data for
  110332. * @param container Defines the container attached to the parsing sequence
  110333. * @param rootUrl Defines the root url of the data
  110334. */
  110335. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110336. /**
  110337. * Gets the list of root nodes (ie. nodes with no parent)
  110338. */
  110339. rootNodes: Node[];
  110340. /** All of the cameras added to this scene
  110341. * @see http://doc.babylonjs.com/babylon101/cameras
  110342. */
  110343. cameras: Camera[];
  110344. /**
  110345. * All of the lights added to this scene
  110346. * @see http://doc.babylonjs.com/babylon101/lights
  110347. */
  110348. lights: Light[];
  110349. /**
  110350. * All of the (abstract) meshes added to this scene
  110351. */
  110352. meshes: AbstractMesh[];
  110353. /**
  110354. * The list of skeletons added to the scene
  110355. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110356. */
  110357. skeletons: Skeleton[];
  110358. /**
  110359. * All of the particle systems added to this scene
  110360. * @see http://doc.babylonjs.com/babylon101/particles
  110361. */
  110362. particleSystems: IParticleSystem[];
  110363. /**
  110364. * Gets a list of Animations associated with the scene
  110365. */
  110366. animations: Animation[];
  110367. /**
  110368. * All of the animation groups added to this scene
  110369. * @see http://doc.babylonjs.com/how_to/group
  110370. */
  110371. animationGroups: AnimationGroup[];
  110372. /**
  110373. * All of the multi-materials added to this scene
  110374. * @see http://doc.babylonjs.com/how_to/multi_materials
  110375. */
  110376. multiMaterials: MultiMaterial[];
  110377. /**
  110378. * All of the materials added to this scene
  110379. * In the context of a Scene, it is not supposed to be modified manually.
  110380. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110381. * Note also that the order of the Material within the array is not significant and might change.
  110382. * @see http://doc.babylonjs.com/babylon101/materials
  110383. */
  110384. materials: Material[];
  110385. /**
  110386. * The list of morph target managers added to the scene
  110387. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110388. */
  110389. morphTargetManagers: MorphTargetManager[];
  110390. /**
  110391. * The list of geometries used in the scene.
  110392. */
  110393. geometries: Geometry[];
  110394. /**
  110395. * All of the tranform nodes added to this scene
  110396. * In the context of a Scene, it is not supposed to be modified manually.
  110397. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110398. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110399. * @see http://doc.babylonjs.com/how_to/transformnode
  110400. */
  110401. transformNodes: TransformNode[];
  110402. /**
  110403. * ActionManagers available on the scene.
  110404. */
  110405. actionManagers: AbstractActionManager[];
  110406. /**
  110407. * Textures to keep.
  110408. */
  110409. textures: BaseTexture[];
  110410. /**
  110411. * Environment texture for the scene
  110412. */
  110413. environmentTexture: Nullable<BaseTexture>;
  110414. /**
  110415. * @returns all meshes, lights, cameras, transformNodes and bones
  110416. */
  110417. getNodes(): Array<Node>;
  110418. }
  110419. }
  110420. declare module BABYLON {
  110421. /**
  110422. * Interface used to define options for Sound class
  110423. */
  110424. export interface ISoundOptions {
  110425. /**
  110426. * Does the sound autoplay once loaded.
  110427. */
  110428. autoplay?: boolean;
  110429. /**
  110430. * Does the sound loop after it finishes playing once.
  110431. */
  110432. loop?: boolean;
  110433. /**
  110434. * Sound's volume
  110435. */
  110436. volume?: number;
  110437. /**
  110438. * Is it a spatial sound?
  110439. */
  110440. spatialSound?: boolean;
  110441. /**
  110442. * Maximum distance to hear that sound
  110443. */
  110444. maxDistance?: number;
  110445. /**
  110446. * Uses user defined attenuation function
  110447. */
  110448. useCustomAttenuation?: boolean;
  110449. /**
  110450. * Define the roll off factor of spatial sounds.
  110451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110452. */
  110453. rolloffFactor?: number;
  110454. /**
  110455. * Define the reference distance the sound should be heard perfectly.
  110456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110457. */
  110458. refDistance?: number;
  110459. /**
  110460. * Define the distance attenuation model the sound will follow.
  110461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110462. */
  110463. distanceModel?: string;
  110464. /**
  110465. * Defines the playback speed (1 by default)
  110466. */
  110467. playbackRate?: number;
  110468. /**
  110469. * Defines if the sound is from a streaming source
  110470. */
  110471. streaming?: boolean;
  110472. /**
  110473. * Defines an optional length (in seconds) inside the sound file
  110474. */
  110475. length?: number;
  110476. /**
  110477. * Defines an optional offset (in seconds) inside the sound file
  110478. */
  110479. offset?: number;
  110480. /**
  110481. * If true, URLs will not be required to state the audio file codec to use.
  110482. */
  110483. skipCodecCheck?: boolean;
  110484. }
  110485. /**
  110486. * Defines a sound that can be played in the application.
  110487. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110489. */
  110490. export class Sound {
  110491. /**
  110492. * The name of the sound in the scene.
  110493. */
  110494. name: string;
  110495. /**
  110496. * Does the sound autoplay once loaded.
  110497. */
  110498. autoplay: boolean;
  110499. /**
  110500. * Does the sound loop after it finishes playing once.
  110501. */
  110502. loop: boolean;
  110503. /**
  110504. * Does the sound use a custom attenuation curve to simulate the falloff
  110505. * happening when the source gets further away from the camera.
  110506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110507. */
  110508. useCustomAttenuation: boolean;
  110509. /**
  110510. * The sound track id this sound belongs to.
  110511. */
  110512. soundTrackId: number;
  110513. /**
  110514. * Is this sound currently played.
  110515. */
  110516. isPlaying: boolean;
  110517. /**
  110518. * Is this sound currently paused.
  110519. */
  110520. isPaused: boolean;
  110521. /**
  110522. * Does this sound enables spatial sound.
  110523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110524. */
  110525. spatialSound: boolean;
  110526. /**
  110527. * Define the reference distance the sound should be heard perfectly.
  110528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110529. */
  110530. refDistance: number;
  110531. /**
  110532. * Define the roll off factor of spatial sounds.
  110533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110534. */
  110535. rolloffFactor: number;
  110536. /**
  110537. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110539. */
  110540. maxDistance: number;
  110541. /**
  110542. * Define the distance attenuation model the sound will follow.
  110543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110544. */
  110545. distanceModel: string;
  110546. /**
  110547. * @hidden
  110548. * Back Compat
  110549. **/
  110550. onended: () => any;
  110551. /**
  110552. * Observable event when the current playing sound finishes.
  110553. */
  110554. onEndedObservable: Observable<Sound>;
  110555. private _panningModel;
  110556. private _playbackRate;
  110557. private _streaming;
  110558. private _startTime;
  110559. private _startOffset;
  110560. private _position;
  110561. /** @hidden */
  110562. _positionInEmitterSpace: boolean;
  110563. private _localDirection;
  110564. private _volume;
  110565. private _isReadyToPlay;
  110566. private _isDirectional;
  110567. private _readyToPlayCallback;
  110568. private _audioBuffer;
  110569. private _soundSource;
  110570. private _streamingSource;
  110571. private _soundPanner;
  110572. private _soundGain;
  110573. private _inputAudioNode;
  110574. private _outputAudioNode;
  110575. private _coneInnerAngle;
  110576. private _coneOuterAngle;
  110577. private _coneOuterGain;
  110578. private _scene;
  110579. private _connectedTransformNode;
  110580. private _customAttenuationFunction;
  110581. private _registerFunc;
  110582. private _isOutputConnected;
  110583. private _htmlAudioElement;
  110584. private _urlType;
  110585. private _length?;
  110586. private _offset?;
  110587. /** @hidden */
  110588. static _SceneComponentInitialization: (scene: Scene) => void;
  110589. /**
  110590. * Create a sound and attach it to a scene
  110591. * @param name Name of your sound
  110592. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110593. * @param scene defines the scene the sound belongs to
  110594. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110595. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110596. */
  110597. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110598. /**
  110599. * Release the sound and its associated resources
  110600. */
  110601. dispose(): void;
  110602. /**
  110603. * Gets if the sounds is ready to be played or not.
  110604. * @returns true if ready, otherwise false
  110605. */
  110606. isReady(): boolean;
  110607. private _soundLoaded;
  110608. /**
  110609. * Sets the data of the sound from an audiobuffer
  110610. * @param audioBuffer The audioBuffer containing the data
  110611. */
  110612. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110613. /**
  110614. * Updates the current sounds options such as maxdistance, loop...
  110615. * @param options A JSON object containing values named as the object properties
  110616. */
  110617. updateOptions(options: ISoundOptions): void;
  110618. private _createSpatialParameters;
  110619. private _updateSpatialParameters;
  110620. /**
  110621. * Switch the panning model to HRTF:
  110622. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110624. */
  110625. switchPanningModelToHRTF(): void;
  110626. /**
  110627. * Switch the panning model to Equal Power:
  110628. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110630. */
  110631. switchPanningModelToEqualPower(): void;
  110632. private _switchPanningModel;
  110633. /**
  110634. * Connect this sound to a sound track audio node like gain...
  110635. * @param soundTrackAudioNode the sound track audio node to connect to
  110636. */
  110637. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110638. /**
  110639. * Transform this sound into a directional source
  110640. * @param coneInnerAngle Size of the inner cone in degree
  110641. * @param coneOuterAngle Size of the outer cone in degree
  110642. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110643. */
  110644. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110645. /**
  110646. * Gets or sets the inner angle for the directional cone.
  110647. */
  110648. get directionalConeInnerAngle(): number;
  110649. /**
  110650. * Gets or sets the inner angle for the directional cone.
  110651. */
  110652. set directionalConeInnerAngle(value: number);
  110653. /**
  110654. * Gets or sets the outer angle for the directional cone.
  110655. */
  110656. get directionalConeOuterAngle(): number;
  110657. /**
  110658. * Gets or sets the outer angle for the directional cone.
  110659. */
  110660. set directionalConeOuterAngle(value: number);
  110661. /**
  110662. * Sets the position of the emitter if spatial sound is enabled
  110663. * @param newPosition Defines the new posisiton
  110664. */
  110665. setPosition(newPosition: Vector3): void;
  110666. /**
  110667. * Sets the local direction of the emitter if spatial sound is enabled
  110668. * @param newLocalDirection Defines the new local direction
  110669. */
  110670. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110671. private _updateDirection;
  110672. /** @hidden */
  110673. updateDistanceFromListener(): void;
  110674. /**
  110675. * Sets a new custom attenuation function for the sound.
  110676. * @param callback Defines the function used for the attenuation
  110677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110678. */
  110679. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110680. /**
  110681. * Play the sound
  110682. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110683. * @param offset (optional) Start the sound at a specific time in seconds
  110684. * @param length (optional) Sound duration (in seconds)
  110685. */
  110686. play(time?: number, offset?: number, length?: number): void;
  110687. private _onended;
  110688. /**
  110689. * Stop the sound
  110690. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110691. */
  110692. stop(time?: number): void;
  110693. /**
  110694. * Put the sound in pause
  110695. */
  110696. pause(): void;
  110697. /**
  110698. * Sets a dedicated volume for this sounds
  110699. * @param newVolume Define the new volume of the sound
  110700. * @param time Define time for gradual change to new volume
  110701. */
  110702. setVolume(newVolume: number, time?: number): void;
  110703. /**
  110704. * Set the sound play back rate
  110705. * @param newPlaybackRate Define the playback rate the sound should be played at
  110706. */
  110707. setPlaybackRate(newPlaybackRate: number): void;
  110708. /**
  110709. * Gets the volume of the sound.
  110710. * @returns the volume of the sound
  110711. */
  110712. getVolume(): number;
  110713. /**
  110714. * Attach the sound to a dedicated mesh
  110715. * @param transformNode The transform node to connect the sound with
  110716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110717. */
  110718. attachToMesh(transformNode: TransformNode): void;
  110719. /**
  110720. * Detach the sound from the previously attached mesh
  110721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110722. */
  110723. detachFromMesh(): void;
  110724. private _onRegisterAfterWorldMatrixUpdate;
  110725. /**
  110726. * Clone the current sound in the scene.
  110727. * @returns the new sound clone
  110728. */
  110729. clone(): Nullable<Sound>;
  110730. /**
  110731. * Gets the current underlying audio buffer containing the data
  110732. * @returns the audio buffer
  110733. */
  110734. getAudioBuffer(): Nullable<AudioBuffer>;
  110735. /**
  110736. * Serializes the Sound in a JSON representation
  110737. * @returns the JSON representation of the sound
  110738. */
  110739. serialize(): any;
  110740. /**
  110741. * Parse a JSON representation of a sound to innstantiate in a given scene
  110742. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110743. * @param scene Define the scene the new parsed sound should be created in
  110744. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110745. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110746. * @returns the newly parsed sound
  110747. */
  110748. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110749. }
  110750. }
  110751. declare module BABYLON {
  110752. /**
  110753. * This defines an action helpful to play a defined sound on a triggered action.
  110754. */
  110755. export class PlaySoundAction extends Action {
  110756. private _sound;
  110757. /**
  110758. * Instantiate the action
  110759. * @param triggerOptions defines the trigger options
  110760. * @param sound defines the sound to play
  110761. * @param condition defines the trigger related conditions
  110762. */
  110763. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110764. /** @hidden */
  110765. _prepare(): void;
  110766. /**
  110767. * Execute the action and play the sound.
  110768. */
  110769. execute(): void;
  110770. /**
  110771. * Serializes the actions and its related information.
  110772. * @param parent defines the object to serialize in
  110773. * @returns the serialized object
  110774. */
  110775. serialize(parent: any): any;
  110776. }
  110777. /**
  110778. * This defines an action helpful to stop a defined sound on a triggered action.
  110779. */
  110780. export class StopSoundAction extends Action {
  110781. private _sound;
  110782. /**
  110783. * Instantiate the action
  110784. * @param triggerOptions defines the trigger options
  110785. * @param sound defines the sound to stop
  110786. * @param condition defines the trigger related conditions
  110787. */
  110788. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110789. /** @hidden */
  110790. _prepare(): void;
  110791. /**
  110792. * Execute the action and stop the sound.
  110793. */
  110794. execute(): void;
  110795. /**
  110796. * Serializes the actions and its related information.
  110797. * @param parent defines the object to serialize in
  110798. * @returns the serialized object
  110799. */
  110800. serialize(parent: any): any;
  110801. }
  110802. }
  110803. declare module BABYLON {
  110804. /**
  110805. * This defines an action responsible to change the value of a property
  110806. * by interpolating between its current value and the newly set one once triggered.
  110807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110808. */
  110809. export class InterpolateValueAction extends Action {
  110810. /**
  110811. * Defines the path of the property where the value should be interpolated
  110812. */
  110813. propertyPath: string;
  110814. /**
  110815. * Defines the target value at the end of the interpolation.
  110816. */
  110817. value: any;
  110818. /**
  110819. * Defines the time it will take for the property to interpolate to the value.
  110820. */
  110821. duration: number;
  110822. /**
  110823. * Defines if the other scene animations should be stopped when the action has been triggered
  110824. */
  110825. stopOtherAnimations?: boolean;
  110826. /**
  110827. * Defines a callback raised once the interpolation animation has been done.
  110828. */
  110829. onInterpolationDone?: () => void;
  110830. /**
  110831. * Observable triggered once the interpolation animation has been done.
  110832. */
  110833. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110834. private _target;
  110835. private _effectiveTarget;
  110836. private _property;
  110837. /**
  110838. * Instantiate the action
  110839. * @param triggerOptions defines the trigger options
  110840. * @param target defines the object containing the value to interpolate
  110841. * @param propertyPath defines the path to the property in the target object
  110842. * @param value defines the target value at the end of the interpolation
  110843. * @param duration deines the time it will take for the property to interpolate to the value.
  110844. * @param condition defines the trigger related conditions
  110845. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110846. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110847. */
  110848. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110849. /** @hidden */
  110850. _prepare(): void;
  110851. /**
  110852. * Execute the action starts the value interpolation.
  110853. */
  110854. execute(): void;
  110855. /**
  110856. * Serializes the actions and its related information.
  110857. * @param parent defines the object to serialize in
  110858. * @returns the serialized object
  110859. */
  110860. serialize(parent: any): any;
  110861. }
  110862. }
  110863. declare module BABYLON {
  110864. /**
  110865. * Options allowed during the creation of a sound track.
  110866. */
  110867. export interface ISoundTrackOptions {
  110868. /**
  110869. * The volume the sound track should take during creation
  110870. */
  110871. volume?: number;
  110872. /**
  110873. * Define if the sound track is the main sound track of the scene
  110874. */
  110875. mainTrack?: boolean;
  110876. }
  110877. /**
  110878. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110879. * It will be also used in a future release to apply effects on a specific track.
  110880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110881. */
  110882. export class SoundTrack {
  110883. /**
  110884. * The unique identifier of the sound track in the scene.
  110885. */
  110886. id: number;
  110887. /**
  110888. * The list of sounds included in the sound track.
  110889. */
  110890. soundCollection: Array<Sound>;
  110891. private _outputAudioNode;
  110892. private _scene;
  110893. private _connectedAnalyser;
  110894. private _options;
  110895. private _isInitialized;
  110896. /**
  110897. * Creates a new sound track.
  110898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110899. * @param scene Define the scene the sound track belongs to
  110900. * @param options
  110901. */
  110902. constructor(scene: Scene, options?: ISoundTrackOptions);
  110903. private _initializeSoundTrackAudioGraph;
  110904. /**
  110905. * Release the sound track and its associated resources
  110906. */
  110907. dispose(): void;
  110908. /**
  110909. * Adds a sound to this sound track
  110910. * @param sound define the cound to add
  110911. * @ignoreNaming
  110912. */
  110913. AddSound(sound: Sound): void;
  110914. /**
  110915. * Removes a sound to this sound track
  110916. * @param sound define the cound to remove
  110917. * @ignoreNaming
  110918. */
  110919. RemoveSound(sound: Sound): void;
  110920. /**
  110921. * Set a global volume for the full sound track.
  110922. * @param newVolume Define the new volume of the sound track
  110923. */
  110924. setVolume(newVolume: number): void;
  110925. /**
  110926. * Switch the panning model to HRTF:
  110927. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110929. */
  110930. switchPanningModelToHRTF(): void;
  110931. /**
  110932. * Switch the panning model to Equal Power:
  110933. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110935. */
  110936. switchPanningModelToEqualPower(): void;
  110937. /**
  110938. * Connect the sound track to an audio analyser allowing some amazing
  110939. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110941. * @param analyser The analyser to connect to the engine
  110942. */
  110943. connectToAnalyser(analyser: Analyser): void;
  110944. }
  110945. }
  110946. declare module BABYLON {
  110947. interface AbstractScene {
  110948. /**
  110949. * The list of sounds used in the scene.
  110950. */
  110951. sounds: Nullable<Array<Sound>>;
  110952. }
  110953. interface Scene {
  110954. /**
  110955. * @hidden
  110956. * Backing field
  110957. */
  110958. _mainSoundTrack: SoundTrack;
  110959. /**
  110960. * The main sound track played by the scene.
  110961. * It cotains your primary collection of sounds.
  110962. */
  110963. mainSoundTrack: SoundTrack;
  110964. /**
  110965. * The list of sound tracks added to the scene
  110966. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110967. */
  110968. soundTracks: Nullable<Array<SoundTrack>>;
  110969. /**
  110970. * Gets a sound using a given name
  110971. * @param name defines the name to search for
  110972. * @return the found sound or null if not found at all.
  110973. */
  110974. getSoundByName(name: string): Nullable<Sound>;
  110975. /**
  110976. * Gets or sets if audio support is enabled
  110977. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110978. */
  110979. audioEnabled: boolean;
  110980. /**
  110981. * Gets or sets if audio will be output to headphones
  110982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110983. */
  110984. headphone: boolean;
  110985. /**
  110986. * Gets or sets custom audio listener position provider
  110987. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110988. */
  110989. audioListenerPositionProvider: Nullable<() => Vector3>;
  110990. /**
  110991. * Gets or sets a refresh rate when using 3D audio positioning
  110992. */
  110993. audioPositioningRefreshRate: number;
  110994. }
  110995. /**
  110996. * Defines the sound scene component responsible to manage any sounds
  110997. * in a given scene.
  110998. */
  110999. export class AudioSceneComponent implements ISceneSerializableComponent {
  111000. /**
  111001. * The component name helpfull to identify the component in the list of scene components.
  111002. */
  111003. readonly name: string;
  111004. /**
  111005. * The scene the component belongs to.
  111006. */
  111007. scene: Scene;
  111008. private _audioEnabled;
  111009. /**
  111010. * Gets whether audio is enabled or not.
  111011. * Please use related enable/disable method to switch state.
  111012. */
  111013. get audioEnabled(): boolean;
  111014. private _headphone;
  111015. /**
  111016. * Gets whether audio is outputing to headphone or not.
  111017. * Please use the according Switch methods to change output.
  111018. */
  111019. get headphone(): boolean;
  111020. /**
  111021. * Gets or sets a refresh rate when using 3D audio positioning
  111022. */
  111023. audioPositioningRefreshRate: number;
  111024. private _audioListenerPositionProvider;
  111025. /**
  111026. * Gets the current audio listener position provider
  111027. */
  111028. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111029. /**
  111030. * Sets a custom listener position for all sounds in the scene
  111031. * By default, this is the position of the first active camera
  111032. */
  111033. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111034. /**
  111035. * Creates a new instance of the component for the given scene
  111036. * @param scene Defines the scene to register the component in
  111037. */
  111038. constructor(scene: Scene);
  111039. /**
  111040. * Registers the component in a given scene
  111041. */
  111042. register(): void;
  111043. /**
  111044. * Rebuilds the elements related to this component in case of
  111045. * context lost for instance.
  111046. */
  111047. rebuild(): void;
  111048. /**
  111049. * Serializes the component data to the specified json object
  111050. * @param serializationObject The object to serialize to
  111051. */
  111052. serialize(serializationObject: any): void;
  111053. /**
  111054. * Adds all the elements from the container to the scene
  111055. * @param container the container holding the elements
  111056. */
  111057. addFromContainer(container: AbstractScene): void;
  111058. /**
  111059. * Removes all the elements in the container from the scene
  111060. * @param container contains the elements to remove
  111061. * @param dispose if the removed element should be disposed (default: false)
  111062. */
  111063. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111064. /**
  111065. * Disposes the component and the associated ressources.
  111066. */
  111067. dispose(): void;
  111068. /**
  111069. * Disables audio in the associated scene.
  111070. */
  111071. disableAudio(): void;
  111072. /**
  111073. * Enables audio in the associated scene.
  111074. */
  111075. enableAudio(): void;
  111076. /**
  111077. * Switch audio to headphone output.
  111078. */
  111079. switchAudioModeForHeadphones(): void;
  111080. /**
  111081. * Switch audio to normal speakers.
  111082. */
  111083. switchAudioModeForNormalSpeakers(): void;
  111084. private _cachedCameraDirection;
  111085. private _cachedCameraPosition;
  111086. private _lastCheck;
  111087. private _afterRender;
  111088. }
  111089. }
  111090. declare module BABYLON {
  111091. /**
  111092. * Wraps one or more Sound objects and selects one with random weight for playback.
  111093. */
  111094. export class WeightedSound {
  111095. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111096. loop: boolean;
  111097. private _coneInnerAngle;
  111098. private _coneOuterAngle;
  111099. private _volume;
  111100. /** A Sound is currently playing. */
  111101. isPlaying: boolean;
  111102. /** A Sound is currently paused. */
  111103. isPaused: boolean;
  111104. private _sounds;
  111105. private _weights;
  111106. private _currentIndex?;
  111107. /**
  111108. * Creates a new WeightedSound from the list of sounds given.
  111109. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111110. * @param sounds Array of Sounds that will be selected from.
  111111. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111112. */
  111113. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111114. /**
  111115. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111116. */
  111117. get directionalConeInnerAngle(): number;
  111118. /**
  111119. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111120. */
  111121. set directionalConeInnerAngle(value: number);
  111122. /**
  111123. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111124. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111125. */
  111126. get directionalConeOuterAngle(): number;
  111127. /**
  111128. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111129. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111130. */
  111131. set directionalConeOuterAngle(value: number);
  111132. /**
  111133. * Playback volume.
  111134. */
  111135. get volume(): number;
  111136. /**
  111137. * Playback volume.
  111138. */
  111139. set volume(value: number);
  111140. private _onended;
  111141. /**
  111142. * Suspend playback
  111143. */
  111144. pause(): void;
  111145. /**
  111146. * Stop playback
  111147. */
  111148. stop(): void;
  111149. /**
  111150. * Start playback.
  111151. * @param startOffset Position the clip head at a specific time in seconds.
  111152. */
  111153. play(startOffset?: number): void;
  111154. }
  111155. }
  111156. declare module BABYLON {
  111157. /**
  111158. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111159. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111160. */
  111161. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111162. /**
  111163. * Gets the name of the behavior.
  111164. */
  111165. get name(): string;
  111166. /**
  111167. * The easing function used by animations
  111168. */
  111169. static EasingFunction: BackEase;
  111170. /**
  111171. * The easing mode used by animations
  111172. */
  111173. static EasingMode: number;
  111174. /**
  111175. * The duration of the animation, in milliseconds
  111176. */
  111177. transitionDuration: number;
  111178. /**
  111179. * Length of the distance animated by the transition when lower radius is reached
  111180. */
  111181. lowerRadiusTransitionRange: number;
  111182. /**
  111183. * Length of the distance animated by the transition when upper radius is reached
  111184. */
  111185. upperRadiusTransitionRange: number;
  111186. private _autoTransitionRange;
  111187. /**
  111188. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111189. */
  111190. get autoTransitionRange(): boolean;
  111191. /**
  111192. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111193. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111194. */
  111195. set autoTransitionRange(value: boolean);
  111196. private _attachedCamera;
  111197. private _onAfterCheckInputsObserver;
  111198. private _onMeshTargetChangedObserver;
  111199. /**
  111200. * Initializes the behavior.
  111201. */
  111202. init(): void;
  111203. /**
  111204. * Attaches the behavior to its arc rotate camera.
  111205. * @param camera Defines the camera to attach the behavior to
  111206. */
  111207. attach(camera: ArcRotateCamera): void;
  111208. /**
  111209. * Detaches the behavior from its current arc rotate camera.
  111210. */
  111211. detach(): void;
  111212. private _radiusIsAnimating;
  111213. private _radiusBounceTransition;
  111214. private _animatables;
  111215. private _cachedWheelPrecision;
  111216. /**
  111217. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111218. * @param radiusLimit The limit to check against.
  111219. * @return Bool to indicate if at limit.
  111220. */
  111221. private _isRadiusAtLimit;
  111222. /**
  111223. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111224. * @param radiusDelta The delta by which to animate to. Can be negative.
  111225. */
  111226. private _applyBoundRadiusAnimation;
  111227. /**
  111228. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111229. */
  111230. protected _clearAnimationLocks(): void;
  111231. /**
  111232. * Stops and removes all animations that have been applied to the camera
  111233. */
  111234. stopAllAnimations(): void;
  111235. }
  111236. }
  111237. declare module BABYLON {
  111238. /**
  111239. * 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.
  111240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111241. */
  111242. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111243. /**
  111244. * Gets the name of the behavior.
  111245. */
  111246. get name(): string;
  111247. private _mode;
  111248. private _radiusScale;
  111249. private _positionScale;
  111250. private _defaultElevation;
  111251. private _elevationReturnTime;
  111252. private _elevationReturnWaitTime;
  111253. private _zoomStopsAnimation;
  111254. private _framingTime;
  111255. /**
  111256. * The easing function used by animations
  111257. */
  111258. static EasingFunction: ExponentialEase;
  111259. /**
  111260. * The easing mode used by animations
  111261. */
  111262. static EasingMode: number;
  111263. /**
  111264. * Sets the current mode used by the behavior
  111265. */
  111266. set mode(mode: number);
  111267. /**
  111268. * Gets current mode used by the behavior.
  111269. */
  111270. get mode(): number;
  111271. /**
  111272. * Sets the scale applied to the radius (1 by default)
  111273. */
  111274. set radiusScale(radius: number);
  111275. /**
  111276. * Gets the scale applied to the radius
  111277. */
  111278. get radiusScale(): number;
  111279. /**
  111280. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111281. */
  111282. set positionScale(scale: number);
  111283. /**
  111284. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111285. */
  111286. get positionScale(): number;
  111287. /**
  111288. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111289. * behaviour is triggered, in radians.
  111290. */
  111291. set defaultElevation(elevation: number);
  111292. /**
  111293. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111294. * behaviour is triggered, in radians.
  111295. */
  111296. get defaultElevation(): number;
  111297. /**
  111298. * Sets the time (in milliseconds) taken to return to the default beta position.
  111299. * Negative value indicates camera should not return to default.
  111300. */
  111301. set elevationReturnTime(speed: number);
  111302. /**
  111303. * Gets the time (in milliseconds) taken to return to the default beta position.
  111304. * Negative value indicates camera should not return to default.
  111305. */
  111306. get elevationReturnTime(): number;
  111307. /**
  111308. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111309. */
  111310. set elevationReturnWaitTime(time: number);
  111311. /**
  111312. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111313. */
  111314. get elevationReturnWaitTime(): number;
  111315. /**
  111316. * Sets the flag that indicates if user zooming should stop animation.
  111317. */
  111318. set zoomStopsAnimation(flag: boolean);
  111319. /**
  111320. * Gets the flag that indicates if user zooming should stop animation.
  111321. */
  111322. get zoomStopsAnimation(): boolean;
  111323. /**
  111324. * Sets the transition time when framing the mesh, in milliseconds
  111325. */
  111326. set framingTime(time: number);
  111327. /**
  111328. * Gets the transition time when framing the mesh, in milliseconds
  111329. */
  111330. get framingTime(): number;
  111331. /**
  111332. * Define if the behavior should automatically change the configured
  111333. * camera limits and sensibilities.
  111334. */
  111335. autoCorrectCameraLimitsAndSensibility: boolean;
  111336. private _onPrePointerObservableObserver;
  111337. private _onAfterCheckInputsObserver;
  111338. private _onMeshTargetChangedObserver;
  111339. private _attachedCamera;
  111340. private _isPointerDown;
  111341. private _lastInteractionTime;
  111342. /**
  111343. * Initializes the behavior.
  111344. */
  111345. init(): void;
  111346. /**
  111347. * Attaches the behavior to its arc rotate camera.
  111348. * @param camera Defines the camera to attach the behavior to
  111349. */
  111350. attach(camera: ArcRotateCamera): void;
  111351. /**
  111352. * Detaches the behavior from its current arc rotate camera.
  111353. */
  111354. detach(): void;
  111355. private _animatables;
  111356. private _betaIsAnimating;
  111357. private _betaTransition;
  111358. private _radiusTransition;
  111359. private _vectorTransition;
  111360. /**
  111361. * Targets the given mesh and updates zoom level accordingly.
  111362. * @param mesh The mesh to target.
  111363. * @param radius Optional. If a cached radius position already exists, overrides default.
  111364. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111365. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111366. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111367. */
  111368. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111369. /**
  111370. * Targets the given mesh with its children and updates zoom level accordingly.
  111371. * @param mesh The mesh to target.
  111372. * @param radius Optional. If a cached radius position already exists, overrides default.
  111373. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111374. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111375. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111376. */
  111377. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111378. /**
  111379. * Targets the given meshes with their children and updates zoom level accordingly.
  111380. * @param meshes The mesh to target.
  111381. * @param radius Optional. If a cached radius position already exists, overrides default.
  111382. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  111383. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111384. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111385. */
  111386. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111387. /**
  111388. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111389. * @param minimumWorld Determines the smaller position of the bounding box extend
  111390. * @param maximumWorld Determines the bigger position of the bounding box extend
  111391. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111392. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111393. */
  111394. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111395. /**
  111396. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111397. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111398. * frustum width.
  111399. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111400. * to fully enclose the mesh in the viewing frustum.
  111401. */
  111402. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111403. /**
  111404. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111405. * is automatically returned to its default position (expected to be above ground plane).
  111406. */
  111407. private _maintainCameraAboveGround;
  111408. /**
  111409. * Returns the frustum slope based on the canvas ratio and camera FOV
  111410. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111411. */
  111412. private _getFrustumSlope;
  111413. /**
  111414. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111415. */
  111416. private _clearAnimationLocks;
  111417. /**
  111418. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111419. */
  111420. private _applyUserInteraction;
  111421. /**
  111422. * Stops and removes all animations that have been applied to the camera
  111423. */
  111424. stopAllAnimations(): void;
  111425. /**
  111426. * Gets a value indicating if the user is moving the camera
  111427. */
  111428. get isUserIsMoving(): boolean;
  111429. /**
  111430. * The camera can move all the way towards the mesh.
  111431. */
  111432. static IgnoreBoundsSizeMode: number;
  111433. /**
  111434. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111435. */
  111436. static FitFrustumSidesMode: number;
  111437. }
  111438. }
  111439. declare module BABYLON {
  111440. /**
  111441. * Base class for Camera Pointer Inputs.
  111442. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111443. * for example usage.
  111444. */
  111445. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111446. /**
  111447. * Defines the camera the input is attached to.
  111448. */
  111449. abstract camera: Camera;
  111450. /**
  111451. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111452. */
  111453. protected _altKey: boolean;
  111454. protected _ctrlKey: boolean;
  111455. protected _metaKey: boolean;
  111456. protected _shiftKey: boolean;
  111457. /**
  111458. * Which mouse buttons were pressed at time of last mouse event.
  111459. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111460. */
  111461. protected _buttonsPressed: number;
  111462. /**
  111463. * Defines the buttons associated with the input to handle camera move.
  111464. */
  111465. buttons: number[];
  111466. /**
  111467. * Attach the input controls to a specific dom element to get the input from.
  111468. * @param element Defines the element the controls should be listened from
  111469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111470. */
  111471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111472. /**
  111473. * Detach the current controls from the specified dom element.
  111474. * @param element Defines the element to stop listening the inputs from
  111475. */
  111476. detachControl(element: Nullable<HTMLElement>): void;
  111477. /**
  111478. * Gets the class name of the current input.
  111479. * @returns the class name
  111480. */
  111481. getClassName(): string;
  111482. /**
  111483. * Get the friendly name associated with the input class.
  111484. * @returns the input friendly name
  111485. */
  111486. getSimpleName(): string;
  111487. /**
  111488. * Called on pointer POINTERDOUBLETAP event.
  111489. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111490. */
  111491. protected onDoubleTap(type: string): void;
  111492. /**
  111493. * Called on pointer POINTERMOVE event if only a single touch is active.
  111494. * Override this method to provide functionality.
  111495. */
  111496. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111497. /**
  111498. * Called on pointer POINTERMOVE event if multiple touches are active.
  111499. * Override this method to provide functionality.
  111500. */
  111501. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111502. /**
  111503. * Called on JS contextmenu event.
  111504. * Override this method to provide functionality.
  111505. */
  111506. protected onContextMenu(evt: PointerEvent): void;
  111507. /**
  111508. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111509. * press.
  111510. * Override this method to provide functionality.
  111511. */
  111512. protected onButtonDown(evt: PointerEvent): void;
  111513. /**
  111514. * Called each time a new POINTERUP event occurs. Ie, for each button
  111515. * release.
  111516. * Override this method to provide functionality.
  111517. */
  111518. protected onButtonUp(evt: PointerEvent): void;
  111519. /**
  111520. * Called when window becomes inactive.
  111521. * Override this method to provide functionality.
  111522. */
  111523. protected onLostFocus(): void;
  111524. private _pointerInput;
  111525. private _observer;
  111526. private _onLostFocus;
  111527. private pointA;
  111528. private pointB;
  111529. }
  111530. }
  111531. declare module BABYLON {
  111532. /**
  111533. * Manage the pointers inputs to control an arc rotate camera.
  111534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111535. */
  111536. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111537. /**
  111538. * Defines the camera the input is attached to.
  111539. */
  111540. camera: ArcRotateCamera;
  111541. /**
  111542. * Gets the class name of the current input.
  111543. * @returns the class name
  111544. */
  111545. getClassName(): string;
  111546. /**
  111547. * Defines the buttons associated with the input to handle camera move.
  111548. */
  111549. buttons: number[];
  111550. /**
  111551. * Defines the pointer angular sensibility along the X axis or how fast is
  111552. * the camera rotating.
  111553. */
  111554. angularSensibilityX: number;
  111555. /**
  111556. * Defines the pointer angular sensibility along the Y axis or how fast is
  111557. * the camera rotating.
  111558. */
  111559. angularSensibilityY: number;
  111560. /**
  111561. * Defines the pointer pinch precision or how fast is the camera zooming.
  111562. */
  111563. pinchPrecision: number;
  111564. /**
  111565. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111566. * from 0.
  111567. * It defines the percentage of current camera.radius to use as delta when
  111568. * pinch zoom is used.
  111569. */
  111570. pinchDeltaPercentage: number;
  111571. /**
  111572. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111573. * that any object in the plane at the camera's target point will scale
  111574. * perfectly with finger motion.
  111575. * Overrides pinchDeltaPercentage and pinchPrecision.
  111576. */
  111577. useNaturalPinchZoom: boolean;
  111578. /**
  111579. * Defines the pointer panning sensibility or how fast is the camera moving.
  111580. */
  111581. panningSensibility: number;
  111582. /**
  111583. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111584. */
  111585. multiTouchPanning: boolean;
  111586. /**
  111587. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111588. * zoom (pinch) through multitouch.
  111589. */
  111590. multiTouchPanAndZoom: boolean;
  111591. /**
  111592. * Revers pinch action direction.
  111593. */
  111594. pinchInwards: boolean;
  111595. private _isPanClick;
  111596. private _twoFingerActivityCount;
  111597. private _isPinching;
  111598. /**
  111599. * Called on pointer POINTERMOVE event if only a single touch is active.
  111600. */
  111601. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111602. /**
  111603. * Called on pointer POINTERDOUBLETAP event.
  111604. */
  111605. protected onDoubleTap(type: string): void;
  111606. /**
  111607. * Called on pointer POINTERMOVE event if multiple touches are active.
  111608. */
  111609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111610. /**
  111611. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111612. * press.
  111613. */
  111614. protected onButtonDown(evt: PointerEvent): void;
  111615. /**
  111616. * Called each time a new POINTERUP event occurs. Ie, for each button
  111617. * release.
  111618. */
  111619. protected onButtonUp(evt: PointerEvent): void;
  111620. /**
  111621. * Called when window becomes inactive.
  111622. */
  111623. protected onLostFocus(): void;
  111624. }
  111625. }
  111626. declare module BABYLON {
  111627. /**
  111628. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111630. */
  111631. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111632. /**
  111633. * Defines the camera the input is attached to.
  111634. */
  111635. camera: ArcRotateCamera;
  111636. /**
  111637. * Defines the list of key codes associated with the up action (increase alpha)
  111638. */
  111639. keysUp: number[];
  111640. /**
  111641. * Defines the list of key codes associated with the down action (decrease alpha)
  111642. */
  111643. keysDown: number[];
  111644. /**
  111645. * Defines the list of key codes associated with the left action (increase beta)
  111646. */
  111647. keysLeft: number[];
  111648. /**
  111649. * Defines the list of key codes associated with the right action (decrease beta)
  111650. */
  111651. keysRight: number[];
  111652. /**
  111653. * Defines the list of key codes associated with the reset action.
  111654. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111655. */
  111656. keysReset: number[];
  111657. /**
  111658. * Defines the panning sensibility of the inputs.
  111659. * (How fast is the camera panning)
  111660. */
  111661. panningSensibility: number;
  111662. /**
  111663. * Defines the zooming sensibility of the inputs.
  111664. * (How fast is the camera zooming)
  111665. */
  111666. zoomingSensibility: number;
  111667. /**
  111668. * Defines whether maintaining the alt key down switch the movement mode from
  111669. * orientation to zoom.
  111670. */
  111671. useAltToZoom: boolean;
  111672. /**
  111673. * Rotation speed of the camera
  111674. */
  111675. angularSpeed: number;
  111676. private _keys;
  111677. private _ctrlPressed;
  111678. private _altPressed;
  111679. private _onCanvasBlurObserver;
  111680. private _onKeyboardObserver;
  111681. private _engine;
  111682. private _scene;
  111683. /**
  111684. * Attach the input controls to a specific dom element to get the input from.
  111685. * @param element Defines the element the controls should be listened from
  111686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111687. */
  111688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111689. /**
  111690. * Detach the current controls from the specified dom element.
  111691. * @param element Defines the element to stop listening the inputs from
  111692. */
  111693. detachControl(element: Nullable<HTMLElement>): void;
  111694. /**
  111695. * Update the current camera state depending on the inputs that have been used this frame.
  111696. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111697. */
  111698. checkInputs(): void;
  111699. /**
  111700. * Gets the class name of the current intput.
  111701. * @returns the class name
  111702. */
  111703. getClassName(): string;
  111704. /**
  111705. * Get the friendly name associated with the input class.
  111706. * @returns the input friendly name
  111707. */
  111708. getSimpleName(): string;
  111709. }
  111710. }
  111711. declare module BABYLON {
  111712. /**
  111713. * Manage the mouse wheel inputs to control an arc rotate camera.
  111714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111715. */
  111716. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111717. /**
  111718. * Defines the camera the input is attached to.
  111719. */
  111720. camera: ArcRotateCamera;
  111721. /**
  111722. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111723. */
  111724. wheelPrecision: number;
  111725. /**
  111726. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111727. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111728. */
  111729. wheelDeltaPercentage: number;
  111730. private _wheel;
  111731. private _observer;
  111732. private computeDeltaFromMouseWheelLegacyEvent;
  111733. /**
  111734. * Attach the input controls to a specific dom element to get the input from.
  111735. * @param element Defines the element the controls should be listened from
  111736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111737. */
  111738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111739. /**
  111740. * Detach the current controls from the specified dom element.
  111741. * @param element Defines the element to stop listening the inputs from
  111742. */
  111743. detachControl(element: Nullable<HTMLElement>): void;
  111744. /**
  111745. * Gets the class name of the current intput.
  111746. * @returns the class name
  111747. */
  111748. getClassName(): string;
  111749. /**
  111750. * Get the friendly name associated with the input class.
  111751. * @returns the input friendly name
  111752. */
  111753. getSimpleName(): string;
  111754. }
  111755. }
  111756. declare module BABYLON {
  111757. /**
  111758. * Default Inputs manager for the ArcRotateCamera.
  111759. * It groups all the default supported inputs for ease of use.
  111760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111761. */
  111762. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111763. /**
  111764. * Instantiates a new ArcRotateCameraInputsManager.
  111765. * @param camera Defines the camera the inputs belong to
  111766. */
  111767. constructor(camera: ArcRotateCamera);
  111768. /**
  111769. * Add mouse wheel input support to the input manager.
  111770. * @returns the current input manager
  111771. */
  111772. addMouseWheel(): ArcRotateCameraInputsManager;
  111773. /**
  111774. * Add pointers input support to the input manager.
  111775. * @returns the current input manager
  111776. */
  111777. addPointers(): ArcRotateCameraInputsManager;
  111778. /**
  111779. * Add keyboard input support to the input manager.
  111780. * @returns the current input manager
  111781. */
  111782. addKeyboard(): ArcRotateCameraInputsManager;
  111783. }
  111784. }
  111785. declare module BABYLON {
  111786. /**
  111787. * This represents an orbital type of camera.
  111788. *
  111789. * 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.
  111790. * 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.
  111791. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111792. */
  111793. export class ArcRotateCamera extends TargetCamera {
  111794. /**
  111795. * Defines the rotation angle of the camera along the longitudinal axis.
  111796. */
  111797. alpha: number;
  111798. /**
  111799. * Defines the rotation angle of the camera along the latitudinal axis.
  111800. */
  111801. beta: number;
  111802. /**
  111803. * Defines the radius of the camera from it s target point.
  111804. */
  111805. radius: number;
  111806. protected _target: Vector3;
  111807. protected _targetHost: Nullable<AbstractMesh>;
  111808. /**
  111809. * Defines the target point of the camera.
  111810. * The camera looks towards it form the radius distance.
  111811. */
  111812. get target(): Vector3;
  111813. set target(value: Vector3);
  111814. /**
  111815. * Define the current local position of the camera in the scene
  111816. */
  111817. get position(): Vector3;
  111818. set position(newPosition: Vector3);
  111819. protected _upVector: Vector3;
  111820. protected _upToYMatrix: Matrix;
  111821. protected _YToUpMatrix: Matrix;
  111822. /**
  111823. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111824. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111825. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111826. */
  111827. set upVector(vec: Vector3);
  111828. get upVector(): Vector3;
  111829. /**
  111830. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111831. */
  111832. setMatUp(): void;
  111833. /**
  111834. * Current inertia value on the longitudinal axis.
  111835. * The bigger this number the longer it will take for the camera to stop.
  111836. */
  111837. inertialAlphaOffset: number;
  111838. /**
  111839. * Current inertia value on the latitudinal axis.
  111840. * The bigger this number the longer it will take for the camera to stop.
  111841. */
  111842. inertialBetaOffset: number;
  111843. /**
  111844. * Current inertia value on the radius axis.
  111845. * The bigger this number the longer it will take for the camera to stop.
  111846. */
  111847. inertialRadiusOffset: number;
  111848. /**
  111849. * Minimum allowed angle on the longitudinal axis.
  111850. * This can help limiting how the Camera is able to move in the scene.
  111851. */
  111852. lowerAlphaLimit: Nullable<number>;
  111853. /**
  111854. * Maximum allowed angle on the longitudinal axis.
  111855. * This can help limiting how the Camera is able to move in the scene.
  111856. */
  111857. upperAlphaLimit: Nullable<number>;
  111858. /**
  111859. * Minimum allowed angle on the latitudinal axis.
  111860. * This can help limiting how the Camera is able to move in the scene.
  111861. */
  111862. lowerBetaLimit: number;
  111863. /**
  111864. * Maximum allowed angle on the latitudinal axis.
  111865. * This can help limiting how the Camera is able to move in the scene.
  111866. */
  111867. upperBetaLimit: number;
  111868. /**
  111869. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111870. * This can help limiting how the Camera is able to move in the scene.
  111871. */
  111872. lowerRadiusLimit: Nullable<number>;
  111873. /**
  111874. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111875. * This can help limiting how the Camera is able to move in the scene.
  111876. */
  111877. upperRadiusLimit: Nullable<number>;
  111878. /**
  111879. * Defines the current inertia value used during panning of the camera along the X axis.
  111880. */
  111881. inertialPanningX: number;
  111882. /**
  111883. * Defines the current inertia value used during panning of the camera along the Y axis.
  111884. */
  111885. inertialPanningY: number;
  111886. /**
  111887. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111888. * Basically if your fingers moves away from more than this distance you will be considered
  111889. * in pinch mode.
  111890. */
  111891. pinchToPanMaxDistance: number;
  111892. /**
  111893. * Defines the maximum distance the camera can pan.
  111894. * This could help keeping the cammera always in your scene.
  111895. */
  111896. panningDistanceLimit: Nullable<number>;
  111897. /**
  111898. * Defines the target of the camera before paning.
  111899. */
  111900. panningOriginTarget: Vector3;
  111901. /**
  111902. * Defines the value of the inertia used during panning.
  111903. * 0 would mean stop inertia and one would mean no decelleration at all.
  111904. */
  111905. panningInertia: number;
  111906. /**
  111907. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111908. */
  111909. get angularSensibilityX(): number;
  111910. set angularSensibilityX(value: number);
  111911. /**
  111912. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111913. */
  111914. get angularSensibilityY(): number;
  111915. set angularSensibilityY(value: number);
  111916. /**
  111917. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111918. */
  111919. get pinchPrecision(): number;
  111920. set pinchPrecision(value: number);
  111921. /**
  111922. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111923. * It will be used instead of pinchDeltaPrecision if different from 0.
  111924. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111925. */
  111926. get pinchDeltaPercentage(): number;
  111927. set pinchDeltaPercentage(value: number);
  111928. /**
  111929. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111930. * and pinch delta percentage.
  111931. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111932. * that any object in the plane at the camera's target point will scale
  111933. * perfectly with finger motion.
  111934. */
  111935. get useNaturalPinchZoom(): boolean;
  111936. set useNaturalPinchZoom(value: boolean);
  111937. /**
  111938. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111939. */
  111940. get panningSensibility(): number;
  111941. set panningSensibility(value: number);
  111942. /**
  111943. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111944. */
  111945. get keysUp(): number[];
  111946. set keysUp(value: number[]);
  111947. /**
  111948. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111949. */
  111950. get keysDown(): number[];
  111951. set keysDown(value: number[]);
  111952. /**
  111953. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111954. */
  111955. get keysLeft(): number[];
  111956. set keysLeft(value: number[]);
  111957. /**
  111958. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111959. */
  111960. get keysRight(): number[];
  111961. set keysRight(value: number[]);
  111962. /**
  111963. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111964. */
  111965. get wheelPrecision(): number;
  111966. set wheelPrecision(value: number);
  111967. /**
  111968. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111969. * It will be used instead of pinchDeltaPrecision if different from 0.
  111970. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111971. */
  111972. get wheelDeltaPercentage(): number;
  111973. set wheelDeltaPercentage(value: number);
  111974. /**
  111975. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111976. */
  111977. zoomOnFactor: number;
  111978. /**
  111979. * Defines a screen offset for the camera position.
  111980. */
  111981. targetScreenOffset: Vector2;
  111982. /**
  111983. * Allows the camera to be completely reversed.
  111984. * If false the camera can not arrive upside down.
  111985. */
  111986. allowUpsideDown: boolean;
  111987. /**
  111988. * Define if double tap/click is used to restore the previously saved state of the camera.
  111989. */
  111990. useInputToRestoreState: boolean;
  111991. /** @hidden */
  111992. _viewMatrix: Matrix;
  111993. /** @hidden */
  111994. _useCtrlForPanning: boolean;
  111995. /** @hidden */
  111996. _panningMouseButton: number;
  111997. /**
  111998. * Defines the input associated to the camera.
  111999. */
  112000. inputs: ArcRotateCameraInputsManager;
  112001. /** @hidden */
  112002. _reset: () => void;
  112003. /**
  112004. * Defines the allowed panning axis.
  112005. */
  112006. panningAxis: Vector3;
  112007. protected _localDirection: Vector3;
  112008. protected _transformedDirection: Vector3;
  112009. private _bouncingBehavior;
  112010. /**
  112011. * Gets the bouncing behavior of the camera if it has been enabled.
  112012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112013. */
  112014. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112015. /**
  112016. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112017. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112018. */
  112019. get useBouncingBehavior(): boolean;
  112020. set useBouncingBehavior(value: boolean);
  112021. private _framingBehavior;
  112022. /**
  112023. * Gets the framing behavior of the camera if it has been enabled.
  112024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112025. */
  112026. get framingBehavior(): Nullable<FramingBehavior>;
  112027. /**
  112028. * Defines if the framing behavior of the camera is enabled on the camera.
  112029. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112030. */
  112031. get useFramingBehavior(): boolean;
  112032. set useFramingBehavior(value: boolean);
  112033. private _autoRotationBehavior;
  112034. /**
  112035. * Gets the auto rotation behavior of the camera if it has been enabled.
  112036. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112037. */
  112038. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112039. /**
  112040. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112041. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112042. */
  112043. get useAutoRotationBehavior(): boolean;
  112044. set useAutoRotationBehavior(value: boolean);
  112045. /**
  112046. * Observable triggered when the mesh target has been changed on the camera.
  112047. */
  112048. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112049. /**
  112050. * Event raised when the camera is colliding with a mesh.
  112051. */
  112052. onCollide: (collidedMesh: AbstractMesh) => void;
  112053. /**
  112054. * Defines whether the camera should check collision with the objects oh the scene.
  112055. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112056. */
  112057. checkCollisions: boolean;
  112058. /**
  112059. * Defines the collision radius of the camera.
  112060. * This simulates a sphere around the camera.
  112061. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112062. */
  112063. collisionRadius: Vector3;
  112064. protected _collider: Collider;
  112065. protected _previousPosition: Vector3;
  112066. protected _collisionVelocity: Vector3;
  112067. protected _newPosition: Vector3;
  112068. protected _previousAlpha: number;
  112069. protected _previousBeta: number;
  112070. protected _previousRadius: number;
  112071. protected _collisionTriggered: boolean;
  112072. protected _targetBoundingCenter: Nullable<Vector3>;
  112073. private _computationVector;
  112074. /**
  112075. * Instantiates a new ArcRotateCamera in a given scene
  112076. * @param name Defines the name of the camera
  112077. * @param alpha Defines the camera rotation along the logitudinal axis
  112078. * @param beta Defines the camera rotation along the latitudinal axis
  112079. * @param radius Defines the camera distance from its target
  112080. * @param target Defines the camera target
  112081. * @param scene Defines the scene the camera belongs to
  112082. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112083. */
  112084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112085. /** @hidden */
  112086. _initCache(): void;
  112087. /** @hidden */
  112088. _updateCache(ignoreParentClass?: boolean): void;
  112089. protected _getTargetPosition(): Vector3;
  112090. private _storedAlpha;
  112091. private _storedBeta;
  112092. private _storedRadius;
  112093. private _storedTarget;
  112094. private _storedTargetScreenOffset;
  112095. /**
  112096. * Stores the current state of the camera (alpha, beta, radius and target)
  112097. * @returns the camera itself
  112098. */
  112099. storeState(): Camera;
  112100. /**
  112101. * @hidden
  112102. * Restored camera state. You must call storeState() first
  112103. */
  112104. _restoreStateValues(): boolean;
  112105. /** @hidden */
  112106. _isSynchronizedViewMatrix(): boolean;
  112107. /**
  112108. * Attached controls to the current camera.
  112109. * @param element Defines the element the controls should be listened from
  112110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112111. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112112. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112113. */
  112114. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112115. /**
  112116. * Detach the current controls from the camera.
  112117. * The camera will stop reacting to inputs.
  112118. * @param element Defines the element to stop listening the inputs from
  112119. */
  112120. detachControl(element: HTMLElement): void;
  112121. /** @hidden */
  112122. _checkInputs(): void;
  112123. protected _checkLimits(): void;
  112124. /**
  112125. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112126. */
  112127. rebuildAnglesAndRadius(): void;
  112128. /**
  112129. * Use a position to define the current camera related information like alpha, beta and radius
  112130. * @param position Defines the position to set the camera at
  112131. */
  112132. setPosition(position: Vector3): void;
  112133. /**
  112134. * Defines the target the camera should look at.
  112135. * This will automatically adapt alpha beta and radius to fit within the new target.
  112136. * @param target Defines the new target as a Vector or a mesh
  112137. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112138. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112139. */
  112140. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112141. /** @hidden */
  112142. _getViewMatrix(): Matrix;
  112143. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112144. /**
  112145. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112146. * @param meshes Defines the mesh to zoom on
  112147. * @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)
  112148. */
  112149. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112150. /**
  112151. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112152. * The target will be changed but the radius
  112153. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112154. * @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)
  112155. */
  112156. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112157. min: Vector3;
  112158. max: Vector3;
  112159. distance: number;
  112160. }, doNotUpdateMaxZ?: boolean): void;
  112161. /**
  112162. * @override
  112163. * Override Camera.createRigCamera
  112164. */
  112165. createRigCamera(name: string, cameraIndex: number): Camera;
  112166. /**
  112167. * @hidden
  112168. * @override
  112169. * Override Camera._updateRigCameras
  112170. */
  112171. _updateRigCameras(): void;
  112172. /**
  112173. * Destroy the camera and release the current resources hold by it.
  112174. */
  112175. dispose(): void;
  112176. /**
  112177. * Gets the current object class name.
  112178. * @return the class name
  112179. */
  112180. getClassName(): string;
  112181. }
  112182. }
  112183. declare module BABYLON {
  112184. /**
  112185. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112186. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112187. */
  112188. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112189. /**
  112190. * Gets the name of the behavior.
  112191. */
  112192. get name(): string;
  112193. private _zoomStopsAnimation;
  112194. private _idleRotationSpeed;
  112195. private _idleRotationWaitTime;
  112196. private _idleRotationSpinupTime;
  112197. /**
  112198. * Sets the flag that indicates if user zooming should stop animation.
  112199. */
  112200. set zoomStopsAnimation(flag: boolean);
  112201. /**
  112202. * Gets the flag that indicates if user zooming should stop animation.
  112203. */
  112204. get zoomStopsAnimation(): boolean;
  112205. /**
  112206. * Sets the default speed at which the camera rotates around the model.
  112207. */
  112208. set idleRotationSpeed(speed: number);
  112209. /**
  112210. * Gets the default speed at which the camera rotates around the model.
  112211. */
  112212. get idleRotationSpeed(): number;
  112213. /**
  112214. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112215. */
  112216. set idleRotationWaitTime(time: number);
  112217. /**
  112218. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112219. */
  112220. get idleRotationWaitTime(): number;
  112221. /**
  112222. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112223. */
  112224. set idleRotationSpinupTime(time: number);
  112225. /**
  112226. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112227. */
  112228. get idleRotationSpinupTime(): number;
  112229. /**
  112230. * Gets a value indicating if the camera is currently rotating because of this behavior
  112231. */
  112232. get rotationInProgress(): boolean;
  112233. private _onPrePointerObservableObserver;
  112234. private _onAfterCheckInputsObserver;
  112235. private _attachedCamera;
  112236. private _isPointerDown;
  112237. private _lastFrameTime;
  112238. private _lastInteractionTime;
  112239. private _cameraRotationSpeed;
  112240. /**
  112241. * Initializes the behavior.
  112242. */
  112243. init(): void;
  112244. /**
  112245. * Attaches the behavior to its arc rotate camera.
  112246. * @param camera Defines the camera to attach the behavior to
  112247. */
  112248. attach(camera: ArcRotateCamera): void;
  112249. /**
  112250. * Detaches the behavior from its current arc rotate camera.
  112251. */
  112252. detach(): void;
  112253. /**
  112254. * Returns true if user is scrolling.
  112255. * @return true if user is scrolling.
  112256. */
  112257. private _userIsZooming;
  112258. private _lastFrameRadius;
  112259. private _shouldAnimationStopForInteraction;
  112260. /**
  112261. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112262. */
  112263. private _applyUserInteraction;
  112264. private _userIsMoving;
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. /**
  112269. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112270. */
  112271. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112272. private ui;
  112273. /**
  112274. * The name of the behavior
  112275. */
  112276. name: string;
  112277. /**
  112278. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112279. */
  112280. distanceAwayFromFace: number;
  112281. /**
  112282. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112283. */
  112284. distanceAwayFromBottomOfFace: number;
  112285. private _faceVectors;
  112286. private _target;
  112287. private _scene;
  112288. private _onRenderObserver;
  112289. private _tmpMatrix;
  112290. private _tmpVector;
  112291. /**
  112292. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112293. * @param ui The transform node that should be attched to the mesh
  112294. */
  112295. constructor(ui: TransformNode);
  112296. /**
  112297. * Initializes the behavior
  112298. */
  112299. init(): void;
  112300. private _closestFace;
  112301. private _zeroVector;
  112302. private _lookAtTmpMatrix;
  112303. private _lookAtToRef;
  112304. /**
  112305. * Attaches the AttachToBoxBehavior to the passed in mesh
  112306. * @param target The mesh that the specified node will be attached to
  112307. */
  112308. attach(target: Mesh): void;
  112309. /**
  112310. * Detaches the behavior from the mesh
  112311. */
  112312. detach(): void;
  112313. }
  112314. }
  112315. declare module BABYLON {
  112316. /**
  112317. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112318. */
  112319. export class FadeInOutBehavior implements Behavior<Mesh> {
  112320. /**
  112321. * Time in milliseconds to delay before fading in (Default: 0)
  112322. */
  112323. delay: number;
  112324. /**
  112325. * Time in milliseconds for the mesh to fade in (Default: 300)
  112326. */
  112327. fadeInTime: number;
  112328. private _millisecondsPerFrame;
  112329. private _hovered;
  112330. private _hoverValue;
  112331. private _ownerNode;
  112332. /**
  112333. * Instatiates the FadeInOutBehavior
  112334. */
  112335. constructor();
  112336. /**
  112337. * The name of the behavior
  112338. */
  112339. get name(): string;
  112340. /**
  112341. * Initializes the behavior
  112342. */
  112343. init(): void;
  112344. /**
  112345. * Attaches the fade behavior on the passed in mesh
  112346. * @param ownerNode The mesh that will be faded in/out once attached
  112347. */
  112348. attach(ownerNode: Mesh): void;
  112349. /**
  112350. * Detaches the behavior from the mesh
  112351. */
  112352. detach(): void;
  112353. /**
  112354. * Triggers the mesh to begin fading in or out
  112355. * @param value if the object should fade in or out (true to fade in)
  112356. */
  112357. fadeIn(value: boolean): void;
  112358. private _update;
  112359. private _setAllVisibility;
  112360. }
  112361. }
  112362. declare module BABYLON {
  112363. /**
  112364. * Class containing a set of static utilities functions for managing Pivots
  112365. * @hidden
  112366. */
  112367. export class PivotTools {
  112368. private static _PivotCached;
  112369. private static _OldPivotPoint;
  112370. private static _PivotTranslation;
  112371. private static _PivotTmpVector;
  112372. /** @hidden */
  112373. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112374. /** @hidden */
  112375. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112376. }
  112377. }
  112378. declare module BABYLON {
  112379. /**
  112380. * Class containing static functions to help procedurally build meshes
  112381. */
  112382. export class PlaneBuilder {
  112383. /**
  112384. * Creates a plane mesh
  112385. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112386. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112387. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112391. * @param name defines the name of the mesh
  112392. * @param options defines the options used to create the mesh
  112393. * @param scene defines the hosting scene
  112394. * @returns the plane mesh
  112395. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112396. */
  112397. static CreatePlane(name: string, options: {
  112398. size?: number;
  112399. width?: number;
  112400. height?: number;
  112401. sideOrientation?: number;
  112402. frontUVs?: Vector4;
  112403. backUVs?: Vector4;
  112404. updatable?: boolean;
  112405. sourcePlane?: Plane;
  112406. }, scene?: Nullable<Scene>): Mesh;
  112407. }
  112408. }
  112409. declare module BABYLON {
  112410. /**
  112411. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112412. */
  112413. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112414. private static _AnyMouseID;
  112415. /**
  112416. * Abstract mesh the behavior is set on
  112417. */
  112418. attachedNode: AbstractMesh;
  112419. private _dragPlane;
  112420. private _scene;
  112421. private _pointerObserver;
  112422. private _beforeRenderObserver;
  112423. private static _planeScene;
  112424. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112425. /**
  112426. * 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)
  112427. */
  112428. maxDragAngle: number;
  112429. /**
  112430. * @hidden
  112431. */
  112432. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112433. /**
  112434. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112435. */
  112436. currentDraggingPointerID: number;
  112437. /**
  112438. * The last position where the pointer hit the drag plane in world space
  112439. */
  112440. lastDragPosition: Vector3;
  112441. /**
  112442. * If the behavior is currently in a dragging state
  112443. */
  112444. dragging: boolean;
  112445. /**
  112446. * 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)
  112447. */
  112448. dragDeltaRatio: number;
  112449. /**
  112450. * If the drag plane orientation should be updated during the dragging (Default: true)
  112451. */
  112452. updateDragPlane: boolean;
  112453. private _debugMode;
  112454. private _moving;
  112455. /**
  112456. * Fires each time the attached mesh is dragged with the pointer
  112457. * * delta between last drag position and current drag position in world space
  112458. * * dragDistance along the drag axis
  112459. * * dragPlaneNormal normal of the current drag plane used during the drag
  112460. * * dragPlanePoint in world space where the drag intersects the drag plane
  112461. */
  112462. onDragObservable: Observable<{
  112463. delta: Vector3;
  112464. dragPlanePoint: Vector3;
  112465. dragPlaneNormal: Vector3;
  112466. dragDistance: number;
  112467. pointerId: number;
  112468. }>;
  112469. /**
  112470. * Fires each time a drag begins (eg. mouse down on mesh)
  112471. */
  112472. onDragStartObservable: Observable<{
  112473. dragPlanePoint: Vector3;
  112474. pointerId: number;
  112475. }>;
  112476. /**
  112477. * Fires each time a drag ends (eg. mouse release after drag)
  112478. */
  112479. onDragEndObservable: Observable<{
  112480. dragPlanePoint: Vector3;
  112481. pointerId: number;
  112482. }>;
  112483. /**
  112484. * If the attached mesh should be moved when dragged
  112485. */
  112486. moveAttached: boolean;
  112487. /**
  112488. * If the drag behavior will react to drag events (Default: true)
  112489. */
  112490. enabled: boolean;
  112491. /**
  112492. * If pointer events should start and release the drag (Default: true)
  112493. */
  112494. startAndReleaseDragOnPointerEvents: boolean;
  112495. /**
  112496. * If camera controls should be detached during the drag
  112497. */
  112498. detachCameraControls: boolean;
  112499. /**
  112500. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112501. */
  112502. useObjectOrientationForDragging: boolean;
  112503. private _options;
  112504. /**
  112505. * Gets the options used by the behavior
  112506. */
  112507. get options(): {
  112508. dragAxis?: Vector3;
  112509. dragPlaneNormal?: Vector3;
  112510. };
  112511. /**
  112512. * Sets the options used by the behavior
  112513. */
  112514. set options(options: {
  112515. dragAxis?: Vector3;
  112516. dragPlaneNormal?: Vector3;
  112517. });
  112518. /**
  112519. * Creates a pointer drag behavior that can be attached to a mesh
  112520. * @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)
  112521. */
  112522. constructor(options?: {
  112523. dragAxis?: Vector3;
  112524. dragPlaneNormal?: Vector3;
  112525. });
  112526. /**
  112527. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112528. */
  112529. validateDrag: (targetPosition: Vector3) => boolean;
  112530. /**
  112531. * The name of the behavior
  112532. */
  112533. get name(): string;
  112534. /**
  112535. * Initializes the behavior
  112536. */
  112537. init(): void;
  112538. private _tmpVector;
  112539. private _alternatePickedPoint;
  112540. private _worldDragAxis;
  112541. private _targetPosition;
  112542. private _attachedElement;
  112543. /**
  112544. * Attaches the drag behavior the passed in mesh
  112545. * @param ownerNode The mesh that will be dragged around once attached
  112546. * @param predicate Predicate to use for pick filtering
  112547. */
  112548. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112549. /**
  112550. * Force relase the drag action by code.
  112551. */
  112552. releaseDrag(): void;
  112553. private _startDragRay;
  112554. private _lastPointerRay;
  112555. /**
  112556. * Simulates the start of a pointer drag event on the behavior
  112557. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112558. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112559. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112560. */
  112561. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112562. private _startDrag;
  112563. private _dragDelta;
  112564. private _moveDrag;
  112565. private _pickWithRayOnDragPlane;
  112566. private _pointA;
  112567. private _pointB;
  112568. private _pointC;
  112569. private _lineA;
  112570. private _lineB;
  112571. private _localAxis;
  112572. private _lookAt;
  112573. private _updateDragPlanePosition;
  112574. /**
  112575. * Detaches the behavior from the mesh
  112576. */
  112577. detach(): void;
  112578. }
  112579. }
  112580. declare module BABYLON {
  112581. /**
  112582. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112583. */
  112584. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112585. private _dragBehaviorA;
  112586. private _dragBehaviorB;
  112587. private _startDistance;
  112588. private _initialScale;
  112589. private _targetScale;
  112590. private _ownerNode;
  112591. private _sceneRenderObserver;
  112592. /**
  112593. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112594. */
  112595. constructor();
  112596. /**
  112597. * The name of the behavior
  112598. */
  112599. get name(): string;
  112600. /**
  112601. * Initializes the behavior
  112602. */
  112603. init(): void;
  112604. private _getCurrentDistance;
  112605. /**
  112606. * Attaches the scale behavior the passed in mesh
  112607. * @param ownerNode The mesh that will be scaled around once attached
  112608. */
  112609. attach(ownerNode: Mesh): void;
  112610. /**
  112611. * Detaches the behavior from the mesh
  112612. */
  112613. detach(): void;
  112614. }
  112615. }
  112616. declare module BABYLON {
  112617. /**
  112618. * 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
  112619. */
  112620. export class SixDofDragBehavior implements Behavior<Mesh> {
  112621. private static _virtualScene;
  112622. private _ownerNode;
  112623. private _sceneRenderObserver;
  112624. private _scene;
  112625. private _targetPosition;
  112626. private _virtualOriginMesh;
  112627. private _virtualDragMesh;
  112628. private _pointerObserver;
  112629. private _moving;
  112630. private _startingOrientation;
  112631. /**
  112632. * 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)
  112633. */
  112634. private zDragFactor;
  112635. /**
  112636. * If the object should rotate to face the drag origin
  112637. */
  112638. rotateDraggedObject: boolean;
  112639. /**
  112640. * If the behavior is currently in a dragging state
  112641. */
  112642. dragging: boolean;
  112643. /**
  112644. * 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)
  112645. */
  112646. dragDeltaRatio: number;
  112647. /**
  112648. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112649. */
  112650. currentDraggingPointerID: number;
  112651. /**
  112652. * If camera controls should be detached during the drag
  112653. */
  112654. detachCameraControls: boolean;
  112655. /**
  112656. * Fires each time a drag starts
  112657. */
  112658. onDragStartObservable: Observable<{}>;
  112659. /**
  112660. * Fires each time a drag ends (eg. mouse release after drag)
  112661. */
  112662. onDragEndObservable: Observable<{}>;
  112663. /**
  112664. * 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
  112665. */
  112666. constructor();
  112667. /**
  112668. * The name of the behavior
  112669. */
  112670. get name(): string;
  112671. /**
  112672. * Initializes the behavior
  112673. */
  112674. init(): void;
  112675. /**
  112676. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112677. */
  112678. private get _pointerCamera();
  112679. /**
  112680. * Attaches the scale behavior the passed in mesh
  112681. * @param ownerNode The mesh that will be scaled around once attached
  112682. */
  112683. attach(ownerNode: Mesh): void;
  112684. /**
  112685. * Detaches the behavior from the mesh
  112686. */
  112687. detach(): void;
  112688. }
  112689. }
  112690. declare module BABYLON {
  112691. /**
  112692. * Class used to apply inverse kinematics to bones
  112693. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112694. */
  112695. export class BoneIKController {
  112696. private static _tmpVecs;
  112697. private static _tmpQuat;
  112698. private static _tmpMats;
  112699. /**
  112700. * Gets or sets the target mesh
  112701. */
  112702. targetMesh: AbstractMesh;
  112703. /** Gets or sets the mesh used as pole */
  112704. poleTargetMesh: AbstractMesh;
  112705. /**
  112706. * Gets or sets the bone used as pole
  112707. */
  112708. poleTargetBone: Nullable<Bone>;
  112709. /**
  112710. * Gets or sets the target position
  112711. */
  112712. targetPosition: Vector3;
  112713. /**
  112714. * Gets or sets the pole target position
  112715. */
  112716. poleTargetPosition: Vector3;
  112717. /**
  112718. * Gets or sets the pole target local offset
  112719. */
  112720. poleTargetLocalOffset: Vector3;
  112721. /**
  112722. * Gets or sets the pole angle
  112723. */
  112724. poleAngle: number;
  112725. /**
  112726. * Gets or sets the mesh associated with the controller
  112727. */
  112728. mesh: AbstractMesh;
  112729. /**
  112730. * 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)
  112731. */
  112732. slerpAmount: number;
  112733. private _bone1Quat;
  112734. private _bone1Mat;
  112735. private _bone2Ang;
  112736. private _bone1;
  112737. private _bone2;
  112738. private _bone1Length;
  112739. private _bone2Length;
  112740. private _maxAngle;
  112741. private _maxReach;
  112742. private _rightHandedSystem;
  112743. private _bendAxis;
  112744. private _slerping;
  112745. private _adjustRoll;
  112746. /**
  112747. * Gets or sets maximum allowed angle
  112748. */
  112749. get maxAngle(): number;
  112750. set maxAngle(value: number);
  112751. /**
  112752. * Creates a new BoneIKController
  112753. * @param mesh defines the mesh to control
  112754. * @param bone defines the bone to control
  112755. * @param options defines options to set up the controller
  112756. */
  112757. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112758. targetMesh?: AbstractMesh;
  112759. poleTargetMesh?: AbstractMesh;
  112760. poleTargetBone?: Bone;
  112761. poleTargetLocalOffset?: Vector3;
  112762. poleAngle?: number;
  112763. bendAxis?: Vector3;
  112764. maxAngle?: number;
  112765. slerpAmount?: number;
  112766. });
  112767. private _setMaxAngle;
  112768. /**
  112769. * Force the controller to update the bones
  112770. */
  112771. update(): void;
  112772. }
  112773. }
  112774. declare module BABYLON {
  112775. /**
  112776. * Class used to make a bone look toward a point in space
  112777. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112778. */
  112779. export class BoneLookController {
  112780. private static _tmpVecs;
  112781. private static _tmpQuat;
  112782. private static _tmpMats;
  112783. /**
  112784. * The target Vector3 that the bone will look at
  112785. */
  112786. target: Vector3;
  112787. /**
  112788. * The mesh that the bone is attached to
  112789. */
  112790. mesh: AbstractMesh;
  112791. /**
  112792. * The bone that will be looking to the target
  112793. */
  112794. bone: Bone;
  112795. /**
  112796. * The up axis of the coordinate system that is used when the bone is rotated
  112797. */
  112798. upAxis: Vector3;
  112799. /**
  112800. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112801. */
  112802. upAxisSpace: Space;
  112803. /**
  112804. * Used to make an adjustment to the yaw of the bone
  112805. */
  112806. adjustYaw: number;
  112807. /**
  112808. * Used to make an adjustment to the pitch of the bone
  112809. */
  112810. adjustPitch: number;
  112811. /**
  112812. * Used to make an adjustment to the roll of the bone
  112813. */
  112814. adjustRoll: number;
  112815. /**
  112816. * 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)
  112817. */
  112818. slerpAmount: number;
  112819. private _minYaw;
  112820. private _maxYaw;
  112821. private _minPitch;
  112822. private _maxPitch;
  112823. private _minYawSin;
  112824. private _minYawCos;
  112825. private _maxYawSin;
  112826. private _maxYawCos;
  112827. private _midYawConstraint;
  112828. private _minPitchTan;
  112829. private _maxPitchTan;
  112830. private _boneQuat;
  112831. private _slerping;
  112832. private _transformYawPitch;
  112833. private _transformYawPitchInv;
  112834. private _firstFrameSkipped;
  112835. private _yawRange;
  112836. private _fowardAxis;
  112837. /**
  112838. * Gets or sets the minimum yaw angle that the bone can look to
  112839. */
  112840. get minYaw(): number;
  112841. set minYaw(value: number);
  112842. /**
  112843. * Gets or sets the maximum yaw angle that the bone can look to
  112844. */
  112845. get maxYaw(): number;
  112846. set maxYaw(value: number);
  112847. /**
  112848. * Gets or sets the minimum pitch angle that the bone can look to
  112849. */
  112850. get minPitch(): number;
  112851. set minPitch(value: number);
  112852. /**
  112853. * Gets or sets the maximum pitch angle that the bone can look to
  112854. */
  112855. get maxPitch(): number;
  112856. set maxPitch(value: number);
  112857. /**
  112858. * Create a BoneLookController
  112859. * @param mesh the mesh that the bone belongs to
  112860. * @param bone the bone that will be looking to the target
  112861. * @param target the target Vector3 to look at
  112862. * @param options optional settings:
  112863. * * maxYaw: the maximum angle the bone will yaw to
  112864. * * minYaw: the minimum angle the bone will yaw to
  112865. * * maxPitch: the maximum angle the bone will pitch to
  112866. * * minPitch: the minimum angle the bone will yaw to
  112867. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112868. * * upAxis: the up axis of the coordinate system
  112869. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112870. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112871. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112872. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112873. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112874. * * adjustRoll: used to make an adjustment to the roll of the bone
  112875. **/
  112876. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112877. maxYaw?: number;
  112878. minYaw?: number;
  112879. maxPitch?: number;
  112880. minPitch?: number;
  112881. slerpAmount?: number;
  112882. upAxis?: Vector3;
  112883. upAxisSpace?: Space;
  112884. yawAxis?: Vector3;
  112885. pitchAxis?: Vector3;
  112886. adjustYaw?: number;
  112887. adjustPitch?: number;
  112888. adjustRoll?: number;
  112889. });
  112890. /**
  112891. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112892. */
  112893. update(): void;
  112894. private _getAngleDiff;
  112895. private _getAngleBetween;
  112896. private _isAngleBetween;
  112897. }
  112898. }
  112899. declare module BABYLON {
  112900. /**
  112901. * Manage the gamepad inputs to control an arc rotate camera.
  112902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112903. */
  112904. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112905. /**
  112906. * Defines the camera the input is attached to.
  112907. */
  112908. camera: ArcRotateCamera;
  112909. /**
  112910. * Defines the gamepad the input is gathering event from.
  112911. */
  112912. gamepad: Nullable<Gamepad>;
  112913. /**
  112914. * Defines the gamepad rotation sensiblity.
  112915. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112916. */
  112917. gamepadRotationSensibility: number;
  112918. /**
  112919. * Defines the gamepad move sensiblity.
  112920. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112921. */
  112922. gamepadMoveSensibility: number;
  112923. private _yAxisScale;
  112924. /**
  112925. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112926. */
  112927. get invertYAxis(): boolean;
  112928. set invertYAxis(value: boolean);
  112929. private _onGamepadConnectedObserver;
  112930. private _onGamepadDisconnectedObserver;
  112931. /**
  112932. * Attach the input controls to a specific dom element to get the input from.
  112933. * @param element Defines the element the controls should be listened from
  112934. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112935. */
  112936. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112937. /**
  112938. * Detach the current controls from the specified dom element.
  112939. * @param element Defines the element to stop listening the inputs from
  112940. */
  112941. detachControl(element: Nullable<HTMLElement>): void;
  112942. /**
  112943. * Update the current camera state depending on the inputs that have been used this frame.
  112944. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112945. */
  112946. checkInputs(): void;
  112947. /**
  112948. * Gets the class name of the current intput.
  112949. * @returns the class name
  112950. */
  112951. getClassName(): string;
  112952. /**
  112953. * Get the friendly name associated with the input class.
  112954. * @returns the input friendly name
  112955. */
  112956. getSimpleName(): string;
  112957. }
  112958. }
  112959. declare module BABYLON {
  112960. interface ArcRotateCameraInputsManager {
  112961. /**
  112962. * Add orientation input support to the input manager.
  112963. * @returns the current input manager
  112964. */
  112965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112966. }
  112967. /**
  112968. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112969. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112970. */
  112971. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112972. /**
  112973. * Defines the camera the input is attached to.
  112974. */
  112975. camera: ArcRotateCamera;
  112976. /**
  112977. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112978. */
  112979. alphaCorrection: number;
  112980. /**
  112981. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112982. */
  112983. gammaCorrection: number;
  112984. private _alpha;
  112985. private _gamma;
  112986. private _dirty;
  112987. private _deviceOrientationHandler;
  112988. /**
  112989. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112990. */
  112991. constructor();
  112992. /**
  112993. * Attach the input controls to a specific dom element to get the input from.
  112994. * @param element Defines the element the controls should be listened from
  112995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112996. */
  112997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112998. /** @hidden */
  112999. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113000. /**
  113001. * Update the current camera state depending on the inputs that have been used this frame.
  113002. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113003. */
  113004. checkInputs(): void;
  113005. /**
  113006. * Detach the current controls from the specified dom element.
  113007. * @param element Defines the element to stop listening the inputs from
  113008. */
  113009. detachControl(element: Nullable<HTMLElement>): void;
  113010. /**
  113011. * Gets the class name of the current intput.
  113012. * @returns the class name
  113013. */
  113014. getClassName(): string;
  113015. /**
  113016. * Get the friendly name associated with the input class.
  113017. * @returns the input friendly name
  113018. */
  113019. getSimpleName(): string;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. /**
  113024. * Listen to mouse events to control the camera.
  113025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113026. */
  113027. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113028. /**
  113029. * Defines the camera the input is attached to.
  113030. */
  113031. camera: FlyCamera;
  113032. /**
  113033. * Defines if touch is enabled. (Default is true.)
  113034. */
  113035. touchEnabled: boolean;
  113036. /**
  113037. * Defines the buttons associated with the input to handle camera rotation.
  113038. */
  113039. buttons: number[];
  113040. /**
  113041. * Assign buttons for Yaw control.
  113042. */
  113043. buttonsYaw: number[];
  113044. /**
  113045. * Assign buttons for Pitch control.
  113046. */
  113047. buttonsPitch: number[];
  113048. /**
  113049. * Assign buttons for Roll control.
  113050. */
  113051. buttonsRoll: number[];
  113052. /**
  113053. * Detect if any button is being pressed while mouse is moved.
  113054. * -1 = Mouse locked.
  113055. * 0 = Left button.
  113056. * 1 = Middle Button.
  113057. * 2 = Right Button.
  113058. */
  113059. activeButton: number;
  113060. /**
  113061. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113062. * Higher values reduce its sensitivity.
  113063. */
  113064. angularSensibility: number;
  113065. private _mousemoveCallback;
  113066. private _observer;
  113067. private _rollObserver;
  113068. private previousPosition;
  113069. private noPreventDefault;
  113070. private element;
  113071. /**
  113072. * Listen to mouse events to control the camera.
  113073. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113075. */
  113076. constructor(touchEnabled?: boolean);
  113077. /**
  113078. * Attach the mouse control to the HTML DOM element.
  113079. * @param element Defines the element that listens to the input events.
  113080. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113081. */
  113082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113083. /**
  113084. * Detach the current controls from the specified dom element.
  113085. * @param element Defines the element to stop listening the inputs from
  113086. */
  113087. detachControl(element: Nullable<HTMLElement>): void;
  113088. /**
  113089. * Gets the class name of the current input.
  113090. * @returns the class name.
  113091. */
  113092. getClassName(): string;
  113093. /**
  113094. * Get the friendly name associated with the input class.
  113095. * @returns the input's friendly name.
  113096. */
  113097. getSimpleName(): string;
  113098. private _pointerInput;
  113099. private _onMouseMove;
  113100. /**
  113101. * Rotate camera by mouse offset.
  113102. */
  113103. private rotateCamera;
  113104. }
  113105. }
  113106. declare module BABYLON {
  113107. /**
  113108. * Default Inputs manager for the FlyCamera.
  113109. * It groups all the default supported inputs for ease of use.
  113110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113111. */
  113112. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113113. /**
  113114. * Instantiates a new FlyCameraInputsManager.
  113115. * @param camera Defines the camera the inputs belong to.
  113116. */
  113117. constructor(camera: FlyCamera);
  113118. /**
  113119. * Add keyboard input support to the input manager.
  113120. * @returns the new FlyCameraKeyboardMoveInput().
  113121. */
  113122. addKeyboard(): FlyCameraInputsManager;
  113123. /**
  113124. * Add mouse input support to the input manager.
  113125. * @param touchEnabled Enable touch screen support.
  113126. * @returns the new FlyCameraMouseInput().
  113127. */
  113128. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113129. }
  113130. }
  113131. declare module BABYLON {
  113132. /**
  113133. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113134. * such as in a 3D Space Shooter or a Flight Simulator.
  113135. */
  113136. export class FlyCamera extends TargetCamera {
  113137. /**
  113138. * Define the collision ellipsoid of the camera.
  113139. * This is helpful for simulating a camera body, like a player's body.
  113140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113141. */
  113142. ellipsoid: Vector3;
  113143. /**
  113144. * Define an offset for the position of the ellipsoid around the camera.
  113145. * This can be helpful if the camera is attached away from the player's body center,
  113146. * such as at its head.
  113147. */
  113148. ellipsoidOffset: Vector3;
  113149. /**
  113150. * Enable or disable collisions of the camera with the rest of the scene objects.
  113151. */
  113152. checkCollisions: boolean;
  113153. /**
  113154. * Enable or disable gravity on the camera.
  113155. */
  113156. applyGravity: boolean;
  113157. /**
  113158. * Define the current direction the camera is moving to.
  113159. */
  113160. cameraDirection: Vector3;
  113161. /**
  113162. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113163. * This overrides and empties cameraRotation.
  113164. */
  113165. rotationQuaternion: Quaternion;
  113166. /**
  113167. * Track Roll to maintain the wanted Rolling when looking around.
  113168. */
  113169. _trackRoll: number;
  113170. /**
  113171. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113172. */
  113173. rollCorrect: number;
  113174. /**
  113175. * Mimic a banked turn, Rolling the camera when Yawing.
  113176. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113177. */
  113178. bankedTurn: boolean;
  113179. /**
  113180. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113181. */
  113182. bankedTurnLimit: number;
  113183. /**
  113184. * Value of 0 disables the banked Roll.
  113185. * Value of 1 is equal to the Yaw angle in radians.
  113186. */
  113187. bankedTurnMultiplier: number;
  113188. /**
  113189. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113190. */
  113191. inputs: FlyCameraInputsManager;
  113192. /**
  113193. * Gets the input sensibility for mouse input.
  113194. * Higher values reduce sensitivity.
  113195. */
  113196. get angularSensibility(): number;
  113197. /**
  113198. * Sets the input sensibility for a mouse input.
  113199. * Higher values reduce sensitivity.
  113200. */
  113201. set angularSensibility(value: number);
  113202. /**
  113203. * Get the keys for camera movement forward.
  113204. */
  113205. get keysForward(): number[];
  113206. /**
  113207. * Set the keys for camera movement forward.
  113208. */
  113209. set keysForward(value: number[]);
  113210. /**
  113211. * Get the keys for camera movement backward.
  113212. */
  113213. get keysBackward(): number[];
  113214. set keysBackward(value: number[]);
  113215. /**
  113216. * Get the keys for camera movement up.
  113217. */
  113218. get keysUp(): number[];
  113219. /**
  113220. * Set the keys for camera movement up.
  113221. */
  113222. set keysUp(value: number[]);
  113223. /**
  113224. * Get the keys for camera movement down.
  113225. */
  113226. get keysDown(): number[];
  113227. /**
  113228. * Set the keys for camera movement down.
  113229. */
  113230. set keysDown(value: number[]);
  113231. /**
  113232. * Get the keys for camera movement left.
  113233. */
  113234. get keysLeft(): number[];
  113235. /**
  113236. * Set the keys for camera movement left.
  113237. */
  113238. set keysLeft(value: number[]);
  113239. /**
  113240. * Set the keys for camera movement right.
  113241. */
  113242. get keysRight(): number[];
  113243. /**
  113244. * Set the keys for camera movement right.
  113245. */
  113246. set keysRight(value: number[]);
  113247. /**
  113248. * Event raised when the camera collides with a mesh in the scene.
  113249. */
  113250. onCollide: (collidedMesh: AbstractMesh) => void;
  113251. private _collider;
  113252. private _needMoveForGravity;
  113253. private _oldPosition;
  113254. private _diffPosition;
  113255. private _newPosition;
  113256. /** @hidden */
  113257. _localDirection: Vector3;
  113258. /** @hidden */
  113259. _transformedDirection: Vector3;
  113260. /**
  113261. * Instantiates a FlyCamera.
  113262. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113263. * such as in a 3D Space Shooter or a Flight Simulator.
  113264. * @param name Define the name of the camera in the scene.
  113265. * @param position Define the starting position of the camera in the scene.
  113266. * @param scene Define the scene the camera belongs to.
  113267. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113268. */
  113269. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113270. /**
  113271. * Attach a control to the HTML DOM element.
  113272. * @param element Defines the element that listens to the input events.
  113273. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113274. */
  113275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113276. /**
  113277. * Detach a control from the HTML DOM element.
  113278. * The camera will stop reacting to that input.
  113279. * @param element Defines the element that listens to the input events.
  113280. */
  113281. detachControl(element: HTMLElement): void;
  113282. private _collisionMask;
  113283. /**
  113284. * Get the mask that the camera ignores in collision events.
  113285. */
  113286. get collisionMask(): number;
  113287. /**
  113288. * Set the mask that the camera ignores in collision events.
  113289. */
  113290. set collisionMask(mask: number);
  113291. /** @hidden */
  113292. _collideWithWorld(displacement: Vector3): void;
  113293. /** @hidden */
  113294. private _onCollisionPositionChange;
  113295. /** @hidden */
  113296. _checkInputs(): void;
  113297. /** @hidden */
  113298. _decideIfNeedsToMove(): boolean;
  113299. /** @hidden */
  113300. _updatePosition(): void;
  113301. /**
  113302. * Restore the Roll to its target value at the rate specified.
  113303. * @param rate - Higher means slower restoring.
  113304. * @hidden
  113305. */
  113306. restoreRoll(rate: number): void;
  113307. /**
  113308. * Destroy the camera and release the current resources held by it.
  113309. */
  113310. dispose(): void;
  113311. /**
  113312. * Get the current object class name.
  113313. * @returns the class name.
  113314. */
  113315. getClassName(): string;
  113316. }
  113317. }
  113318. declare module BABYLON {
  113319. /**
  113320. * Listen to keyboard events to control the camera.
  113321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113322. */
  113323. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113324. /**
  113325. * Defines the camera the input is attached to.
  113326. */
  113327. camera: FlyCamera;
  113328. /**
  113329. * The list of keyboard keys used to control the forward move of the camera.
  113330. */
  113331. keysForward: number[];
  113332. /**
  113333. * The list of keyboard keys used to control the backward move of the camera.
  113334. */
  113335. keysBackward: number[];
  113336. /**
  113337. * The list of keyboard keys used to control the forward move of the camera.
  113338. */
  113339. keysUp: number[];
  113340. /**
  113341. * The list of keyboard keys used to control the backward move of the camera.
  113342. */
  113343. keysDown: number[];
  113344. /**
  113345. * The list of keyboard keys used to control the right strafe move of the camera.
  113346. */
  113347. keysRight: number[];
  113348. /**
  113349. * The list of keyboard keys used to control the left strafe move of the camera.
  113350. */
  113351. keysLeft: number[];
  113352. private _keys;
  113353. private _onCanvasBlurObserver;
  113354. private _onKeyboardObserver;
  113355. private _engine;
  113356. private _scene;
  113357. /**
  113358. * Attach the input controls to a specific dom element to get the input from.
  113359. * @param element Defines the element the controls should be listened from
  113360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113361. */
  113362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113363. /**
  113364. * Detach the current controls from the specified dom element.
  113365. * @param element Defines the element to stop listening the inputs from
  113366. */
  113367. detachControl(element: Nullable<HTMLElement>): void;
  113368. /**
  113369. * Gets the class name of the current intput.
  113370. * @returns the class name
  113371. */
  113372. getClassName(): string;
  113373. /** @hidden */
  113374. _onLostFocus(e: FocusEvent): void;
  113375. /**
  113376. * Get the friendly name associated with the input class.
  113377. * @returns the input friendly name
  113378. */
  113379. getSimpleName(): string;
  113380. /**
  113381. * Update the current camera state depending on the inputs that have been used this frame.
  113382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113383. */
  113384. checkInputs(): void;
  113385. }
  113386. }
  113387. declare module BABYLON {
  113388. /**
  113389. * Manage the mouse wheel inputs to control a follow camera.
  113390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113391. */
  113392. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113393. /**
  113394. * Defines the camera the input is attached to.
  113395. */
  113396. camera: FollowCamera;
  113397. /**
  113398. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113399. */
  113400. axisControlRadius: boolean;
  113401. /**
  113402. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113403. */
  113404. axisControlHeight: boolean;
  113405. /**
  113406. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113407. */
  113408. axisControlRotation: boolean;
  113409. /**
  113410. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113411. * relation to mouseWheel events.
  113412. */
  113413. wheelPrecision: number;
  113414. /**
  113415. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113416. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113417. */
  113418. wheelDeltaPercentage: number;
  113419. private _wheel;
  113420. private _observer;
  113421. /**
  113422. * Attach the input controls to a specific dom element to get the input from.
  113423. * @param element Defines the element the controls should be listened from
  113424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113425. */
  113426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113427. /**
  113428. * Detach the current controls from the specified dom element.
  113429. * @param element Defines the element to stop listening the inputs from
  113430. */
  113431. detachControl(element: Nullable<HTMLElement>): void;
  113432. /**
  113433. * Gets the class name of the current intput.
  113434. * @returns the class name
  113435. */
  113436. getClassName(): string;
  113437. /**
  113438. * Get the friendly name associated with the input class.
  113439. * @returns the input friendly name
  113440. */
  113441. getSimpleName(): string;
  113442. }
  113443. }
  113444. declare module BABYLON {
  113445. /**
  113446. * Manage the pointers inputs to control an follow camera.
  113447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113448. */
  113449. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113450. /**
  113451. * Defines the camera the input is attached to.
  113452. */
  113453. camera: FollowCamera;
  113454. /**
  113455. * Gets the class name of the current input.
  113456. * @returns the class name
  113457. */
  113458. getClassName(): string;
  113459. /**
  113460. * Defines the pointer angular sensibility along the X axis or how fast is
  113461. * the camera rotating.
  113462. * A negative number will reverse the axis direction.
  113463. */
  113464. angularSensibilityX: number;
  113465. /**
  113466. * Defines the pointer angular sensibility along the Y axis or how fast is
  113467. * the camera rotating.
  113468. * A negative number will reverse the axis direction.
  113469. */
  113470. angularSensibilityY: number;
  113471. /**
  113472. * Defines the pointer pinch precision or how fast is the camera zooming.
  113473. * A negative number will reverse the axis direction.
  113474. */
  113475. pinchPrecision: number;
  113476. /**
  113477. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113478. * from 0.
  113479. * It defines the percentage of current camera.radius to use as delta when
  113480. * pinch zoom is used.
  113481. */
  113482. pinchDeltaPercentage: number;
  113483. /**
  113484. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113485. */
  113486. axisXControlRadius: boolean;
  113487. /**
  113488. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113489. */
  113490. axisXControlHeight: boolean;
  113491. /**
  113492. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113493. */
  113494. axisXControlRotation: boolean;
  113495. /**
  113496. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113497. */
  113498. axisYControlRadius: boolean;
  113499. /**
  113500. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113501. */
  113502. axisYControlHeight: boolean;
  113503. /**
  113504. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113505. */
  113506. axisYControlRotation: boolean;
  113507. /**
  113508. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113509. */
  113510. axisPinchControlRadius: boolean;
  113511. /**
  113512. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113513. */
  113514. axisPinchControlHeight: boolean;
  113515. /**
  113516. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113517. */
  113518. axisPinchControlRotation: boolean;
  113519. /**
  113520. * Log error messages if basic misconfiguration has occurred.
  113521. */
  113522. warningEnable: boolean;
  113523. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113524. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113525. private _warningCounter;
  113526. private _warning;
  113527. }
  113528. }
  113529. declare module BABYLON {
  113530. /**
  113531. * Default Inputs manager for the FollowCamera.
  113532. * It groups all the default supported inputs for ease of use.
  113533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113534. */
  113535. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113536. /**
  113537. * Instantiates a new FollowCameraInputsManager.
  113538. * @param camera Defines the camera the inputs belong to
  113539. */
  113540. constructor(camera: FollowCamera);
  113541. /**
  113542. * Add keyboard input support to the input manager.
  113543. * @returns the current input manager
  113544. */
  113545. addKeyboard(): FollowCameraInputsManager;
  113546. /**
  113547. * Add mouse wheel input support to the input manager.
  113548. * @returns the current input manager
  113549. */
  113550. addMouseWheel(): FollowCameraInputsManager;
  113551. /**
  113552. * Add pointers input support to the input manager.
  113553. * @returns the current input manager
  113554. */
  113555. addPointers(): FollowCameraInputsManager;
  113556. /**
  113557. * Add orientation input support to the input manager.
  113558. * @returns the current input manager
  113559. */
  113560. addVRDeviceOrientation(): FollowCameraInputsManager;
  113561. }
  113562. }
  113563. declare module BABYLON {
  113564. /**
  113565. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113566. * an arc rotate version arcFollowCamera are available.
  113567. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113568. */
  113569. export class FollowCamera extends TargetCamera {
  113570. /**
  113571. * Distance the follow camera should follow an object at
  113572. */
  113573. radius: number;
  113574. /**
  113575. * Minimum allowed distance of the camera to the axis of rotation
  113576. * (The camera can not get closer).
  113577. * This can help limiting how the Camera is able to move in the scene.
  113578. */
  113579. lowerRadiusLimit: Nullable<number>;
  113580. /**
  113581. * Maximum allowed distance of the camera to the axis of rotation
  113582. * (The camera can not get further).
  113583. * This can help limiting how the Camera is able to move in the scene.
  113584. */
  113585. upperRadiusLimit: Nullable<number>;
  113586. /**
  113587. * Define a rotation offset between the camera and the object it follows
  113588. */
  113589. rotationOffset: number;
  113590. /**
  113591. * Minimum allowed angle to camera position relative to target object.
  113592. * This can help limiting how the Camera is able to move in the scene.
  113593. */
  113594. lowerRotationOffsetLimit: Nullable<number>;
  113595. /**
  113596. * Maximum allowed angle to camera position relative to target object.
  113597. * This can help limiting how the Camera is able to move in the scene.
  113598. */
  113599. upperRotationOffsetLimit: Nullable<number>;
  113600. /**
  113601. * Define a height offset between the camera and the object it follows.
  113602. * It can help following an object from the top (like a car chaing a plane)
  113603. */
  113604. heightOffset: number;
  113605. /**
  113606. * Minimum allowed height of camera position relative to target object.
  113607. * This can help limiting how the Camera is able to move in the scene.
  113608. */
  113609. lowerHeightOffsetLimit: Nullable<number>;
  113610. /**
  113611. * Maximum allowed height of camera position relative to target object.
  113612. * This can help limiting how the Camera is able to move in the scene.
  113613. */
  113614. upperHeightOffsetLimit: Nullable<number>;
  113615. /**
  113616. * Define how fast the camera can accelerate to follow it s target.
  113617. */
  113618. cameraAcceleration: number;
  113619. /**
  113620. * Define the speed limit of the camera following an object.
  113621. */
  113622. maxCameraSpeed: number;
  113623. /**
  113624. * Define the target of the camera.
  113625. */
  113626. lockedTarget: Nullable<AbstractMesh>;
  113627. /**
  113628. * Defines the input associated with the camera.
  113629. */
  113630. inputs: FollowCameraInputsManager;
  113631. /**
  113632. * Instantiates the follow camera.
  113633. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113634. * @param name Define the name of the camera in the scene
  113635. * @param position Define the position of the camera
  113636. * @param scene Define the scene the camera belong to
  113637. * @param lockedTarget Define the target of the camera
  113638. */
  113639. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113640. private _follow;
  113641. /**
  113642. * Attached controls to the current camera.
  113643. * @param element Defines the element the controls should be listened from
  113644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113645. */
  113646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113647. /**
  113648. * Detach the current controls from the camera.
  113649. * The camera will stop reacting to inputs.
  113650. * @param element Defines the element to stop listening the inputs from
  113651. */
  113652. detachControl(element: HTMLElement): void;
  113653. /** @hidden */
  113654. _checkInputs(): void;
  113655. private _checkLimits;
  113656. /**
  113657. * Gets the camera class name.
  113658. * @returns the class name
  113659. */
  113660. getClassName(): string;
  113661. }
  113662. /**
  113663. * Arc Rotate version of the follow camera.
  113664. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113665. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113666. */
  113667. export class ArcFollowCamera extends TargetCamera {
  113668. /** The longitudinal angle of the camera */
  113669. alpha: number;
  113670. /** The latitudinal angle of the camera */
  113671. beta: number;
  113672. /** The radius of the camera from its target */
  113673. radius: number;
  113674. /** Define the camera target (the messh it should follow) */
  113675. target: Nullable<AbstractMesh>;
  113676. private _cartesianCoordinates;
  113677. /**
  113678. * Instantiates a new ArcFollowCamera
  113679. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113680. * @param name Define the name of the camera
  113681. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113682. * @param beta Define the rotation angle of the camera around the elevation axis
  113683. * @param radius Define the radius of the camera from its target point
  113684. * @param target Define the target of the camera
  113685. * @param scene Define the scene the camera belongs to
  113686. */
  113687. constructor(name: string,
  113688. /** The longitudinal angle of the camera */
  113689. alpha: number,
  113690. /** The latitudinal angle of the camera */
  113691. beta: number,
  113692. /** The radius of the camera from its target */
  113693. radius: number,
  113694. /** Define the camera target (the messh it should follow) */
  113695. target: Nullable<AbstractMesh>, scene: Scene);
  113696. private _follow;
  113697. /** @hidden */
  113698. _checkInputs(): void;
  113699. /**
  113700. * Returns the class name of the object.
  113701. * It is mostly used internally for serialization purposes.
  113702. */
  113703. getClassName(): string;
  113704. }
  113705. }
  113706. declare module BABYLON {
  113707. /**
  113708. * Manage the keyboard inputs to control the movement of a follow camera.
  113709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113710. */
  113711. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113712. /**
  113713. * Defines the camera the input is attached to.
  113714. */
  113715. camera: FollowCamera;
  113716. /**
  113717. * Defines the list of key codes associated with the up action (increase heightOffset)
  113718. */
  113719. keysHeightOffsetIncr: number[];
  113720. /**
  113721. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113722. */
  113723. keysHeightOffsetDecr: number[];
  113724. /**
  113725. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113726. */
  113727. keysHeightOffsetModifierAlt: boolean;
  113728. /**
  113729. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113730. */
  113731. keysHeightOffsetModifierCtrl: boolean;
  113732. /**
  113733. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113734. */
  113735. keysHeightOffsetModifierShift: boolean;
  113736. /**
  113737. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113738. */
  113739. keysRotationOffsetIncr: number[];
  113740. /**
  113741. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113742. */
  113743. keysRotationOffsetDecr: number[];
  113744. /**
  113745. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113746. */
  113747. keysRotationOffsetModifierAlt: boolean;
  113748. /**
  113749. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113750. */
  113751. keysRotationOffsetModifierCtrl: boolean;
  113752. /**
  113753. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113754. */
  113755. keysRotationOffsetModifierShift: boolean;
  113756. /**
  113757. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113758. */
  113759. keysRadiusIncr: number[];
  113760. /**
  113761. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113762. */
  113763. keysRadiusDecr: number[];
  113764. /**
  113765. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113766. */
  113767. keysRadiusModifierAlt: boolean;
  113768. /**
  113769. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113770. */
  113771. keysRadiusModifierCtrl: boolean;
  113772. /**
  113773. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113774. */
  113775. keysRadiusModifierShift: boolean;
  113776. /**
  113777. * Defines the rate of change of heightOffset.
  113778. */
  113779. heightSensibility: number;
  113780. /**
  113781. * Defines the rate of change of rotationOffset.
  113782. */
  113783. rotationSensibility: number;
  113784. /**
  113785. * Defines the rate of change of radius.
  113786. */
  113787. radiusSensibility: number;
  113788. private _keys;
  113789. private _ctrlPressed;
  113790. private _altPressed;
  113791. private _shiftPressed;
  113792. private _onCanvasBlurObserver;
  113793. private _onKeyboardObserver;
  113794. private _engine;
  113795. private _scene;
  113796. /**
  113797. * Attach the input controls to a specific dom element to get the input from.
  113798. * @param element Defines the element the controls should be listened from
  113799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113800. */
  113801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113802. /**
  113803. * Detach the current controls from the specified dom element.
  113804. * @param element Defines the element to stop listening the inputs from
  113805. */
  113806. detachControl(element: Nullable<HTMLElement>): void;
  113807. /**
  113808. * Update the current camera state depending on the inputs that have been used this frame.
  113809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113810. */
  113811. checkInputs(): void;
  113812. /**
  113813. * Gets the class name of the current input.
  113814. * @returns the class name
  113815. */
  113816. getClassName(): string;
  113817. /**
  113818. * Get the friendly name associated with the input class.
  113819. * @returns the input friendly name
  113820. */
  113821. getSimpleName(): string;
  113822. /**
  113823. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113824. * allow modification of the heightOffset value.
  113825. */
  113826. private _modifierHeightOffset;
  113827. /**
  113828. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113829. * allow modification of the rotationOffset value.
  113830. */
  113831. private _modifierRotationOffset;
  113832. /**
  113833. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113834. * allow modification of the radius value.
  113835. */
  113836. private _modifierRadius;
  113837. }
  113838. }
  113839. declare module BABYLON {
  113840. interface FreeCameraInputsManager {
  113841. /**
  113842. * @hidden
  113843. */
  113844. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113845. /**
  113846. * Add orientation input support to the input manager.
  113847. * @returns the current input manager
  113848. */
  113849. addDeviceOrientation(): FreeCameraInputsManager;
  113850. }
  113851. /**
  113852. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113853. * Screen rotation is taken into account.
  113854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113855. */
  113856. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113857. private _camera;
  113858. private _screenOrientationAngle;
  113859. private _constantTranform;
  113860. private _screenQuaternion;
  113861. private _alpha;
  113862. private _beta;
  113863. private _gamma;
  113864. /**
  113865. * Can be used to detect if a device orientation sensor is available on a device
  113866. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113867. * @returns a promise that will resolve on orientation change
  113868. */
  113869. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113870. /**
  113871. * @hidden
  113872. */
  113873. _onDeviceOrientationChangedObservable: Observable<void>;
  113874. /**
  113875. * Instantiates a new input
  113876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113877. */
  113878. constructor();
  113879. /**
  113880. * Define the camera controlled by the input.
  113881. */
  113882. get camera(): FreeCamera;
  113883. set camera(camera: FreeCamera);
  113884. /**
  113885. * Attach the input controls to a specific dom element to get the input from.
  113886. * @param element Defines the element the controls should be listened from
  113887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113888. */
  113889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113890. private _orientationChanged;
  113891. private _deviceOrientation;
  113892. /**
  113893. * Detach the current controls from the specified dom element.
  113894. * @param element Defines the element to stop listening the inputs from
  113895. */
  113896. detachControl(element: Nullable<HTMLElement>): void;
  113897. /**
  113898. * Update the current camera state depending on the inputs that have been used this frame.
  113899. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113900. */
  113901. checkInputs(): void;
  113902. /**
  113903. * Gets the class name of the current intput.
  113904. * @returns the class name
  113905. */
  113906. getClassName(): string;
  113907. /**
  113908. * Get the friendly name associated with the input class.
  113909. * @returns the input friendly name
  113910. */
  113911. getSimpleName(): string;
  113912. }
  113913. }
  113914. declare module BABYLON {
  113915. /**
  113916. * Manage the gamepad inputs to control a free camera.
  113917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113918. */
  113919. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113920. /**
  113921. * Define the camera the input is attached to.
  113922. */
  113923. camera: FreeCamera;
  113924. /**
  113925. * Define the Gamepad controlling the input
  113926. */
  113927. gamepad: Nullable<Gamepad>;
  113928. /**
  113929. * Defines the gamepad rotation sensiblity.
  113930. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113931. */
  113932. gamepadAngularSensibility: number;
  113933. /**
  113934. * Defines the gamepad move sensiblity.
  113935. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113936. */
  113937. gamepadMoveSensibility: number;
  113938. private _yAxisScale;
  113939. /**
  113940. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113941. */
  113942. get invertYAxis(): boolean;
  113943. set invertYAxis(value: boolean);
  113944. private _onGamepadConnectedObserver;
  113945. private _onGamepadDisconnectedObserver;
  113946. private _cameraTransform;
  113947. private _deltaTransform;
  113948. private _vector3;
  113949. private _vector2;
  113950. /**
  113951. * Attach the input controls to a specific dom element to get the input from.
  113952. * @param element Defines the element the controls should be listened from
  113953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113954. */
  113955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113956. /**
  113957. * Detach the current controls from the specified dom element.
  113958. * @param element Defines the element to stop listening the inputs from
  113959. */
  113960. detachControl(element: Nullable<HTMLElement>): void;
  113961. /**
  113962. * Update the current camera state depending on the inputs that have been used this frame.
  113963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113964. */
  113965. checkInputs(): void;
  113966. /**
  113967. * Gets the class name of the current intput.
  113968. * @returns the class name
  113969. */
  113970. getClassName(): string;
  113971. /**
  113972. * Get the friendly name associated with the input class.
  113973. * @returns the input friendly name
  113974. */
  113975. getSimpleName(): string;
  113976. }
  113977. }
  113978. declare module BABYLON {
  113979. /**
  113980. * Defines the potential axis of a Joystick
  113981. */
  113982. export enum JoystickAxis {
  113983. /** X axis */
  113984. X = 0,
  113985. /** Y axis */
  113986. Y = 1,
  113987. /** Z axis */
  113988. Z = 2
  113989. }
  113990. /**
  113991. * Class used to define virtual joystick (used in touch mode)
  113992. */
  113993. export class VirtualJoystick {
  113994. /**
  113995. * Gets or sets a boolean indicating that left and right values must be inverted
  113996. */
  113997. reverseLeftRight: boolean;
  113998. /**
  113999. * Gets or sets a boolean indicating that up and down values must be inverted
  114000. */
  114001. reverseUpDown: boolean;
  114002. /**
  114003. * Gets the offset value for the position (ie. the change of the position value)
  114004. */
  114005. deltaPosition: Vector3;
  114006. /**
  114007. * Gets a boolean indicating if the virtual joystick was pressed
  114008. */
  114009. pressed: boolean;
  114010. /**
  114011. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114012. */
  114013. static Canvas: Nullable<HTMLCanvasElement>;
  114014. private static _globalJoystickIndex;
  114015. private static vjCanvasContext;
  114016. private static vjCanvasWidth;
  114017. private static vjCanvasHeight;
  114018. private static halfWidth;
  114019. private _action;
  114020. private _axisTargetedByLeftAndRight;
  114021. private _axisTargetedByUpAndDown;
  114022. private _joystickSensibility;
  114023. private _inversedSensibility;
  114024. private _joystickPointerID;
  114025. private _joystickColor;
  114026. private _joystickPointerPos;
  114027. private _joystickPreviousPointerPos;
  114028. private _joystickPointerStartPos;
  114029. private _deltaJoystickVector;
  114030. private _leftJoystick;
  114031. private _touches;
  114032. private _onPointerDownHandlerRef;
  114033. private _onPointerMoveHandlerRef;
  114034. private _onPointerUpHandlerRef;
  114035. private _onResize;
  114036. /**
  114037. * Creates a new virtual joystick
  114038. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114039. */
  114040. constructor(leftJoystick?: boolean);
  114041. /**
  114042. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114043. * @param newJoystickSensibility defines the new sensibility
  114044. */
  114045. setJoystickSensibility(newJoystickSensibility: number): void;
  114046. private _onPointerDown;
  114047. private _onPointerMove;
  114048. private _onPointerUp;
  114049. /**
  114050. * Change the color of the virtual joystick
  114051. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114052. */
  114053. setJoystickColor(newColor: string): void;
  114054. /**
  114055. * Defines a callback to call when the joystick is touched
  114056. * @param action defines the callback
  114057. */
  114058. setActionOnTouch(action: () => any): void;
  114059. /**
  114060. * Defines which axis you'd like to control for left & right
  114061. * @param axis defines the axis to use
  114062. */
  114063. setAxisForLeftRight(axis: JoystickAxis): void;
  114064. /**
  114065. * Defines which axis you'd like to control for up & down
  114066. * @param axis defines the axis to use
  114067. */
  114068. setAxisForUpDown(axis: JoystickAxis): void;
  114069. private _drawVirtualJoystick;
  114070. /**
  114071. * Release internal HTML canvas
  114072. */
  114073. releaseCanvas(): void;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. interface FreeCameraInputsManager {
  114078. /**
  114079. * Add virtual joystick input support to the input manager.
  114080. * @returns the current input manager
  114081. */
  114082. addVirtualJoystick(): FreeCameraInputsManager;
  114083. }
  114084. /**
  114085. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114086. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114087. */
  114088. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114089. /**
  114090. * Defines the camera the input is attached to.
  114091. */
  114092. camera: FreeCamera;
  114093. private _leftjoystick;
  114094. private _rightjoystick;
  114095. /**
  114096. * Gets the left stick of the virtual joystick.
  114097. * @returns The virtual Joystick
  114098. */
  114099. getLeftJoystick(): VirtualJoystick;
  114100. /**
  114101. * Gets the right stick of the virtual joystick.
  114102. * @returns The virtual Joystick
  114103. */
  114104. getRightJoystick(): VirtualJoystick;
  114105. /**
  114106. * Update the current camera state depending on the inputs that have been used this frame.
  114107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114108. */
  114109. checkInputs(): void;
  114110. /**
  114111. * Attach the input controls to a specific dom element to get the input from.
  114112. * @param element Defines the element the controls should be listened from
  114113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114114. */
  114115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114116. /**
  114117. * Detach the current controls from the specified dom element.
  114118. * @param element Defines the element to stop listening the inputs from
  114119. */
  114120. detachControl(element: Nullable<HTMLElement>): void;
  114121. /**
  114122. * Gets the class name of the current intput.
  114123. * @returns the class name
  114124. */
  114125. getClassName(): string;
  114126. /**
  114127. * Get the friendly name associated with the input class.
  114128. * @returns the input friendly name
  114129. */
  114130. getSimpleName(): string;
  114131. }
  114132. }
  114133. declare module BABYLON {
  114134. /**
  114135. * This represents a FPS type of camera controlled by touch.
  114136. * This is like a universal camera minus the Gamepad controls.
  114137. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114138. */
  114139. export class TouchCamera extends FreeCamera {
  114140. /**
  114141. * Defines the touch sensibility for rotation.
  114142. * The higher the faster.
  114143. */
  114144. get touchAngularSensibility(): number;
  114145. set touchAngularSensibility(value: number);
  114146. /**
  114147. * Defines the touch sensibility for move.
  114148. * The higher the faster.
  114149. */
  114150. get touchMoveSensibility(): number;
  114151. set touchMoveSensibility(value: number);
  114152. /**
  114153. * Instantiates a new touch camera.
  114154. * This represents a FPS type of camera controlled by touch.
  114155. * This is like a universal camera minus the Gamepad controls.
  114156. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114157. * @param name Define the name of the camera in the scene
  114158. * @param position Define the start position of the camera in the scene
  114159. * @param scene Define the scene the camera belongs to
  114160. */
  114161. constructor(name: string, position: Vector3, scene: Scene);
  114162. /**
  114163. * Gets the current object class name.
  114164. * @return the class name
  114165. */
  114166. getClassName(): string;
  114167. /** @hidden */
  114168. _setupInputs(): void;
  114169. }
  114170. }
  114171. declare module BABYLON {
  114172. /**
  114173. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114174. * being tilted forward or back and left or right.
  114175. */
  114176. export class DeviceOrientationCamera extends FreeCamera {
  114177. private _initialQuaternion;
  114178. private _quaternionCache;
  114179. private _tmpDragQuaternion;
  114180. private _disablePointerInputWhenUsingDeviceOrientation;
  114181. /**
  114182. * Creates a new device orientation camera
  114183. * @param name The name of the camera
  114184. * @param position The start position camera
  114185. * @param scene The scene the camera belongs to
  114186. */
  114187. constructor(name: string, position: Vector3, scene: Scene);
  114188. /**
  114189. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114190. */
  114191. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114192. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114193. private _dragFactor;
  114194. /**
  114195. * Enabled turning on the y axis when the orientation sensor is active
  114196. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114197. */
  114198. enableHorizontalDragging(dragFactor?: number): void;
  114199. /**
  114200. * Gets the current instance class name ("DeviceOrientationCamera").
  114201. * This helps avoiding instanceof at run time.
  114202. * @returns the class name
  114203. */
  114204. getClassName(): string;
  114205. /**
  114206. * @hidden
  114207. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114208. */
  114209. _checkInputs(): void;
  114210. /**
  114211. * Reset the camera to its default orientation on the specified axis only.
  114212. * @param axis The axis to reset
  114213. */
  114214. resetToCurrentRotation(axis?: Axis): void;
  114215. }
  114216. }
  114217. declare module BABYLON {
  114218. /**
  114219. * Defines supported buttons for XBox360 compatible gamepads
  114220. */
  114221. export enum Xbox360Button {
  114222. /** A */
  114223. A = 0,
  114224. /** B */
  114225. B = 1,
  114226. /** X */
  114227. X = 2,
  114228. /** Y */
  114229. Y = 3,
  114230. /** Start */
  114231. Start = 4,
  114232. /** Back */
  114233. Back = 5,
  114234. /** Left button */
  114235. LB = 6,
  114236. /** Right button */
  114237. RB = 7,
  114238. /** Left stick */
  114239. LeftStick = 8,
  114240. /** Right stick */
  114241. RightStick = 9
  114242. }
  114243. /** Defines values for XBox360 DPad */
  114244. export enum Xbox360Dpad {
  114245. /** Up */
  114246. Up = 0,
  114247. /** Down */
  114248. Down = 1,
  114249. /** Left */
  114250. Left = 2,
  114251. /** Right */
  114252. Right = 3
  114253. }
  114254. /**
  114255. * Defines a XBox360 gamepad
  114256. */
  114257. export class Xbox360Pad extends Gamepad {
  114258. private _leftTrigger;
  114259. private _rightTrigger;
  114260. private _onlefttriggerchanged;
  114261. private _onrighttriggerchanged;
  114262. private _onbuttondown;
  114263. private _onbuttonup;
  114264. private _ondpaddown;
  114265. private _ondpadup;
  114266. /** Observable raised when a button is pressed */
  114267. onButtonDownObservable: Observable<Xbox360Button>;
  114268. /** Observable raised when a button is released */
  114269. onButtonUpObservable: Observable<Xbox360Button>;
  114270. /** Observable raised when a pad is pressed */
  114271. onPadDownObservable: Observable<Xbox360Dpad>;
  114272. /** Observable raised when a pad is released */
  114273. onPadUpObservable: Observable<Xbox360Dpad>;
  114274. private _buttonA;
  114275. private _buttonB;
  114276. private _buttonX;
  114277. private _buttonY;
  114278. private _buttonBack;
  114279. private _buttonStart;
  114280. private _buttonLB;
  114281. private _buttonRB;
  114282. private _buttonLeftStick;
  114283. private _buttonRightStick;
  114284. private _dPadUp;
  114285. private _dPadDown;
  114286. private _dPadLeft;
  114287. private _dPadRight;
  114288. private _isXboxOnePad;
  114289. /**
  114290. * Creates a new XBox360 gamepad object
  114291. * @param id defines the id of this gamepad
  114292. * @param index defines its index
  114293. * @param gamepad defines the internal HTML gamepad object
  114294. * @param xboxOne defines if it is a XBox One gamepad
  114295. */
  114296. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114297. /**
  114298. * Defines the callback to call when left trigger is pressed
  114299. * @param callback defines the callback to use
  114300. */
  114301. onlefttriggerchanged(callback: (value: number) => void): void;
  114302. /**
  114303. * Defines the callback to call when right trigger is pressed
  114304. * @param callback defines the callback to use
  114305. */
  114306. onrighttriggerchanged(callback: (value: number) => void): void;
  114307. /**
  114308. * Gets the left trigger value
  114309. */
  114310. get leftTrigger(): number;
  114311. /**
  114312. * Sets the left trigger value
  114313. */
  114314. set leftTrigger(newValue: number);
  114315. /**
  114316. * Gets the right trigger value
  114317. */
  114318. get rightTrigger(): number;
  114319. /**
  114320. * Sets the right trigger value
  114321. */
  114322. set rightTrigger(newValue: number);
  114323. /**
  114324. * Defines the callback to call when a button is pressed
  114325. * @param callback defines the callback to use
  114326. */
  114327. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114328. /**
  114329. * Defines the callback to call when a button is released
  114330. * @param callback defines the callback to use
  114331. */
  114332. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114333. /**
  114334. * Defines the callback to call when a pad is pressed
  114335. * @param callback defines the callback to use
  114336. */
  114337. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114338. /**
  114339. * Defines the callback to call when a pad is released
  114340. * @param callback defines the callback to use
  114341. */
  114342. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114343. private _setButtonValue;
  114344. private _setDPadValue;
  114345. /**
  114346. * Gets the value of the `A` button
  114347. */
  114348. get buttonA(): number;
  114349. /**
  114350. * Sets the value of the `A` button
  114351. */
  114352. set buttonA(value: number);
  114353. /**
  114354. * Gets the value of the `B` button
  114355. */
  114356. get buttonB(): number;
  114357. /**
  114358. * Sets the value of the `B` button
  114359. */
  114360. set buttonB(value: number);
  114361. /**
  114362. * Gets the value of the `X` button
  114363. */
  114364. get buttonX(): number;
  114365. /**
  114366. * Sets the value of the `X` button
  114367. */
  114368. set buttonX(value: number);
  114369. /**
  114370. * Gets the value of the `Y` button
  114371. */
  114372. get buttonY(): number;
  114373. /**
  114374. * Sets the value of the `Y` button
  114375. */
  114376. set buttonY(value: number);
  114377. /**
  114378. * Gets the value of the `Start` button
  114379. */
  114380. get buttonStart(): number;
  114381. /**
  114382. * Sets the value of the `Start` button
  114383. */
  114384. set buttonStart(value: number);
  114385. /**
  114386. * Gets the value of the `Back` button
  114387. */
  114388. get buttonBack(): number;
  114389. /**
  114390. * Sets the value of the `Back` button
  114391. */
  114392. set buttonBack(value: number);
  114393. /**
  114394. * Gets the value of the `Left` button
  114395. */
  114396. get buttonLB(): number;
  114397. /**
  114398. * Sets the value of the `Left` button
  114399. */
  114400. set buttonLB(value: number);
  114401. /**
  114402. * Gets the value of the `Right` button
  114403. */
  114404. get buttonRB(): number;
  114405. /**
  114406. * Sets the value of the `Right` button
  114407. */
  114408. set buttonRB(value: number);
  114409. /**
  114410. * Gets the value of the Left joystick
  114411. */
  114412. get buttonLeftStick(): number;
  114413. /**
  114414. * Sets the value of the Left joystick
  114415. */
  114416. set buttonLeftStick(value: number);
  114417. /**
  114418. * Gets the value of the Right joystick
  114419. */
  114420. get buttonRightStick(): number;
  114421. /**
  114422. * Sets the value of the Right joystick
  114423. */
  114424. set buttonRightStick(value: number);
  114425. /**
  114426. * Gets the value of D-pad up
  114427. */
  114428. get dPadUp(): number;
  114429. /**
  114430. * Sets the value of D-pad up
  114431. */
  114432. set dPadUp(value: number);
  114433. /**
  114434. * Gets the value of D-pad down
  114435. */
  114436. get dPadDown(): number;
  114437. /**
  114438. * Sets the value of D-pad down
  114439. */
  114440. set dPadDown(value: number);
  114441. /**
  114442. * Gets the value of D-pad left
  114443. */
  114444. get dPadLeft(): number;
  114445. /**
  114446. * Sets the value of D-pad left
  114447. */
  114448. set dPadLeft(value: number);
  114449. /**
  114450. * Gets the value of D-pad right
  114451. */
  114452. get dPadRight(): number;
  114453. /**
  114454. * Sets the value of D-pad right
  114455. */
  114456. set dPadRight(value: number);
  114457. /**
  114458. * Force the gamepad to synchronize with device values
  114459. */
  114460. update(): void;
  114461. /**
  114462. * Disposes the gamepad
  114463. */
  114464. dispose(): void;
  114465. }
  114466. }
  114467. declare module BABYLON {
  114468. /**
  114469. * Defines supported buttons for DualShock compatible gamepads
  114470. */
  114471. export enum DualShockButton {
  114472. /** Cross */
  114473. Cross = 0,
  114474. /** Circle */
  114475. Circle = 1,
  114476. /** Square */
  114477. Square = 2,
  114478. /** Triangle */
  114479. Triangle = 3,
  114480. /** Options */
  114481. Options = 4,
  114482. /** Share */
  114483. Share = 5,
  114484. /** L1 */
  114485. L1 = 6,
  114486. /** R1 */
  114487. R1 = 7,
  114488. /** Left stick */
  114489. LeftStick = 8,
  114490. /** Right stick */
  114491. RightStick = 9
  114492. }
  114493. /** Defines values for DualShock DPad */
  114494. export enum DualShockDpad {
  114495. /** Up */
  114496. Up = 0,
  114497. /** Down */
  114498. Down = 1,
  114499. /** Left */
  114500. Left = 2,
  114501. /** Right */
  114502. Right = 3
  114503. }
  114504. /**
  114505. * Defines a DualShock gamepad
  114506. */
  114507. export class DualShockPad extends Gamepad {
  114508. private _leftTrigger;
  114509. private _rightTrigger;
  114510. private _onlefttriggerchanged;
  114511. private _onrighttriggerchanged;
  114512. private _onbuttondown;
  114513. private _onbuttonup;
  114514. private _ondpaddown;
  114515. private _ondpadup;
  114516. /** Observable raised when a button is pressed */
  114517. onButtonDownObservable: Observable<DualShockButton>;
  114518. /** Observable raised when a button is released */
  114519. onButtonUpObservable: Observable<DualShockButton>;
  114520. /** Observable raised when a pad is pressed */
  114521. onPadDownObservable: Observable<DualShockDpad>;
  114522. /** Observable raised when a pad is released */
  114523. onPadUpObservable: Observable<DualShockDpad>;
  114524. private _buttonCross;
  114525. private _buttonCircle;
  114526. private _buttonSquare;
  114527. private _buttonTriangle;
  114528. private _buttonShare;
  114529. private _buttonOptions;
  114530. private _buttonL1;
  114531. private _buttonR1;
  114532. private _buttonLeftStick;
  114533. private _buttonRightStick;
  114534. private _dPadUp;
  114535. private _dPadDown;
  114536. private _dPadLeft;
  114537. private _dPadRight;
  114538. /**
  114539. * Creates a new DualShock gamepad object
  114540. * @param id defines the id of this gamepad
  114541. * @param index defines its index
  114542. * @param gamepad defines the internal HTML gamepad object
  114543. */
  114544. constructor(id: string, index: number, gamepad: any);
  114545. /**
  114546. * Defines the callback to call when left trigger is pressed
  114547. * @param callback defines the callback to use
  114548. */
  114549. onlefttriggerchanged(callback: (value: number) => void): void;
  114550. /**
  114551. * Defines the callback to call when right trigger is pressed
  114552. * @param callback defines the callback to use
  114553. */
  114554. onrighttriggerchanged(callback: (value: number) => void): void;
  114555. /**
  114556. * Gets the left trigger value
  114557. */
  114558. get leftTrigger(): number;
  114559. /**
  114560. * Sets the left trigger value
  114561. */
  114562. set leftTrigger(newValue: number);
  114563. /**
  114564. * Gets the right trigger value
  114565. */
  114566. get rightTrigger(): number;
  114567. /**
  114568. * Sets the right trigger value
  114569. */
  114570. set rightTrigger(newValue: number);
  114571. /**
  114572. * Defines the callback to call when a button is pressed
  114573. * @param callback defines the callback to use
  114574. */
  114575. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114576. /**
  114577. * Defines the callback to call when a button is released
  114578. * @param callback defines the callback to use
  114579. */
  114580. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114581. /**
  114582. * Defines the callback to call when a pad is pressed
  114583. * @param callback defines the callback to use
  114584. */
  114585. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114586. /**
  114587. * Defines the callback to call when a pad is released
  114588. * @param callback defines the callback to use
  114589. */
  114590. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114591. private _setButtonValue;
  114592. private _setDPadValue;
  114593. /**
  114594. * Gets the value of the `Cross` button
  114595. */
  114596. get buttonCross(): number;
  114597. /**
  114598. * Sets the value of the `Cross` button
  114599. */
  114600. set buttonCross(value: number);
  114601. /**
  114602. * Gets the value of the `Circle` button
  114603. */
  114604. get buttonCircle(): number;
  114605. /**
  114606. * Sets the value of the `Circle` button
  114607. */
  114608. set buttonCircle(value: number);
  114609. /**
  114610. * Gets the value of the `Square` button
  114611. */
  114612. get buttonSquare(): number;
  114613. /**
  114614. * Sets the value of the `Square` button
  114615. */
  114616. set buttonSquare(value: number);
  114617. /**
  114618. * Gets the value of the `Triangle` button
  114619. */
  114620. get buttonTriangle(): number;
  114621. /**
  114622. * Sets the value of the `Triangle` button
  114623. */
  114624. set buttonTriangle(value: number);
  114625. /**
  114626. * Gets the value of the `Options` button
  114627. */
  114628. get buttonOptions(): number;
  114629. /**
  114630. * Sets the value of the `Options` button
  114631. */
  114632. set buttonOptions(value: number);
  114633. /**
  114634. * Gets the value of the `Share` button
  114635. */
  114636. get buttonShare(): number;
  114637. /**
  114638. * Sets the value of the `Share` button
  114639. */
  114640. set buttonShare(value: number);
  114641. /**
  114642. * Gets the value of the `L1` button
  114643. */
  114644. get buttonL1(): number;
  114645. /**
  114646. * Sets the value of the `L1` button
  114647. */
  114648. set buttonL1(value: number);
  114649. /**
  114650. * Gets the value of the `R1` button
  114651. */
  114652. get buttonR1(): number;
  114653. /**
  114654. * Sets the value of the `R1` button
  114655. */
  114656. set buttonR1(value: number);
  114657. /**
  114658. * Gets the value of the Left joystick
  114659. */
  114660. get buttonLeftStick(): number;
  114661. /**
  114662. * Sets the value of the Left joystick
  114663. */
  114664. set buttonLeftStick(value: number);
  114665. /**
  114666. * Gets the value of the Right joystick
  114667. */
  114668. get buttonRightStick(): number;
  114669. /**
  114670. * Sets the value of the Right joystick
  114671. */
  114672. set buttonRightStick(value: number);
  114673. /**
  114674. * Gets the value of D-pad up
  114675. */
  114676. get dPadUp(): number;
  114677. /**
  114678. * Sets the value of D-pad up
  114679. */
  114680. set dPadUp(value: number);
  114681. /**
  114682. * Gets the value of D-pad down
  114683. */
  114684. get dPadDown(): number;
  114685. /**
  114686. * Sets the value of D-pad down
  114687. */
  114688. set dPadDown(value: number);
  114689. /**
  114690. * Gets the value of D-pad left
  114691. */
  114692. get dPadLeft(): number;
  114693. /**
  114694. * Sets the value of D-pad left
  114695. */
  114696. set dPadLeft(value: number);
  114697. /**
  114698. * Gets the value of D-pad right
  114699. */
  114700. get dPadRight(): number;
  114701. /**
  114702. * Sets the value of D-pad right
  114703. */
  114704. set dPadRight(value: number);
  114705. /**
  114706. * Force the gamepad to synchronize with device values
  114707. */
  114708. update(): void;
  114709. /**
  114710. * Disposes the gamepad
  114711. */
  114712. dispose(): void;
  114713. }
  114714. }
  114715. declare module BABYLON {
  114716. /**
  114717. * Manager for handling gamepads
  114718. */
  114719. export class GamepadManager {
  114720. private _scene?;
  114721. private _babylonGamepads;
  114722. private _oneGamepadConnected;
  114723. /** @hidden */
  114724. _isMonitoring: boolean;
  114725. private _gamepadEventSupported;
  114726. private _gamepadSupport?;
  114727. /**
  114728. * observable to be triggered when the gamepad controller has been connected
  114729. */
  114730. onGamepadConnectedObservable: Observable<Gamepad>;
  114731. /**
  114732. * observable to be triggered when the gamepad controller has been disconnected
  114733. */
  114734. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114735. private _onGamepadConnectedEvent;
  114736. private _onGamepadDisconnectedEvent;
  114737. /**
  114738. * Initializes the gamepad manager
  114739. * @param _scene BabylonJS scene
  114740. */
  114741. constructor(_scene?: Scene | undefined);
  114742. /**
  114743. * The gamepads in the game pad manager
  114744. */
  114745. get gamepads(): Gamepad[];
  114746. /**
  114747. * Get the gamepad controllers based on type
  114748. * @param type The type of gamepad controller
  114749. * @returns Nullable gamepad
  114750. */
  114751. getGamepadByType(type?: number): Nullable<Gamepad>;
  114752. /**
  114753. * Disposes the gamepad manager
  114754. */
  114755. dispose(): void;
  114756. private _addNewGamepad;
  114757. private _startMonitoringGamepads;
  114758. private _stopMonitoringGamepads;
  114759. /** @hidden */
  114760. _checkGamepadsStatus(): void;
  114761. private _updateGamepadObjects;
  114762. }
  114763. }
  114764. declare module BABYLON {
  114765. interface Scene {
  114766. /** @hidden */
  114767. _gamepadManager: Nullable<GamepadManager>;
  114768. /**
  114769. * Gets the gamepad manager associated with the scene
  114770. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114771. */
  114772. gamepadManager: GamepadManager;
  114773. }
  114774. /**
  114775. * Interface representing a free camera inputs manager
  114776. */
  114777. interface FreeCameraInputsManager {
  114778. /**
  114779. * Adds gamepad input support to the FreeCameraInputsManager.
  114780. * @returns the FreeCameraInputsManager
  114781. */
  114782. addGamepad(): FreeCameraInputsManager;
  114783. }
  114784. /**
  114785. * Interface representing an arc rotate camera inputs manager
  114786. */
  114787. interface ArcRotateCameraInputsManager {
  114788. /**
  114789. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114790. * @returns the camera inputs manager
  114791. */
  114792. addGamepad(): ArcRotateCameraInputsManager;
  114793. }
  114794. /**
  114795. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114796. */
  114797. export class GamepadSystemSceneComponent implements ISceneComponent {
  114798. /**
  114799. * The component name helpfull to identify the component in the list of scene components.
  114800. */
  114801. readonly name: string;
  114802. /**
  114803. * The scene the component belongs to.
  114804. */
  114805. scene: Scene;
  114806. /**
  114807. * Creates a new instance of the component for the given scene
  114808. * @param scene Defines the scene to register the component in
  114809. */
  114810. constructor(scene: Scene);
  114811. /**
  114812. * Registers the component in a given scene
  114813. */
  114814. register(): void;
  114815. /**
  114816. * Rebuilds the elements related to this component in case of
  114817. * context lost for instance.
  114818. */
  114819. rebuild(): void;
  114820. /**
  114821. * Disposes the component and the associated ressources
  114822. */
  114823. dispose(): void;
  114824. private _beforeCameraUpdate;
  114825. }
  114826. }
  114827. declare module BABYLON {
  114828. /**
  114829. * 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,
  114830. * which still works and will still be found in many Playgrounds.
  114831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114832. */
  114833. export class UniversalCamera extends TouchCamera {
  114834. /**
  114835. * Defines the gamepad rotation sensiblity.
  114836. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114837. */
  114838. get gamepadAngularSensibility(): number;
  114839. set gamepadAngularSensibility(value: number);
  114840. /**
  114841. * Defines the gamepad move sensiblity.
  114842. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114843. */
  114844. get gamepadMoveSensibility(): number;
  114845. set gamepadMoveSensibility(value: number);
  114846. /**
  114847. * 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,
  114848. * which still works and will still be found in many Playgrounds.
  114849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114850. * @param name Define the name of the camera in the scene
  114851. * @param position Define the start position of the camera in the scene
  114852. * @param scene Define the scene the camera belongs to
  114853. */
  114854. constructor(name: string, position: Vector3, scene: Scene);
  114855. /**
  114856. * Gets the current object class name.
  114857. * @return the class name
  114858. */
  114859. getClassName(): string;
  114860. }
  114861. }
  114862. declare module BABYLON {
  114863. /**
  114864. * This represents a FPS type of camera. This is only here for back compat purpose.
  114865. * Please use the UniversalCamera instead as both are identical.
  114866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114867. */
  114868. export class GamepadCamera extends UniversalCamera {
  114869. /**
  114870. * Instantiates a new Gamepad Camera
  114871. * This represents a FPS type of camera. This is only here for back compat purpose.
  114872. * Please use the UniversalCamera instead as both are identical.
  114873. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114874. * @param name Define the name of the camera in the scene
  114875. * @param position Define the start position of the camera in the scene
  114876. * @param scene Define the scene the camera belongs to
  114877. */
  114878. constructor(name: string, position: Vector3, scene: Scene);
  114879. /**
  114880. * Gets the current object class name.
  114881. * @return the class name
  114882. */
  114883. getClassName(): string;
  114884. }
  114885. }
  114886. declare module BABYLON {
  114887. /** @hidden */
  114888. export var passPixelShader: {
  114889. name: string;
  114890. shader: string;
  114891. };
  114892. }
  114893. declare module BABYLON {
  114894. /** @hidden */
  114895. export var passCubePixelShader: {
  114896. name: string;
  114897. shader: string;
  114898. };
  114899. }
  114900. declare module BABYLON {
  114901. /**
  114902. * PassPostProcess which produces an output the same as it's input
  114903. */
  114904. export class PassPostProcess extends PostProcess {
  114905. /**
  114906. * Creates the PassPostProcess
  114907. * @param name The name of the effect.
  114908. * @param options The required width/height ratio to downsize to before computing the render pass.
  114909. * @param camera The camera to apply the render pass to.
  114910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114911. * @param engine The engine which the post process will be applied. (default: current engine)
  114912. * @param reusable If the post process can be reused on the same frame. (default: false)
  114913. * @param textureType The type of texture to be used when performing the post processing.
  114914. * @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)
  114915. */
  114916. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114917. }
  114918. /**
  114919. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114920. */
  114921. export class PassCubePostProcess extends PostProcess {
  114922. private _face;
  114923. /**
  114924. * Gets or sets the cube face to display.
  114925. * * 0 is +X
  114926. * * 1 is -X
  114927. * * 2 is +Y
  114928. * * 3 is -Y
  114929. * * 4 is +Z
  114930. * * 5 is -Z
  114931. */
  114932. get face(): number;
  114933. set face(value: number);
  114934. /**
  114935. * Creates the PassCubePostProcess
  114936. * @param name The name of the effect.
  114937. * @param options The required width/height ratio to downsize to before computing the render pass.
  114938. * @param camera The camera to apply the render pass to.
  114939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114940. * @param engine The engine which the post process will be applied. (default: current engine)
  114941. * @param reusable If the post process can be reused on the same frame. (default: false)
  114942. * @param textureType The type of texture to be used when performing the post processing.
  114943. * @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)
  114944. */
  114945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114946. }
  114947. }
  114948. declare module BABYLON {
  114949. /** @hidden */
  114950. export var anaglyphPixelShader: {
  114951. name: string;
  114952. shader: string;
  114953. };
  114954. }
  114955. declare module BABYLON {
  114956. /**
  114957. * Postprocess used to generate anaglyphic rendering
  114958. */
  114959. export class AnaglyphPostProcess extends PostProcess {
  114960. private _passedProcess;
  114961. /**
  114962. * Creates a new AnaglyphPostProcess
  114963. * @param name defines postprocess name
  114964. * @param options defines creation options or target ratio scale
  114965. * @param rigCameras defines cameras using this postprocess
  114966. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114967. * @param engine defines hosting engine
  114968. * @param reusable defines if the postprocess will be reused multiple times per frame
  114969. */
  114970. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114971. }
  114972. }
  114973. declare module BABYLON {
  114974. /**
  114975. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114976. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114977. */
  114978. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114979. /**
  114980. * Creates a new AnaglyphArcRotateCamera
  114981. * @param name defines camera name
  114982. * @param alpha defines alpha angle (in radians)
  114983. * @param beta defines beta angle (in radians)
  114984. * @param radius defines radius
  114985. * @param target defines camera target
  114986. * @param interaxialDistance defines distance between each color axis
  114987. * @param scene defines the hosting scene
  114988. */
  114989. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114990. /**
  114991. * Gets camera class name
  114992. * @returns AnaglyphArcRotateCamera
  114993. */
  114994. getClassName(): string;
  114995. }
  114996. }
  114997. declare module BABYLON {
  114998. /**
  114999. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115000. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115001. */
  115002. export class AnaglyphFreeCamera extends FreeCamera {
  115003. /**
  115004. * Creates a new AnaglyphFreeCamera
  115005. * @param name defines camera name
  115006. * @param position defines initial position
  115007. * @param interaxialDistance defines distance between each color axis
  115008. * @param scene defines the hosting scene
  115009. */
  115010. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115011. /**
  115012. * Gets camera class name
  115013. * @returns AnaglyphFreeCamera
  115014. */
  115015. getClassName(): string;
  115016. }
  115017. }
  115018. declare module BABYLON {
  115019. /**
  115020. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115021. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115022. */
  115023. export class AnaglyphGamepadCamera extends GamepadCamera {
  115024. /**
  115025. * Creates a new AnaglyphGamepadCamera
  115026. * @param name defines camera name
  115027. * @param position defines initial position
  115028. * @param interaxialDistance defines distance between each color axis
  115029. * @param scene defines the hosting scene
  115030. */
  115031. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115032. /**
  115033. * Gets camera class name
  115034. * @returns AnaglyphGamepadCamera
  115035. */
  115036. getClassName(): string;
  115037. }
  115038. }
  115039. declare module BABYLON {
  115040. /**
  115041. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115042. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115043. */
  115044. export class AnaglyphUniversalCamera extends UniversalCamera {
  115045. /**
  115046. * Creates a new AnaglyphUniversalCamera
  115047. * @param name defines camera name
  115048. * @param position defines initial position
  115049. * @param interaxialDistance defines distance between each color axis
  115050. * @param scene defines the hosting scene
  115051. */
  115052. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115053. /**
  115054. * Gets camera class name
  115055. * @returns AnaglyphUniversalCamera
  115056. */
  115057. getClassName(): string;
  115058. }
  115059. }
  115060. declare module BABYLON {
  115061. /** @hidden */
  115062. export var stereoscopicInterlacePixelShader: {
  115063. name: string;
  115064. shader: string;
  115065. };
  115066. }
  115067. declare module BABYLON {
  115068. /**
  115069. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115070. */
  115071. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115072. private _stepSize;
  115073. private _passedProcess;
  115074. /**
  115075. * Initializes a StereoscopicInterlacePostProcessI
  115076. * @param name The name of the effect.
  115077. * @param rigCameras The rig cameras to be appled to the post process
  115078. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115079. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115081. * @param engine The engine which the post process will be applied. (default: current engine)
  115082. * @param reusable If the post process can be reused on the same frame. (default: false)
  115083. */
  115084. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115085. }
  115086. /**
  115087. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115088. */
  115089. export class StereoscopicInterlacePostProcess extends PostProcess {
  115090. private _stepSize;
  115091. private _passedProcess;
  115092. /**
  115093. * Initializes a StereoscopicInterlacePostProcess
  115094. * @param name The name of the effect.
  115095. * @param rigCameras The rig cameras to be appled to the post process
  115096. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115098. * @param engine The engine which the post process will be applied. (default: current engine)
  115099. * @param reusable If the post process can be reused on the same frame. (default: false)
  115100. */
  115101. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115102. }
  115103. }
  115104. declare module BABYLON {
  115105. /**
  115106. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115107. * @see http://doc.babylonjs.com/features/cameras
  115108. */
  115109. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115110. /**
  115111. * Creates a new StereoscopicArcRotateCamera
  115112. * @param name defines camera name
  115113. * @param alpha defines alpha angle (in radians)
  115114. * @param beta defines beta angle (in radians)
  115115. * @param radius defines radius
  115116. * @param target defines camera target
  115117. * @param interaxialDistance defines distance between each color axis
  115118. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115119. * @param scene defines the hosting scene
  115120. */
  115121. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115122. /**
  115123. * Gets camera class name
  115124. * @returns StereoscopicArcRotateCamera
  115125. */
  115126. getClassName(): string;
  115127. }
  115128. }
  115129. declare module BABYLON {
  115130. /**
  115131. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115132. * @see http://doc.babylonjs.com/features/cameras
  115133. */
  115134. export class StereoscopicFreeCamera extends FreeCamera {
  115135. /**
  115136. * Creates a new StereoscopicFreeCamera
  115137. * @param name defines camera name
  115138. * @param position defines initial position
  115139. * @param interaxialDistance defines distance between each color axis
  115140. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115141. * @param scene defines the hosting scene
  115142. */
  115143. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115144. /**
  115145. * Gets camera class name
  115146. * @returns StereoscopicFreeCamera
  115147. */
  115148. getClassName(): string;
  115149. }
  115150. }
  115151. declare module BABYLON {
  115152. /**
  115153. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115154. * @see http://doc.babylonjs.com/features/cameras
  115155. */
  115156. export class StereoscopicGamepadCamera extends GamepadCamera {
  115157. /**
  115158. * Creates a new StereoscopicGamepadCamera
  115159. * @param name defines camera name
  115160. * @param position defines initial position
  115161. * @param interaxialDistance defines distance between each color axis
  115162. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115163. * @param scene defines the hosting scene
  115164. */
  115165. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115166. /**
  115167. * Gets camera class name
  115168. * @returns StereoscopicGamepadCamera
  115169. */
  115170. getClassName(): string;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115176. * @see http://doc.babylonjs.com/features/cameras
  115177. */
  115178. export class StereoscopicUniversalCamera extends UniversalCamera {
  115179. /**
  115180. * Creates a new StereoscopicUniversalCamera
  115181. * @param name defines camera name
  115182. * @param position defines initial position
  115183. * @param interaxialDistance defines distance between each color axis
  115184. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115185. * @param scene defines the hosting scene
  115186. */
  115187. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115188. /**
  115189. * Gets camera class name
  115190. * @returns StereoscopicUniversalCamera
  115191. */
  115192. getClassName(): string;
  115193. }
  115194. }
  115195. declare module BABYLON {
  115196. /**
  115197. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115198. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115199. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115200. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115201. */
  115202. export class VirtualJoysticksCamera extends FreeCamera {
  115203. /**
  115204. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115205. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115206. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115207. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115208. * @param name Define the name of the camera in the scene
  115209. * @param position Define the start position of the camera in the scene
  115210. * @param scene Define the scene the camera belongs to
  115211. */
  115212. constructor(name: string, position: Vector3, scene: Scene);
  115213. /**
  115214. * Gets the current object class name.
  115215. * @return the class name
  115216. */
  115217. getClassName(): string;
  115218. }
  115219. }
  115220. declare module BABYLON {
  115221. /**
  115222. * This represents all the required metrics to create a VR camera.
  115223. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115224. */
  115225. export class VRCameraMetrics {
  115226. /**
  115227. * Define the horizontal resolution off the screen.
  115228. */
  115229. hResolution: number;
  115230. /**
  115231. * Define the vertical resolution off the screen.
  115232. */
  115233. vResolution: number;
  115234. /**
  115235. * Define the horizontal screen size.
  115236. */
  115237. hScreenSize: number;
  115238. /**
  115239. * Define the vertical screen size.
  115240. */
  115241. vScreenSize: number;
  115242. /**
  115243. * Define the vertical screen center position.
  115244. */
  115245. vScreenCenter: number;
  115246. /**
  115247. * Define the distance of the eyes to the screen.
  115248. */
  115249. eyeToScreenDistance: number;
  115250. /**
  115251. * Define the distance between both lenses
  115252. */
  115253. lensSeparationDistance: number;
  115254. /**
  115255. * Define the distance between both viewer's eyes.
  115256. */
  115257. interpupillaryDistance: number;
  115258. /**
  115259. * Define the distortion factor of the VR postprocess.
  115260. * Please, touch with care.
  115261. */
  115262. distortionK: number[];
  115263. /**
  115264. * Define the chromatic aberration correction factors for the VR post process.
  115265. */
  115266. chromaAbCorrection: number[];
  115267. /**
  115268. * Define the scale factor of the post process.
  115269. * The smaller the better but the slower.
  115270. */
  115271. postProcessScaleFactor: number;
  115272. /**
  115273. * Define an offset for the lens center.
  115274. */
  115275. lensCenterOffset: number;
  115276. /**
  115277. * Define if the current vr camera should compensate the distortion of the lense or not.
  115278. */
  115279. compensateDistortion: boolean;
  115280. /**
  115281. * Defines if multiview should be enabled when rendering (Default: false)
  115282. */
  115283. multiviewEnabled: boolean;
  115284. /**
  115285. * Gets the rendering aspect ratio based on the provided resolutions.
  115286. */
  115287. get aspectRatio(): number;
  115288. /**
  115289. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115290. */
  115291. get aspectRatioFov(): number;
  115292. /**
  115293. * @hidden
  115294. */
  115295. get leftHMatrix(): Matrix;
  115296. /**
  115297. * @hidden
  115298. */
  115299. get rightHMatrix(): Matrix;
  115300. /**
  115301. * @hidden
  115302. */
  115303. get leftPreViewMatrix(): Matrix;
  115304. /**
  115305. * @hidden
  115306. */
  115307. get rightPreViewMatrix(): Matrix;
  115308. /**
  115309. * Get the default VRMetrics based on the most generic setup.
  115310. * @returns the default vr metrics
  115311. */
  115312. static GetDefault(): VRCameraMetrics;
  115313. }
  115314. }
  115315. declare module BABYLON {
  115316. /** @hidden */
  115317. export var vrDistortionCorrectionPixelShader: {
  115318. name: string;
  115319. shader: string;
  115320. };
  115321. }
  115322. declare module BABYLON {
  115323. /**
  115324. * VRDistortionCorrectionPostProcess used for mobile VR
  115325. */
  115326. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115327. private _isRightEye;
  115328. private _distortionFactors;
  115329. private _postProcessScaleFactor;
  115330. private _lensCenterOffset;
  115331. private _scaleIn;
  115332. private _scaleFactor;
  115333. private _lensCenter;
  115334. /**
  115335. * Initializes the VRDistortionCorrectionPostProcess
  115336. * @param name The name of the effect.
  115337. * @param camera The camera to apply the render pass to.
  115338. * @param isRightEye If this is for the right eye distortion
  115339. * @param vrMetrics All the required metrics for the VR camera
  115340. */
  115341. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115342. }
  115343. }
  115344. declare module BABYLON {
  115345. /**
  115346. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115347. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115348. */
  115349. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115350. /**
  115351. * Creates a new VRDeviceOrientationArcRotateCamera
  115352. * @param name defines camera name
  115353. * @param alpha defines the camera rotation along the logitudinal axis
  115354. * @param beta defines the camera rotation along the latitudinal axis
  115355. * @param radius defines the camera distance from its target
  115356. * @param target defines the camera target
  115357. * @param scene defines the scene the camera belongs to
  115358. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115359. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115360. */
  115361. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115362. /**
  115363. * Gets camera class name
  115364. * @returns VRDeviceOrientationArcRotateCamera
  115365. */
  115366. getClassName(): string;
  115367. }
  115368. }
  115369. declare module BABYLON {
  115370. /**
  115371. * Camera used to simulate VR rendering (based on FreeCamera)
  115372. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115373. */
  115374. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115375. /**
  115376. * Creates a new VRDeviceOrientationFreeCamera
  115377. * @param name defines camera name
  115378. * @param position defines the start position of the camera
  115379. * @param scene defines the scene the camera belongs to
  115380. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115381. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115382. */
  115383. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115384. /**
  115385. * Gets camera class name
  115386. * @returns VRDeviceOrientationFreeCamera
  115387. */
  115388. getClassName(): string;
  115389. }
  115390. }
  115391. declare module BABYLON {
  115392. /**
  115393. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115394. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115395. */
  115396. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115397. /**
  115398. * Creates a new VRDeviceOrientationGamepadCamera
  115399. * @param name defines camera name
  115400. * @param position defines the start position of the camera
  115401. * @param scene defines the scene the camera belongs to
  115402. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115403. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115404. */
  115405. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115406. /**
  115407. * Gets camera class name
  115408. * @returns VRDeviceOrientationGamepadCamera
  115409. */
  115410. getClassName(): string;
  115411. }
  115412. }
  115413. declare module BABYLON {
  115414. /** @hidden */
  115415. export var imageProcessingPixelShader: {
  115416. name: string;
  115417. shader: string;
  115418. };
  115419. }
  115420. declare module BABYLON {
  115421. /**
  115422. * ImageProcessingPostProcess
  115423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115424. */
  115425. export class ImageProcessingPostProcess extends PostProcess {
  115426. /**
  115427. * Default configuration related to image processing available in the PBR Material.
  115428. */
  115429. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115430. /**
  115431. * Gets the image processing configuration used either in this material.
  115432. */
  115433. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115434. /**
  115435. * Sets the Default image processing configuration used either in the this material.
  115436. *
  115437. * If sets to null, the scene one is in use.
  115438. */
  115439. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115440. /**
  115441. * Keep track of the image processing observer to allow dispose and replace.
  115442. */
  115443. private _imageProcessingObserver;
  115444. /**
  115445. * Attaches a new image processing configuration to the PBR Material.
  115446. * @param configuration
  115447. */
  115448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115449. /**
  115450. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115451. */
  115452. get colorCurves(): Nullable<ColorCurves>;
  115453. /**
  115454. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115455. */
  115456. set colorCurves(value: Nullable<ColorCurves>);
  115457. /**
  115458. * Gets wether the color curves effect is enabled.
  115459. */
  115460. get colorCurvesEnabled(): boolean;
  115461. /**
  115462. * Sets wether the color curves effect is enabled.
  115463. */
  115464. set colorCurvesEnabled(value: boolean);
  115465. /**
  115466. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115467. */
  115468. get colorGradingTexture(): Nullable<BaseTexture>;
  115469. /**
  115470. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115471. */
  115472. set colorGradingTexture(value: Nullable<BaseTexture>);
  115473. /**
  115474. * Gets wether the color grading effect is enabled.
  115475. */
  115476. get colorGradingEnabled(): boolean;
  115477. /**
  115478. * Gets wether the color grading effect is enabled.
  115479. */
  115480. set colorGradingEnabled(value: boolean);
  115481. /**
  115482. * Gets exposure used in the effect.
  115483. */
  115484. get exposure(): number;
  115485. /**
  115486. * Sets exposure used in the effect.
  115487. */
  115488. set exposure(value: number);
  115489. /**
  115490. * Gets wether tonemapping is enabled or not.
  115491. */
  115492. get toneMappingEnabled(): boolean;
  115493. /**
  115494. * Sets wether tonemapping is enabled or not
  115495. */
  115496. set toneMappingEnabled(value: boolean);
  115497. /**
  115498. * Gets the type of tone mapping effect.
  115499. */
  115500. get toneMappingType(): number;
  115501. /**
  115502. * Sets the type of tone mapping effect.
  115503. */
  115504. set toneMappingType(value: number);
  115505. /**
  115506. * Gets contrast used in the effect.
  115507. */
  115508. get contrast(): number;
  115509. /**
  115510. * Sets contrast used in the effect.
  115511. */
  115512. set contrast(value: number);
  115513. /**
  115514. * Gets Vignette stretch size.
  115515. */
  115516. get vignetteStretch(): number;
  115517. /**
  115518. * Sets Vignette stretch size.
  115519. */
  115520. set vignetteStretch(value: number);
  115521. /**
  115522. * Gets Vignette centre X Offset.
  115523. */
  115524. get vignetteCentreX(): number;
  115525. /**
  115526. * Sets Vignette centre X Offset.
  115527. */
  115528. set vignetteCentreX(value: number);
  115529. /**
  115530. * Gets Vignette centre Y Offset.
  115531. */
  115532. get vignetteCentreY(): number;
  115533. /**
  115534. * Sets Vignette centre Y Offset.
  115535. */
  115536. set vignetteCentreY(value: number);
  115537. /**
  115538. * Gets Vignette weight or intensity of the vignette effect.
  115539. */
  115540. get vignetteWeight(): number;
  115541. /**
  115542. * Sets Vignette weight or intensity of the vignette effect.
  115543. */
  115544. set vignetteWeight(value: number);
  115545. /**
  115546. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115547. * if vignetteEnabled is set to true.
  115548. */
  115549. get vignetteColor(): Color4;
  115550. /**
  115551. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115552. * if vignetteEnabled is set to true.
  115553. */
  115554. set vignetteColor(value: Color4);
  115555. /**
  115556. * Gets Camera field of view used by the Vignette effect.
  115557. */
  115558. get vignetteCameraFov(): number;
  115559. /**
  115560. * Sets Camera field of view used by the Vignette effect.
  115561. */
  115562. set vignetteCameraFov(value: number);
  115563. /**
  115564. * Gets the vignette blend mode allowing different kind of effect.
  115565. */
  115566. get vignetteBlendMode(): number;
  115567. /**
  115568. * Sets the vignette blend mode allowing different kind of effect.
  115569. */
  115570. set vignetteBlendMode(value: number);
  115571. /**
  115572. * Gets wether the vignette effect is enabled.
  115573. */
  115574. get vignetteEnabled(): boolean;
  115575. /**
  115576. * Sets wether the vignette effect is enabled.
  115577. */
  115578. set vignetteEnabled(value: boolean);
  115579. private _fromLinearSpace;
  115580. /**
  115581. * Gets wether the input of the processing is in Gamma or Linear Space.
  115582. */
  115583. get fromLinearSpace(): boolean;
  115584. /**
  115585. * Sets wether the input of the processing is in Gamma or Linear Space.
  115586. */
  115587. set fromLinearSpace(value: boolean);
  115588. /**
  115589. * Defines cache preventing GC.
  115590. */
  115591. private _defines;
  115592. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115593. /**
  115594. * "ImageProcessingPostProcess"
  115595. * @returns "ImageProcessingPostProcess"
  115596. */
  115597. getClassName(): string;
  115598. protected _updateParameters(): void;
  115599. dispose(camera?: Camera): void;
  115600. }
  115601. }
  115602. declare module BABYLON {
  115603. /**
  115604. * Class containing static functions to help procedurally build meshes
  115605. */
  115606. export class GroundBuilder {
  115607. /**
  115608. * Creates a ground mesh
  115609. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115610. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115612. * @param name defines the name of the mesh
  115613. * @param options defines the options used to create the mesh
  115614. * @param scene defines the hosting scene
  115615. * @returns the ground mesh
  115616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115617. */
  115618. static CreateGround(name: string, options: {
  115619. width?: number;
  115620. height?: number;
  115621. subdivisions?: number;
  115622. subdivisionsX?: number;
  115623. subdivisionsY?: number;
  115624. updatable?: boolean;
  115625. }, scene: any): Mesh;
  115626. /**
  115627. * Creates a tiled ground mesh
  115628. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115629. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115630. * * 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
  115631. * * 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
  115632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115633. * @param name defines the name of the mesh
  115634. * @param options defines the options used to create the mesh
  115635. * @param scene defines the hosting scene
  115636. * @returns the tiled ground mesh
  115637. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115638. */
  115639. static CreateTiledGround(name: string, options: {
  115640. xmin: number;
  115641. zmin: number;
  115642. xmax: number;
  115643. zmax: number;
  115644. subdivisions?: {
  115645. w: number;
  115646. h: number;
  115647. };
  115648. precision?: {
  115649. w: number;
  115650. h: number;
  115651. };
  115652. updatable?: boolean;
  115653. }, scene?: Nullable<Scene>): Mesh;
  115654. /**
  115655. * Creates a ground mesh from a height map
  115656. * * The parameter `url` sets the URL of the height map image resource.
  115657. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115658. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115659. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115660. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115661. * * 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.
  115662. * * 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).
  115663. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115665. * @param name defines the name of the mesh
  115666. * @param url defines the url to the height map
  115667. * @param options defines the options used to create the mesh
  115668. * @param scene defines the hosting scene
  115669. * @returns the ground mesh
  115670. * @see https://doc.babylonjs.com/babylon101/height_map
  115671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115672. */
  115673. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115674. width?: number;
  115675. height?: number;
  115676. subdivisions?: number;
  115677. minHeight?: number;
  115678. maxHeight?: number;
  115679. colorFilter?: Color3;
  115680. alphaFilter?: number;
  115681. updatable?: boolean;
  115682. onReady?: (mesh: GroundMesh) => void;
  115683. }, scene?: Nullable<Scene>): GroundMesh;
  115684. }
  115685. }
  115686. declare module BABYLON {
  115687. /**
  115688. * Class containing static functions to help procedurally build meshes
  115689. */
  115690. export class TorusBuilder {
  115691. /**
  115692. * Creates a torus mesh
  115693. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115694. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115695. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115699. * @param name defines the name of the mesh
  115700. * @param options defines the options used to create the mesh
  115701. * @param scene defines the hosting scene
  115702. * @returns the torus mesh
  115703. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115704. */
  115705. static CreateTorus(name: string, options: {
  115706. diameter?: number;
  115707. thickness?: number;
  115708. tessellation?: number;
  115709. updatable?: boolean;
  115710. sideOrientation?: number;
  115711. frontUVs?: Vector4;
  115712. backUVs?: Vector4;
  115713. }, scene: any): Mesh;
  115714. }
  115715. }
  115716. declare module BABYLON {
  115717. /**
  115718. * Class containing static functions to help procedurally build meshes
  115719. */
  115720. export class CylinderBuilder {
  115721. /**
  115722. * Creates a cylinder or a cone mesh
  115723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115725. * * 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.
  115726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115730. * * 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).
  115731. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115732. * * 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).
  115733. * * 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
  115734. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115735. * * 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
  115736. * * 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.
  115737. * * If `enclose` is false, a ring surface is one element.
  115738. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115739. * * 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
  115740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115743. * @param name defines the name of the mesh
  115744. * @param options defines the options used to create the mesh
  115745. * @param scene defines the hosting scene
  115746. * @returns the cylinder mesh
  115747. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115748. */
  115749. static CreateCylinder(name: string, options: {
  115750. height?: number;
  115751. diameterTop?: number;
  115752. diameterBottom?: number;
  115753. diameter?: number;
  115754. tessellation?: number;
  115755. subdivisions?: number;
  115756. arc?: number;
  115757. faceColors?: Color4[];
  115758. faceUV?: Vector4[];
  115759. updatable?: boolean;
  115760. hasRings?: boolean;
  115761. enclose?: boolean;
  115762. cap?: number;
  115763. sideOrientation?: number;
  115764. frontUVs?: Vector4;
  115765. backUVs?: Vector4;
  115766. }, scene: any): Mesh;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * States of the webXR experience
  115772. */
  115773. export enum WebXRState {
  115774. /**
  115775. * Transitioning to being in XR mode
  115776. */
  115777. ENTERING_XR = 0,
  115778. /**
  115779. * Transitioning to non XR mode
  115780. */
  115781. EXITING_XR = 1,
  115782. /**
  115783. * In XR mode and presenting
  115784. */
  115785. IN_XR = 2,
  115786. /**
  115787. * Not entered XR mode
  115788. */
  115789. NOT_IN_XR = 3
  115790. }
  115791. /**
  115792. * Abstraction of the XR render target
  115793. */
  115794. export interface WebXRRenderTarget extends IDisposable {
  115795. /**
  115796. * xrpresent context of the canvas which can be used to display/mirror xr content
  115797. */
  115798. canvasContext: WebGLRenderingContext;
  115799. /**
  115800. * xr layer for the canvas
  115801. */
  115802. xrLayer: Nullable<XRWebGLLayer>;
  115803. /**
  115804. * Initializes the xr layer for the session
  115805. * @param xrSession xr session
  115806. * @returns a promise that will resolve once the XR Layer has been created
  115807. */
  115808. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115809. }
  115810. }
  115811. declare module BABYLON {
  115812. /**
  115813. * COnfiguration object for WebXR output canvas
  115814. */
  115815. export class WebXRManagedOutputCanvasOptions {
  115816. /**
  115817. * Options for this XR Layer output
  115818. */
  115819. canvasOptions?: XRWebGLLayerOptions;
  115820. /**
  115821. * CSS styling for a newly created canvas (if not provided)
  115822. */
  115823. newCanvasCssStyle?: string;
  115824. /**
  115825. * An optional canvas in case you wish to create it yourself and provide it here.
  115826. * If not provided, a new canvas will be created
  115827. */
  115828. canvasElement?: HTMLCanvasElement;
  115829. /**
  115830. * Get the default values of the configuration object
  115831. * @returns default values of this configuration object
  115832. */
  115833. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115834. }
  115835. /**
  115836. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115837. */
  115838. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115839. private _options;
  115840. private _engine;
  115841. private _canvas;
  115842. /**
  115843. * Rendering context of the canvas which can be used to display/mirror xr content
  115844. */
  115845. canvasContext: WebGLRenderingContext;
  115846. /**
  115847. * xr layer for the canvas
  115848. */
  115849. xrLayer: Nullable<XRWebGLLayer>;
  115850. /**
  115851. * Initializes the xr layer for the session
  115852. * @param xrSession xr session
  115853. * @returns a promise that will resolve once the XR Layer has been created
  115854. */
  115855. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115856. /**
  115857. * Initializes the canvas to be added/removed upon entering/exiting xr
  115858. * @param _xrSessionManager The XR Session manager
  115859. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115860. */
  115861. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115862. /**
  115863. * Disposes of the object
  115864. */
  115865. dispose(): void;
  115866. private _setManagedOutputCanvas;
  115867. private _addCanvas;
  115868. private _removeCanvas;
  115869. }
  115870. }
  115871. declare module BABYLON {
  115872. /**
  115873. * Manages an XRSession to work with Babylon's engine
  115874. * @see https://doc.babylonjs.com/how_to/webxr
  115875. */
  115876. export class WebXRSessionManager implements IDisposable {
  115877. /** The scene which the session should be created for */
  115878. scene: Scene;
  115879. /**
  115880. * Fires every time a new xrFrame arrives which can be used to update the camera
  115881. */
  115882. onXRFrameObservable: Observable<XRFrame>;
  115883. /**
  115884. * Fires when the xr session is ended either by the device or manually done
  115885. */
  115886. onXRSessionEnded: Observable<any>;
  115887. /**
  115888. * Fires when the xr session is ended either by the device or manually done
  115889. */
  115890. onXRSessionInit: Observable<XRSession>;
  115891. /**
  115892. * Fires when the reference space changed
  115893. */
  115894. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115895. /**
  115896. * Underlying xr session
  115897. */
  115898. session: XRSession;
  115899. /**
  115900. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115901. * or get the offset the player is currently at.
  115902. */
  115903. viewerReferenceSpace: XRReferenceSpace;
  115904. private _referenceSpace;
  115905. /**
  115906. * The current reference space used in this session. This reference space can constantly change!
  115907. * It is mainly used to offset the camera's position.
  115908. */
  115909. get referenceSpace(): XRReferenceSpace;
  115910. /**
  115911. * Set a new reference space and triggers the observable
  115912. */
  115913. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115914. /**
  115915. * The base reference space from which the session started. good if you want to reset your
  115916. * reference space
  115917. */
  115918. baseReferenceSpace: XRReferenceSpace;
  115919. /**
  115920. * Used just in case of a failure to initialize an immersive session.
  115921. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115922. */
  115923. defaultHeightCompensation: number;
  115924. /**
  115925. * Current XR frame
  115926. */
  115927. currentFrame: Nullable<XRFrame>;
  115928. /** WebXR timestamp updated every frame */
  115929. currentTimestamp: number;
  115930. private _xrNavigator;
  115931. private baseLayer;
  115932. private _rttProvider;
  115933. private _sessionEnded;
  115934. /**
  115935. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115936. * @param scene The scene which the session should be created for
  115937. */
  115938. constructor(
  115939. /** The scene which the session should be created for */
  115940. scene: Scene);
  115941. /**
  115942. * Initializes the manager
  115943. * After initialization enterXR can be called to start an XR session
  115944. * @returns Promise which resolves after it is initialized
  115945. */
  115946. initializeAsync(): Promise<void>;
  115947. /**
  115948. * Initializes an xr session
  115949. * @param xrSessionMode mode to initialize
  115950. * @param xrSessionInit defines optional and required values to pass to the session builder
  115951. * @returns a promise which will resolve once the session has been initialized
  115952. */
  115953. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115954. /**
  115955. * Sets the reference space on the xr session
  115956. * @param referenceSpaceType space to set
  115957. * @returns a promise that will resolve once the reference space has been set
  115958. */
  115959. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115960. /**
  115961. * Resets the reference space to the one started the session
  115962. */
  115963. resetReferenceSpace(): void;
  115964. /**
  115965. * Updates the render state of the session
  115966. * @param state state to set
  115967. * @returns a promise that resolves once the render state has been updated
  115968. */
  115969. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115970. /**
  115971. * Starts rendering to the xr layer
  115972. */
  115973. runXRRenderLoop(): void;
  115974. /**
  115975. * Gets the correct render target texture to be rendered this frame for this eye
  115976. * @param eye the eye for which to get the render target
  115977. * @returns the render target for the specified eye
  115978. */
  115979. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115980. /**
  115981. * Stops the xrSession and restores the renderloop
  115982. * @returns Promise which resolves after it exits XR
  115983. */
  115984. exitXRAsync(): Promise<void>;
  115985. /**
  115986. * Checks if a session would be supported for the creation options specified
  115987. * @param sessionMode session mode to check if supported eg. immersive-vr
  115988. * @returns A Promise that resolves to true if supported and false if not
  115989. */
  115990. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115991. /**
  115992. * Creates a WebXRRenderTarget object for the XR session
  115993. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115994. * @param options optional options to provide when creating a new render target
  115995. * @returns a WebXR render target to which the session can render
  115996. */
  115997. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115998. /**
  115999. * @hidden
  116000. * Converts the render layer of xrSession to a render target
  116001. * @param session session to create render target for
  116002. * @param scene scene the new render target should be created for
  116003. * @param baseLayer the webgl layer to create the render target for
  116004. */
  116005. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  116006. /**
  116007. * Disposes of the session manager
  116008. */
  116009. dispose(): void;
  116010. /**
  116011. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116012. * @param sessionMode defines the session to test
  116013. * @returns a promise with boolean as final value
  116014. */
  116015. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116016. }
  116017. }
  116018. declare module BABYLON {
  116019. /**
  116020. * WebXR Camera which holds the views for the xrSession
  116021. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116022. */
  116023. export class WebXRCamera extends FreeCamera {
  116024. private _xrSessionManager;
  116025. private _firstFrame;
  116026. private _referenceQuaternion;
  116027. private _referencedPosition;
  116028. private _xrInvPositionCache;
  116029. private _xrInvQuaternionCache;
  116030. /**
  116031. * Should position compensation execute on first frame.
  116032. * This is used when copying the position from a native (non XR) camera
  116033. */
  116034. compensateOnFirstFrame: boolean;
  116035. /**
  116036. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116037. * @param name the name of the camera
  116038. * @param scene the scene to add the camera to
  116039. * @param _xrSessionManager a constructed xr session manager
  116040. */
  116041. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116042. /**
  116043. * Return the user's height, unrelated to the current ground.
  116044. * This will be the y position of this camera, when ground level is 0.
  116045. */
  116046. get realWorldHeight(): number;
  116047. /** @hidden */
  116048. _updateForDualEyeDebugging(): void;
  116049. /**
  116050. * Sets this camera's transformation based on a non-vr camera
  116051. * @param otherCamera the non-vr camera to copy the transformation from
  116052. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116053. */
  116054. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116055. private _updateFromXRSession;
  116056. private _updateNumberOfRigCameras;
  116057. private _updateReferenceSpace;
  116058. private _updateReferenceSpaceOffset;
  116059. }
  116060. }
  116061. declare module BABYLON {
  116062. /**
  116063. * Defining the interface required for a (webxr) feature
  116064. */
  116065. export interface IWebXRFeature extends IDisposable {
  116066. /**
  116067. * Is this feature attached
  116068. */
  116069. attached: boolean;
  116070. /**
  116071. * Should auto-attach be disabled?
  116072. */
  116073. disableAutoAttach: boolean;
  116074. /**
  116075. * Attach the feature to the session
  116076. * Will usually be called by the features manager
  116077. *
  116078. * @param force should attachment be forced (even when already attached)
  116079. * @returns true if successful.
  116080. */
  116081. attach(force?: boolean): boolean;
  116082. /**
  116083. * Detach the feature from the session
  116084. * Will usually be called by the features manager
  116085. *
  116086. * @returns true if successful.
  116087. */
  116088. detach(): boolean;
  116089. }
  116090. /**
  116091. * A list of the currently available features without referencing them
  116092. */
  116093. export class WebXRFeatureName {
  116094. /**
  116095. * The name of the hit test feature
  116096. */
  116097. static HIT_TEST: string;
  116098. /**
  116099. * The name of the anchor system feature
  116100. */
  116101. static ANCHOR_SYSTEM: string;
  116102. /**
  116103. * The name of the background remover feature
  116104. */
  116105. static BACKGROUND_REMOVER: string;
  116106. /**
  116107. * The name of the pointer selection feature
  116108. */
  116109. static POINTER_SELECTION: string;
  116110. /**
  116111. * The name of the teleportation feature
  116112. */
  116113. static TELEPORTATION: string;
  116114. /**
  116115. * The name of the plane detection feature
  116116. */
  116117. static PLANE_DETECTION: string;
  116118. /**
  116119. * physics impostors for xr controllers feature
  116120. */
  116121. static PHYSICS_CONTROLLERS: string;
  116122. }
  116123. /**
  116124. * Defining the constructor of a feature. Used to register the modules.
  116125. */
  116126. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116127. /**
  116128. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116129. * It is mainly used in AR sessions.
  116130. *
  116131. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116132. */
  116133. export class WebXRFeaturesManager implements IDisposable {
  116134. private _xrSessionManager;
  116135. private static readonly _AvailableFeatures;
  116136. /**
  116137. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116138. * Mainly used internally.
  116139. *
  116140. * @param featureName the name of the feature to register
  116141. * @param constructorFunction the function used to construct the module
  116142. * @param version the (babylon) version of the module
  116143. * @param stable is that a stable version of this module
  116144. */
  116145. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116146. /**
  116147. * Returns a constructor of a specific feature.
  116148. *
  116149. * @param featureName the name of the feature to construct
  116150. * @param version the version of the feature to load
  116151. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116152. * @param options optional options provided to the module.
  116153. * @returns a function that, when called, will return a new instance of this feature
  116154. */
  116155. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116156. /**
  116157. * Return the latest unstable version of this feature
  116158. * @param featureName the name of the feature to search
  116159. * @returns the version number. if not found will return -1
  116160. */
  116161. static GetLatestVersionOfFeature(featureName: string): number;
  116162. /**
  116163. * Return the latest stable version of this feature
  116164. * @param featureName the name of the feature to search
  116165. * @returns the version number. if not found will return -1
  116166. */
  116167. static GetStableVersionOfFeature(featureName: string): number;
  116168. /**
  116169. * Can be used to return the list of features currently registered
  116170. *
  116171. * @returns an Array of available features
  116172. */
  116173. static GetAvailableFeatures(): string[];
  116174. /**
  116175. * Gets the versions available for a specific feature
  116176. * @param featureName the name of the feature
  116177. * @returns an array with the available versions
  116178. */
  116179. static GetAvailableVersions(featureName: string): string[];
  116180. private _features;
  116181. /**
  116182. * constructs a new features manages.
  116183. *
  116184. * @param _xrSessionManager an instance of WebXRSessionManager
  116185. */
  116186. constructor(_xrSessionManager: WebXRSessionManager);
  116187. /**
  116188. * 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.
  116189. * 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.
  116190. *
  116191. * @param featureName the name of the feature to load or the class of the feature
  116192. * @param version optional version to load. if not provided the latest version will be enabled
  116193. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116194. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116195. * @returns a new constructed feature or throws an error if feature not found.
  116196. */
  116197. enableFeature(featureName: string | {
  116198. Name: string;
  116199. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116200. /**
  116201. * Used to disable an already-enabled feature
  116202. * The feature will be disposed and will be recreated once enabled.
  116203. * @param featureName the feature to disable
  116204. * @returns true if disable was successful
  116205. */
  116206. disableFeature(featureName: string | {
  116207. Name: string;
  116208. }): boolean;
  116209. /**
  116210. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116211. * Can be used during a session to start a feature
  116212. * @param featureName the name of feature to attach
  116213. */
  116214. attachFeature(featureName: string): void;
  116215. /**
  116216. * Can be used inside a session or when the session ends to detach a specific feature
  116217. * @param featureName the name of the feature to detach
  116218. */
  116219. detachFeature(featureName: string): void;
  116220. /**
  116221. * Get the list of enabled features
  116222. * @returns an array of enabled features
  116223. */
  116224. getEnabledFeatures(): string[];
  116225. /**
  116226. * get the implementation of an enabled feature.
  116227. * @param featureName the name of the feature to load
  116228. * @returns the feature class, if found
  116229. */
  116230. getEnabledFeature(featureName: string): IWebXRFeature;
  116231. /**
  116232. * dispose this features manager
  116233. */
  116234. dispose(): void;
  116235. }
  116236. }
  116237. declare module BABYLON {
  116238. /**
  116239. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116240. * @see https://doc.babylonjs.com/how_to/webxr
  116241. */
  116242. export class WebXRExperienceHelper implements IDisposable {
  116243. private scene;
  116244. /**
  116245. * Camera used to render xr content
  116246. */
  116247. camera: WebXRCamera;
  116248. /**
  116249. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116250. */
  116251. state: WebXRState;
  116252. private _setState;
  116253. /**
  116254. * Fires when the state of the experience helper has changed
  116255. */
  116256. onStateChangedObservable: Observable<WebXRState>;
  116257. /**
  116258. * Observers registered here will be triggered after the camera's initial transformation is set
  116259. * This can be used to set a different ground level or an extra rotation.
  116260. *
  116261. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116262. * to the position set after this observable is done executing.
  116263. */
  116264. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116265. /** Session manager used to keep track of xr session */
  116266. sessionManager: WebXRSessionManager;
  116267. /** A features manager for this xr session */
  116268. featuresManager: WebXRFeaturesManager;
  116269. private _nonVRCamera;
  116270. private _originalSceneAutoClear;
  116271. private _supported;
  116272. /**
  116273. * Creates the experience helper
  116274. * @param scene the scene to attach the experience helper to
  116275. * @returns a promise for the experience helper
  116276. */
  116277. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116278. /**
  116279. * Creates a WebXRExperienceHelper
  116280. * @param scene The scene the helper should be created in
  116281. */
  116282. private constructor();
  116283. /**
  116284. * Exits XR mode and returns the scene to its original state
  116285. * @returns promise that resolves after xr mode has exited
  116286. */
  116287. exitXRAsync(): Promise<void>;
  116288. /**
  116289. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116290. * @param sessionMode options for the XR session
  116291. * @param referenceSpaceType frame of reference of the XR session
  116292. * @param renderTarget the output canvas that will be used to enter XR mode
  116293. * @returns promise that resolves after xr mode has entered
  116294. */
  116295. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116296. /**
  116297. * Disposes of the experience helper
  116298. */
  116299. dispose(): void;
  116300. private _nonXRToXRCamera;
  116301. }
  116302. }
  116303. declare module BABYLON {
  116304. /**
  116305. * X-Y values for axes in WebXR
  116306. */
  116307. export interface IWebXRMotionControllerAxesValue {
  116308. /**
  116309. * The value of the x axis
  116310. */
  116311. x: number;
  116312. /**
  116313. * The value of the y-axis
  116314. */
  116315. y: number;
  116316. }
  116317. /**
  116318. * changed / previous values for the values of this component
  116319. */
  116320. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116321. /**
  116322. * current (this frame) value
  116323. */
  116324. current: T;
  116325. /**
  116326. * previous (last change) value
  116327. */
  116328. previous: T;
  116329. }
  116330. /**
  116331. * Represents changes in the component between current frame and last values recorded
  116332. */
  116333. export interface IWebXRMotionControllerComponentChanges {
  116334. /**
  116335. * will be populated with previous and current values if touched changed
  116336. */
  116337. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116338. /**
  116339. * will be populated with previous and current values if pressed changed
  116340. */
  116341. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116342. /**
  116343. * will be populated with previous and current values if value changed
  116344. */
  116345. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116346. /**
  116347. * will be populated with previous and current values if axes changed
  116348. */
  116349. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116350. }
  116351. /**
  116352. * This class represents a single component (for example button or thumbstick) of a motion controller
  116353. */
  116354. export class WebXRControllerComponent implements IDisposable {
  116355. /**
  116356. * the id of this component
  116357. */
  116358. id: string;
  116359. /**
  116360. * the type of the component
  116361. */
  116362. type: MotionControllerComponentType;
  116363. private _buttonIndex;
  116364. private _axesIndices;
  116365. /**
  116366. * Thumbstick component type
  116367. */
  116368. static THUMBSTICK: MotionControllerComponentType;
  116369. /**
  116370. * Touchpad component type
  116371. */
  116372. static TOUCHPAD: MotionControllerComponentType;
  116373. /**
  116374. * trigger component type
  116375. */
  116376. static TRIGGER: MotionControllerComponentType;
  116377. /**
  116378. * squeeze component type
  116379. */
  116380. static SQUEEZE: MotionControllerComponentType;
  116381. /**
  116382. * button component type
  116383. */
  116384. static BUTTON: MotionControllerComponentType;
  116385. /**
  116386. * Observers registered here will be triggered when the state of a button changes
  116387. * State change is either pressed / touched / value
  116388. */
  116389. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116390. /**
  116391. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116392. * the axes data changes
  116393. */
  116394. onAxisValueChangedObservable: Observable<{
  116395. x: number;
  116396. y: number;
  116397. }>;
  116398. private _currentValue;
  116399. private _touched;
  116400. private _pressed;
  116401. private _axes;
  116402. private _changes;
  116403. private _hasChanges;
  116404. /**
  116405. * Return whether or not the component changed the last frame
  116406. */
  116407. get hasChanges(): boolean;
  116408. /**
  116409. * Creates a new component for a motion controller.
  116410. * It is created by the motion controller itself
  116411. *
  116412. * @param id the id of this component
  116413. * @param type the type of the component
  116414. * @param _buttonIndex index in the buttons array of the gamepad
  116415. * @param _axesIndices indices of the values in the axes array of the gamepad
  116416. */
  116417. constructor(
  116418. /**
  116419. * the id of this component
  116420. */
  116421. id: string,
  116422. /**
  116423. * the type of the component
  116424. */
  116425. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116426. /**
  116427. * Get the current value of this component
  116428. */
  116429. get value(): number;
  116430. /**
  116431. * is the button currently pressed
  116432. */
  116433. get pressed(): boolean;
  116434. /**
  116435. * is the button currently touched
  116436. */
  116437. get touched(): boolean;
  116438. /**
  116439. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116440. */
  116441. get axes(): IWebXRMotionControllerAxesValue;
  116442. /**
  116443. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116444. */
  116445. get changes(): IWebXRMotionControllerComponentChanges;
  116446. /**
  116447. * Is this component a button (hence - pressable)
  116448. * @returns true if can be pressed
  116449. */
  116450. isButton(): boolean;
  116451. /**
  116452. * Are there axes correlating to this component
  116453. * @return true is axes data is available
  116454. */
  116455. isAxes(): boolean;
  116456. /**
  116457. * update this component using the gamepad object it is in. Called on every frame
  116458. * @param nativeController the native gamepad controller object
  116459. */
  116460. update(nativeController: IMinimalMotionControllerObject): void;
  116461. /**
  116462. * Dispose this component
  116463. */
  116464. dispose(): void;
  116465. }
  116466. }
  116467. declare module BABYLON {
  116468. /**
  116469. * Class used to represent data loading progression
  116470. */
  116471. export class SceneLoaderProgressEvent {
  116472. /** defines if data length to load can be evaluated */
  116473. readonly lengthComputable: boolean;
  116474. /** defines the loaded data length */
  116475. readonly loaded: number;
  116476. /** defines the data length to load */
  116477. readonly total: number;
  116478. /**
  116479. * Create a new progress event
  116480. * @param lengthComputable defines if data length to load can be evaluated
  116481. * @param loaded defines the loaded data length
  116482. * @param total defines the data length to load
  116483. */
  116484. constructor(
  116485. /** defines if data length to load can be evaluated */
  116486. lengthComputable: boolean,
  116487. /** defines the loaded data length */
  116488. loaded: number,
  116489. /** defines the data length to load */
  116490. total: number);
  116491. /**
  116492. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116493. * @param event defines the source event
  116494. * @returns a new SceneLoaderProgressEvent
  116495. */
  116496. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116497. }
  116498. /**
  116499. * Interface used by SceneLoader plugins to define supported file extensions
  116500. */
  116501. export interface ISceneLoaderPluginExtensions {
  116502. /**
  116503. * Defines the list of supported extensions
  116504. */
  116505. [extension: string]: {
  116506. isBinary: boolean;
  116507. };
  116508. }
  116509. /**
  116510. * Interface used by SceneLoader plugin factory
  116511. */
  116512. export interface ISceneLoaderPluginFactory {
  116513. /**
  116514. * Defines the name of the factory
  116515. */
  116516. name: string;
  116517. /**
  116518. * Function called to create a new plugin
  116519. * @return the new plugin
  116520. */
  116521. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116522. /**
  116523. * The callback that returns true if the data can be directly loaded.
  116524. * @param data string containing the file data
  116525. * @returns if the data can be loaded directly
  116526. */
  116527. canDirectLoad?(data: string): boolean;
  116528. }
  116529. /**
  116530. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116531. */
  116532. export interface ISceneLoaderPluginBase {
  116533. /**
  116534. * The friendly name of this plugin.
  116535. */
  116536. name: string;
  116537. /**
  116538. * The file extensions supported by this plugin.
  116539. */
  116540. extensions: string | ISceneLoaderPluginExtensions;
  116541. /**
  116542. * The callback called when loading from a url.
  116543. * @param scene scene loading this url
  116544. * @param url url to load
  116545. * @param onSuccess callback called when the file successfully loads
  116546. * @param onProgress callback called while file is loading (if the server supports this mode)
  116547. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116548. * @param onError callback called when the file fails to load
  116549. * @returns a file request object
  116550. */
  116551. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116552. /**
  116553. * The callback called when loading from a file object.
  116554. * @param scene scene loading this file
  116555. * @param file defines the file to load
  116556. * @param onSuccess defines the callback to call when data is loaded
  116557. * @param onProgress defines the callback to call during loading process
  116558. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116559. * @param onError defines the callback to call when an error occurs
  116560. * @returns a file request object
  116561. */
  116562. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116563. /**
  116564. * The callback that returns true if the data can be directly loaded.
  116565. * @param data string containing the file data
  116566. * @returns if the data can be loaded directly
  116567. */
  116568. canDirectLoad?(data: string): boolean;
  116569. /**
  116570. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116571. * @param scene scene loading this data
  116572. * @param data string containing the data
  116573. * @returns data to pass to the plugin
  116574. */
  116575. directLoad?(scene: Scene, data: string): any;
  116576. /**
  116577. * The callback that allows custom handling of the root url based on the response url.
  116578. * @param rootUrl the original root url
  116579. * @param responseURL the response url if available
  116580. * @returns the new root url
  116581. */
  116582. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116583. }
  116584. /**
  116585. * Interface used to define a SceneLoader plugin
  116586. */
  116587. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116588. /**
  116589. * Import meshes into a scene.
  116590. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116591. * @param scene The scene to import into
  116592. * @param data The data to import
  116593. * @param rootUrl The root url for scene and resources
  116594. * @param meshes The meshes array to import into
  116595. * @param particleSystems The particle systems array to import into
  116596. * @param skeletons The skeletons array to import into
  116597. * @param onError The callback when import fails
  116598. * @returns True if successful or false otherwise
  116599. */
  116600. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116601. /**
  116602. * Load into a scene.
  116603. * @param scene The scene to load into
  116604. * @param data The data to import
  116605. * @param rootUrl The root url for scene and resources
  116606. * @param onError The callback when import fails
  116607. * @returns True if successful or false otherwise
  116608. */
  116609. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116610. /**
  116611. * Load into an asset container.
  116612. * @param scene The scene to load into
  116613. * @param data The data to import
  116614. * @param rootUrl The root url for scene and resources
  116615. * @param onError The callback when import fails
  116616. * @returns The loaded asset container
  116617. */
  116618. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116619. }
  116620. /**
  116621. * Interface used to define an async SceneLoader plugin
  116622. */
  116623. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116624. /**
  116625. * Import meshes into a scene.
  116626. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116627. * @param scene The scene to import into
  116628. * @param data The data to import
  116629. * @param rootUrl The root url for scene and resources
  116630. * @param onProgress The callback when the load progresses
  116631. * @param fileName Defines the name of the file to load
  116632. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116633. */
  116634. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116635. meshes: AbstractMesh[];
  116636. particleSystems: IParticleSystem[];
  116637. skeletons: Skeleton[];
  116638. animationGroups: AnimationGroup[];
  116639. }>;
  116640. /**
  116641. * Load into a scene.
  116642. * @param scene The scene to load into
  116643. * @param data The data to import
  116644. * @param rootUrl The root url for scene and resources
  116645. * @param onProgress The callback when the load progresses
  116646. * @param fileName Defines the name of the file to load
  116647. * @returns Nothing
  116648. */
  116649. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116650. /**
  116651. * Load into an asset container.
  116652. * @param scene The scene to load into
  116653. * @param data The data to import
  116654. * @param rootUrl The root url for scene and resources
  116655. * @param onProgress The callback when the load progresses
  116656. * @param fileName Defines the name of the file to load
  116657. * @returns The loaded asset container
  116658. */
  116659. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116660. }
  116661. /**
  116662. * Mode that determines how to handle old animation groups before loading new ones.
  116663. */
  116664. export enum SceneLoaderAnimationGroupLoadingMode {
  116665. /**
  116666. * Reset all old animations to initial state then dispose them.
  116667. */
  116668. Clean = 0,
  116669. /**
  116670. * Stop all old animations.
  116671. */
  116672. Stop = 1,
  116673. /**
  116674. * Restart old animations from first frame.
  116675. */
  116676. Sync = 2,
  116677. /**
  116678. * Old animations remains untouched.
  116679. */
  116680. NoSync = 3
  116681. }
  116682. /**
  116683. * Class used to load scene from various file formats using registered plugins
  116684. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116685. */
  116686. export class SceneLoader {
  116687. /**
  116688. * No logging while loading
  116689. */
  116690. static readonly NO_LOGGING: number;
  116691. /**
  116692. * Minimal logging while loading
  116693. */
  116694. static readonly MINIMAL_LOGGING: number;
  116695. /**
  116696. * Summary logging while loading
  116697. */
  116698. static readonly SUMMARY_LOGGING: number;
  116699. /**
  116700. * Detailled logging while loading
  116701. */
  116702. static readonly DETAILED_LOGGING: number;
  116703. /**
  116704. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116705. */
  116706. static get ForceFullSceneLoadingForIncremental(): boolean;
  116707. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116708. /**
  116709. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116710. */
  116711. static get ShowLoadingScreen(): boolean;
  116712. static set ShowLoadingScreen(value: boolean);
  116713. /**
  116714. * Defines the current logging level (while loading the scene)
  116715. * @ignorenaming
  116716. */
  116717. static get loggingLevel(): number;
  116718. static set loggingLevel(value: number);
  116719. /**
  116720. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116721. */
  116722. static get CleanBoneMatrixWeights(): boolean;
  116723. static set CleanBoneMatrixWeights(value: boolean);
  116724. /**
  116725. * Event raised when a plugin is used to load a scene
  116726. */
  116727. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116728. private static _registeredPlugins;
  116729. private static _getDefaultPlugin;
  116730. private static _getPluginForExtension;
  116731. private static _getPluginForDirectLoad;
  116732. private static _getPluginForFilename;
  116733. private static _getDirectLoad;
  116734. private static _loadData;
  116735. private static _getFileInfo;
  116736. /**
  116737. * Gets a plugin that can load the given extension
  116738. * @param extension defines the extension to load
  116739. * @returns a plugin or null if none works
  116740. */
  116741. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116742. /**
  116743. * Gets a boolean indicating that the given extension can be loaded
  116744. * @param extension defines the extension to load
  116745. * @returns true if the extension is supported
  116746. */
  116747. static IsPluginForExtensionAvailable(extension: string): boolean;
  116748. /**
  116749. * Adds a new plugin to the list of registered plugins
  116750. * @param plugin defines the plugin to add
  116751. */
  116752. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116753. /**
  116754. * Import meshes into a scene
  116755. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116756. * @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)
  116757. * @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)
  116758. * @param scene the instance of BABYLON.Scene to append to
  116759. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116760. * @param onProgress a callback with a progress event for each file being loaded
  116761. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116762. * @param pluginExtension the extension used to determine the plugin
  116763. * @returns The loaded plugin
  116764. */
  116765. 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>;
  116766. /**
  116767. * Import meshes into a scene
  116768. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116769. * @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)
  116770. * @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)
  116771. * @param scene the instance of BABYLON.Scene to append to
  116772. * @param onProgress a callback with a progress event for each file being loaded
  116773. * @param pluginExtension the extension used to determine the plugin
  116774. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116775. */
  116776. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116777. meshes: AbstractMesh[];
  116778. particleSystems: IParticleSystem[];
  116779. skeletons: Skeleton[];
  116780. animationGroups: AnimationGroup[];
  116781. }>;
  116782. /**
  116783. * Load a scene
  116784. * @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)
  116785. * @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)
  116786. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116787. * @param onSuccess a callback with the scene when import succeeds
  116788. * @param onProgress a callback with a progress event for each file being loaded
  116789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116790. * @param pluginExtension the extension used to determine the plugin
  116791. * @returns The loaded plugin
  116792. */
  116793. 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>;
  116794. /**
  116795. * Load a scene
  116796. * @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)
  116797. * @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)
  116798. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116799. * @param onProgress a callback with a progress event for each file being loaded
  116800. * @param pluginExtension the extension used to determine the plugin
  116801. * @returns The loaded scene
  116802. */
  116803. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116804. /**
  116805. * Append a scene
  116806. * @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)
  116807. * @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)
  116808. * @param scene is the instance of BABYLON.Scene to append to
  116809. * @param onSuccess a callback with the scene when import succeeds
  116810. * @param onProgress a callback with a progress event for each file being loaded
  116811. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116812. * @param pluginExtension the extension used to determine the plugin
  116813. * @returns The loaded plugin
  116814. */
  116815. 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>;
  116816. /**
  116817. * Append a scene
  116818. * @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)
  116819. * @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)
  116820. * @param scene is the instance of BABYLON.Scene to append to
  116821. * @param onProgress a callback with a progress event for each file being loaded
  116822. * @param pluginExtension the extension used to determine the plugin
  116823. * @returns The given scene
  116824. */
  116825. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116826. /**
  116827. * Load a scene into an asset container
  116828. * @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)
  116829. * @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)
  116830. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116831. * @param onSuccess a callback with the scene when import succeeds
  116832. * @param onProgress a callback with a progress event for each file being loaded
  116833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116834. * @param pluginExtension the extension used to determine the plugin
  116835. * @returns The loaded plugin
  116836. */
  116837. 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>;
  116838. /**
  116839. * Load a scene into an asset container
  116840. * @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)
  116841. * @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)
  116842. * @param scene is the instance of Scene to append to
  116843. * @param onProgress a callback with a progress event for each file being loaded
  116844. * @param pluginExtension the extension used to determine the plugin
  116845. * @returns The loaded asset container
  116846. */
  116847. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116848. /**
  116849. * Import animations from a file into a scene
  116850. * @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)
  116851. * @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)
  116852. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116853. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116854. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116855. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116856. * @param onSuccess a callback with the scene when import succeeds
  116857. * @param onProgress a callback with a progress event for each file being loaded
  116858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116859. */
  116860. 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;
  116861. /**
  116862. * Import animations from a file into a scene
  116863. * @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)
  116864. * @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)
  116865. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116866. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116867. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116868. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116869. * @param onSuccess a callback with the scene when import succeeds
  116870. * @param onProgress a callback with a progress event for each file being loaded
  116871. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116872. * @returns the updated scene with imported animations
  116873. */
  116874. 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>;
  116875. }
  116876. }
  116877. declare module BABYLON {
  116878. /**
  116879. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116880. */
  116881. export type MotionControllerHandness = "none" | "left" | "right";
  116882. /**
  116883. * The type of components available in motion controllers.
  116884. * This is not the name of the component.
  116885. */
  116886. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116887. /**
  116888. * The state of a controller component
  116889. */
  116890. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116891. /**
  116892. * The schema of motion controller layout.
  116893. * No object will be initialized using this interface
  116894. * This is used just to define the profile.
  116895. */
  116896. export interface IMotionControllerLayout {
  116897. /**
  116898. * Defines the main button component id
  116899. */
  116900. selectComponentId: string;
  116901. /**
  116902. * Available components (unsorted)
  116903. */
  116904. components: {
  116905. /**
  116906. * A map of component Ids
  116907. */
  116908. [componentId: string]: {
  116909. /**
  116910. * The type of input the component outputs
  116911. */
  116912. type: MotionControllerComponentType;
  116913. /**
  116914. * The indices of this component in the gamepad object
  116915. */
  116916. gamepadIndices: {
  116917. /**
  116918. * Index of button
  116919. */
  116920. button?: number;
  116921. /**
  116922. * If available, index of x-axis
  116923. */
  116924. xAxis?: number;
  116925. /**
  116926. * If available, index of y-axis
  116927. */
  116928. yAxis?: number;
  116929. };
  116930. /**
  116931. * The mesh's root node name
  116932. */
  116933. rootNodeName: string;
  116934. /**
  116935. * Animation definitions for this model
  116936. */
  116937. visualResponses: {
  116938. [stateKey: string]: {
  116939. /**
  116940. * What property will be animated
  116941. */
  116942. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116943. /**
  116944. * What states influence this visual reponse
  116945. */
  116946. states: MotionControllerComponentStateType[];
  116947. /**
  116948. * Type of animation - movement or visibility
  116949. */
  116950. valueNodeProperty: "transform" | "visibility";
  116951. /**
  116952. * Base node name to move. Its position will be calculated according to the min and max nodes
  116953. */
  116954. valueNodeName?: string;
  116955. /**
  116956. * Minimum movement node
  116957. */
  116958. minNodeName?: string;
  116959. /**
  116960. * Max movement node
  116961. */
  116962. maxNodeName?: string;
  116963. };
  116964. };
  116965. /**
  116966. * If touch enabled, what is the name of node to display user feedback
  116967. */
  116968. touchPointNodeName?: string;
  116969. };
  116970. };
  116971. /**
  116972. * Is it xr standard mapping or not
  116973. */
  116974. gamepadMapping: "" | "xr-standard";
  116975. /**
  116976. * Base root node of this entire model
  116977. */
  116978. rootNodeName: string;
  116979. /**
  116980. * Path to load the assets. Usually relative to the base path
  116981. */
  116982. assetPath: string;
  116983. }
  116984. /**
  116985. * A definition for the layout map in the input profile
  116986. */
  116987. export interface IMotionControllerLayoutMap {
  116988. /**
  116989. * Layouts with handness type as a key
  116990. */
  116991. [handness: string]: IMotionControllerLayout;
  116992. }
  116993. /**
  116994. * The XR Input profile schema
  116995. * Profiles can be found here:
  116996. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116997. */
  116998. export interface IMotionControllerProfile {
  116999. /**
  117000. * The id of this profile
  117001. * correlates to the profile(s) in the xrInput.profiles array
  117002. */
  117003. profileId: string;
  117004. /**
  117005. * fallback profiles for this profileId
  117006. */
  117007. fallbackProfileIds: string[];
  117008. /**
  117009. * The layout map, with handness as key
  117010. */
  117011. layouts: IMotionControllerLayoutMap;
  117012. }
  117013. /**
  117014. * A helper-interface for the 3 meshes needed for controller button animation
  117015. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117016. */
  117017. export interface IMotionControllerButtonMeshMap {
  117018. /**
  117019. * The mesh that will be changed when value changes
  117020. */
  117021. valueMesh: AbstractMesh;
  117022. /**
  117023. * the mesh that defines the pressed value mesh position.
  117024. * This is used to find the max-position of this button
  117025. */
  117026. pressedMesh: AbstractMesh;
  117027. /**
  117028. * the mesh that defines the unpressed value mesh position.
  117029. * This is used to find the min (or initial) position of this button
  117030. */
  117031. unpressedMesh: AbstractMesh;
  117032. }
  117033. /**
  117034. * A helper-interface for the 3 meshes needed for controller axis animation.
  117035. * This will be expanded when touchpad animations are fully supported
  117036. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117037. */
  117038. export interface IMotionControllerMeshMap {
  117039. /**
  117040. * The mesh that will be changed when axis value changes
  117041. */
  117042. valueMesh: AbstractMesh;
  117043. /**
  117044. * the mesh that defines the minimum value mesh position.
  117045. */
  117046. minMesh?: AbstractMesh;
  117047. /**
  117048. * the mesh that defines the maximum value mesh position.
  117049. */
  117050. maxMesh?: AbstractMesh;
  117051. }
  117052. /**
  117053. * The elements needed for change-detection of the gamepad objects in motion controllers
  117054. */
  117055. export interface IMinimalMotionControllerObject {
  117056. /**
  117057. * An array of available buttons
  117058. */
  117059. buttons: Array<{
  117060. /**
  117061. * Value of the button/trigger
  117062. */
  117063. value: number;
  117064. /**
  117065. * If the button/trigger is currently touched
  117066. */
  117067. touched: boolean;
  117068. /**
  117069. * If the button/trigger is currently pressed
  117070. */
  117071. pressed: boolean;
  117072. }>;
  117073. /**
  117074. * Available axes of this controller
  117075. */
  117076. axes: number[];
  117077. }
  117078. /**
  117079. * An Abstract Motion controller
  117080. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117081. * Each component has an observable to check for changes in value and state
  117082. */
  117083. export abstract class WebXRAbstractMotionController implements IDisposable {
  117084. protected scene: Scene;
  117085. protected layout: IMotionControllerLayout;
  117086. /**
  117087. * The gamepad object correlating to this controller
  117088. */
  117089. gamepadObject: IMinimalMotionControllerObject;
  117090. /**
  117091. * handness (left/right/none) of this controller
  117092. */
  117093. handness: MotionControllerHandness;
  117094. /**
  117095. * The profile id of this motion controller
  117096. */
  117097. abstract profileId: string;
  117098. /**
  117099. * A map of components (WebXRControllerComponent) in this motion controller
  117100. * Components have a ComponentType and can also have both button and axis definitions
  117101. */
  117102. readonly components: {
  117103. [id: string]: WebXRControllerComponent;
  117104. };
  117105. /**
  117106. * Observers registered here will be triggered when the model of this controller is done loading
  117107. */
  117108. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117109. /**
  117110. * The root mesh of the model. It is null if the model was not yet initialized
  117111. */
  117112. rootMesh: Nullable<AbstractMesh>;
  117113. /**
  117114. * Disable the model's animation. Can be set at any time.
  117115. */
  117116. disableAnimation: boolean;
  117117. private _modelReady;
  117118. /**
  117119. * constructs a new abstract motion controller
  117120. * @param scene the scene to which the model of the controller will be added
  117121. * @param layout The profile layout to load
  117122. * @param gamepadObject The gamepad object correlating to this controller
  117123. * @param handness handness (left/right/none) of this controller
  117124. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117125. */
  117126. constructor(scene: Scene, layout: IMotionControllerLayout,
  117127. /**
  117128. * The gamepad object correlating to this controller
  117129. */
  117130. gamepadObject: IMinimalMotionControllerObject,
  117131. /**
  117132. * handness (left/right/none) of this controller
  117133. */
  117134. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117135. private _initComponent;
  117136. /**
  117137. * Update this model using the current XRFrame
  117138. * @param xrFrame the current xr frame to use and update the model
  117139. */
  117140. updateFromXRFrame(xrFrame: XRFrame): void;
  117141. /**
  117142. * Get the list of components available in this motion controller
  117143. * @returns an array of strings correlating to available components
  117144. */
  117145. getComponentIds(): string[];
  117146. /**
  117147. * Get the main (Select) component of this controller as defined in the layout
  117148. * @returns the main component of this controller
  117149. */
  117150. getMainComponent(): WebXRControllerComponent;
  117151. /**
  117152. * get a component based an its component id as defined in layout.components
  117153. * @param id the id of the component
  117154. * @returns the component correlates to the id or undefined if not found
  117155. */
  117156. getComponent(id: string): WebXRControllerComponent;
  117157. /**
  117158. * Get the first component of specific type
  117159. * @param type type of component to find
  117160. * @return a controller component or null if not found
  117161. */
  117162. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117163. /**
  117164. * Returns all components of specific type
  117165. * @param type the type to search for
  117166. * @return an array of components with this type
  117167. */
  117168. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117169. /**
  117170. * Loads the model correlating to this controller
  117171. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117172. * @returns A promise fulfilled with the result of the model loading
  117173. */
  117174. loadModel(): Promise<boolean>;
  117175. /**
  117176. * Update the model itself with the current frame data
  117177. * @param xrFrame the frame to use for updating the model mesh
  117178. */
  117179. protected updateModel(xrFrame: XRFrame): void;
  117180. /**
  117181. * Moves the axis on the controller mesh based on its current state
  117182. * @param axis the index of the axis
  117183. * @param axisValue the value of the axis which determines the meshes new position
  117184. * @hidden
  117185. */
  117186. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117187. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117188. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117189. private _getGenericFilenameAndPath;
  117190. private _getGenericParentMesh;
  117191. /**
  117192. * Get the filename and path for this controller's model
  117193. * @returns a map of filename and path
  117194. */
  117195. protected abstract _getFilenameAndPath(): {
  117196. filename: string;
  117197. path: string;
  117198. };
  117199. /**
  117200. * This function will be called after the model was successfully loaded and can be used
  117201. * for mesh transformations before it is available for the user
  117202. * @param meshes the loaded meshes
  117203. */
  117204. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117205. /**
  117206. * Set the root mesh for this controller. Important for the WebXR controller class
  117207. * @param meshes the loaded meshes
  117208. */
  117209. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117210. /**
  117211. * A function executed each frame that updates the mesh (if needed)
  117212. * @param xrFrame the current xrFrame
  117213. */
  117214. protected abstract _updateModel(xrFrame: XRFrame): void;
  117215. /**
  117216. * This function is called before the mesh is loaded. It checks for loading constraints.
  117217. * For example, this function can check if the GLB loader is available
  117218. * If this function returns false, the generic controller will be loaded instead
  117219. * @returns Is the client ready to load the mesh
  117220. */
  117221. protected abstract _getModelLoadingConstraints(): boolean;
  117222. /**
  117223. * Dispose this controller, the model mesh and all its components
  117224. */
  117225. dispose(): void;
  117226. }
  117227. }
  117228. declare module BABYLON {
  117229. /**
  117230. * A generic trigger-only motion controller for WebXR
  117231. */
  117232. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117233. /**
  117234. * Static version of the profile id of this controller
  117235. */
  117236. static ProfileId: string;
  117237. profileId: string;
  117238. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117239. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117240. protected _updateModel(): void;
  117241. protected _getFilenameAndPath(): {
  117242. filename: string;
  117243. path: string;
  117244. };
  117245. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117246. protected _getModelLoadingConstraints(): boolean;
  117247. }
  117248. }
  117249. declare module BABYLON {
  117250. /**
  117251. * Class containing static functions to help procedurally build meshes
  117252. */
  117253. export class SphereBuilder {
  117254. /**
  117255. * Creates a sphere mesh
  117256. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117257. * * 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`)
  117258. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117259. * * 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
  117260. * * 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)
  117261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117264. * @param name defines the name of the mesh
  117265. * @param options defines the options used to create the mesh
  117266. * @param scene defines the hosting scene
  117267. * @returns the sphere mesh
  117268. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117269. */
  117270. static CreateSphere(name: string, options: {
  117271. segments?: number;
  117272. diameter?: number;
  117273. diameterX?: number;
  117274. diameterY?: number;
  117275. diameterZ?: number;
  117276. arc?: number;
  117277. slice?: number;
  117278. sideOrientation?: number;
  117279. frontUVs?: Vector4;
  117280. backUVs?: Vector4;
  117281. updatable?: boolean;
  117282. }, scene?: Nullable<Scene>): Mesh;
  117283. }
  117284. }
  117285. declare module BABYLON {
  117286. /**
  117287. * A profiled motion controller has its profile loaded from an online repository.
  117288. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117289. */
  117290. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117291. private _repositoryUrl;
  117292. /**
  117293. * The profile ID of this controller. Will be populated when the controller initializes.
  117294. */
  117295. profileId: string;
  117296. private _buttonMeshMapping;
  117297. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117298. protected _getFilenameAndPath(): {
  117299. filename: string;
  117300. path: string;
  117301. };
  117302. private _touchDots;
  117303. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117304. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117305. protected _updateModel(_xrFrame: XRFrame): void;
  117306. protected _getModelLoadingConstraints(): boolean;
  117307. dispose(): void;
  117308. }
  117309. }
  117310. declare module BABYLON {
  117311. /**
  117312. * A construction function type to create a new controller based on an xrInput object
  117313. */
  117314. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117315. /**
  117316. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117317. *
  117318. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117319. * it should be replaced with auto-loaded controllers.
  117320. *
  117321. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117322. */
  117323. export class WebXRMotionControllerManager {
  117324. /**
  117325. * The base URL of the online controller repository. Can be changed at any time.
  117326. */
  117327. static BaseRepositoryUrl: string;
  117328. /**
  117329. * Use the online repository, or use only locally-defined controllers
  117330. */
  117331. static UseOnlineRepository: boolean;
  117332. /**
  117333. * Which repository gets priority - local or online
  117334. */
  117335. static PrioritizeOnlineRepository: boolean;
  117336. private static _AvailableControllers;
  117337. private static _Fallbacks;
  117338. /**
  117339. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117340. *
  117341. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117342. *
  117343. * @param type the profile type to register
  117344. * @param constructFunction the function to be called when loading this profile
  117345. */
  117346. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117347. /**
  117348. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117349. * The order of search:
  117350. *
  117351. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117352. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117353. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117354. * 4) return the generic trigger controller if none were found
  117355. *
  117356. * @param xrInput the xrInput to which a new controller is initialized
  117357. * @param scene the scene to which the model will be added
  117358. * @param forceProfile force a certain profile for this controller
  117359. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117360. */
  117361. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117362. private static _LoadProfilesFromAvailableControllers;
  117363. private static _ProfilesList;
  117364. private static _ProfileLoadingPromises;
  117365. private static _LoadProfileFromRepository;
  117366. /**
  117367. * Clear the cache used for profile loading and reload when requested again
  117368. */
  117369. static ClearProfilesCache(): void;
  117370. /**
  117371. * Will update the list of profiles available in the repository
  117372. * @return a promise that resolves to a map of profiles available online
  117373. */
  117374. static UpdateProfilesList(): Promise<{
  117375. [profile: string]: string;
  117376. }>;
  117377. /**
  117378. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117379. * @param profileId the profile to which a fallback needs to be found
  117380. * @return an array with corresponding fallback profiles
  117381. */
  117382. static FindFallbackWithProfileId(profileId: string): string[];
  117383. /**
  117384. * Register a fallback to a specific profile.
  117385. * @param profileId the profileId that will receive the fallbacks
  117386. * @param fallbacks A list of fallback profiles
  117387. */
  117388. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117389. /**
  117390. * Register the default fallbacks.
  117391. * This function is called automatically when this file is imported.
  117392. */
  117393. static DefaultFallbacks(): void;
  117394. }
  117395. }
  117396. declare module BABYLON {
  117397. /**
  117398. * Configuration options for the WebXR controller creation
  117399. */
  117400. export interface IWebXRControllerOptions {
  117401. /**
  117402. * Force a specific controller type for this controller.
  117403. * This can be used when creating your own profile or when testing different controllers
  117404. */
  117405. forceControllerProfile?: string;
  117406. /**
  117407. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117408. */
  117409. doNotLoadControllerMesh?: boolean;
  117410. /**
  117411. * Should the controller mesh be animated when a user interacts with it
  117412. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117413. */
  117414. disableMotionControllerAnimation?: boolean;
  117415. }
  117416. /**
  117417. * Represents an XR controller
  117418. */
  117419. export class WebXRInputSource {
  117420. private _scene;
  117421. /** The underlying input source for the controller */
  117422. inputSource: XRInputSource;
  117423. private _options;
  117424. /**
  117425. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  117426. */
  117427. grip?: AbstractMesh;
  117428. /**
  117429. * Pointer which can be used to select objects or attach a visible laser to
  117430. */
  117431. pointer: AbstractMesh;
  117432. /**
  117433. * If available, this is the gamepad object related to this controller.
  117434. * Using this object it is possible to get click events and trackpad changes of the
  117435. * webxr controller that is currently being used.
  117436. */
  117437. motionController?: WebXRAbstractMotionController;
  117438. /**
  117439. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117440. */
  117441. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117442. /**
  117443. * Will be triggered when the mesh associated with the motion controller is done loading.
  117444. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117445. * A shortened version of controller -> motion controller -> on mesh loaded.
  117446. */
  117447. onMeshLoadedObservable: Observable<AbstractMesh>;
  117448. /**
  117449. * Event that fires when the controller is removed/disposed.
  117450. * The object provided as event data is this controller, after associated assets were disposed.
  117451. * uniqueId is still available.
  117452. */
  117453. onDisposeObservable: Observable<WebXRInputSource>;
  117454. private _tmpQuaternion;
  117455. private _tmpVector;
  117456. private _uniqueId;
  117457. /**
  117458. * Creates the controller
  117459. * @see https://doc.babylonjs.com/how_to/webxr
  117460. * @param _scene the scene which the controller should be associated to
  117461. * @param inputSource the underlying input source for the controller
  117462. * @param _options options for this controller creation
  117463. */
  117464. constructor(_scene: Scene,
  117465. /** The underlying input source for the controller */
  117466. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117467. /**
  117468. * Get this controllers unique id
  117469. */
  117470. get uniqueId(): string;
  117471. /**
  117472. * Updates the controller pose based on the given XRFrame
  117473. * @param xrFrame xr frame to update the pose with
  117474. * @param referenceSpace reference space to use
  117475. */
  117476. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117477. /**
  117478. * Gets a world space ray coming from the pointer or grip
  117479. * @param result the resulting ray
  117480. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117481. */
  117482. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117483. /**
  117484. * Disposes of the object
  117485. */
  117486. dispose(): void;
  117487. }
  117488. }
  117489. declare module BABYLON {
  117490. /**
  117491. * The schema for initialization options of the XR Input class
  117492. */
  117493. export interface IWebXRInputOptions {
  117494. /**
  117495. * If set to true no model will be automatically loaded
  117496. */
  117497. doNotLoadControllerMeshes?: boolean;
  117498. /**
  117499. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117500. * If not found, the xr input profile data will be used.
  117501. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117502. */
  117503. forceInputProfile?: string;
  117504. /**
  117505. * Do not send a request to the controlle repository to load the profile.
  117506. *
  117507. * Instead, use the controllers available in babylon itself.
  117508. */
  117509. disableOnlineControllerRepository?: boolean;
  117510. /**
  117511. * A custom URL for the controllers repository
  117512. */
  117513. customControllersRepositoryURL?: string;
  117514. /**
  117515. * Should the controller model's components not move according to the user input
  117516. */
  117517. disableControllerAnimation?: boolean;
  117518. }
  117519. /**
  117520. * XR input used to track XR inputs such as controllers/rays
  117521. */
  117522. export class WebXRInput implements IDisposable {
  117523. /**
  117524. * the xr session manager for this session
  117525. */
  117526. xrSessionManager: WebXRSessionManager;
  117527. /**
  117528. * the WebXR camera for this session. Mainly used for teleportation
  117529. */
  117530. xrCamera: WebXRCamera;
  117531. private readonly options;
  117532. /**
  117533. * XR controllers being tracked
  117534. */
  117535. controllers: Array<WebXRInputSource>;
  117536. private _frameObserver;
  117537. private _sessionEndedObserver;
  117538. private _sessionInitObserver;
  117539. /**
  117540. * Event when a controller has been connected/added
  117541. */
  117542. onControllerAddedObservable: Observable<WebXRInputSource>;
  117543. /**
  117544. * Event when a controller has been removed/disconnected
  117545. */
  117546. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117547. /**
  117548. * Initializes the WebXRInput
  117549. * @param xrSessionManager the xr session manager for this session
  117550. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117551. * @param options = initialization options for this xr input
  117552. */
  117553. constructor(
  117554. /**
  117555. * the xr session manager for this session
  117556. */
  117557. xrSessionManager: WebXRSessionManager,
  117558. /**
  117559. * the WebXR camera for this session. Mainly used for teleportation
  117560. */
  117561. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117562. private _onInputSourcesChange;
  117563. private _addAndRemoveControllers;
  117564. /**
  117565. * Disposes of the object
  117566. */
  117567. dispose(): void;
  117568. }
  117569. }
  117570. declare module BABYLON {
  117571. /**
  117572. * This is the base class for all WebXR features.
  117573. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117574. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117575. */
  117576. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117577. protected _xrSessionManager: WebXRSessionManager;
  117578. /**
  117579. * Construct a new (abstract) webxr feature
  117580. * @param _xrSessionManager the xr session manager for this feature
  117581. */
  117582. constructor(_xrSessionManager: WebXRSessionManager);
  117583. private _attached;
  117584. private _removeOnDetach;
  117585. /**
  117586. * Is this feature attached
  117587. */
  117588. get attached(): boolean;
  117589. /**
  117590. * Should auto-attach be disabled?
  117591. */
  117592. disableAutoAttach: boolean;
  117593. /**
  117594. * attach this feature
  117595. *
  117596. * @param force should attachment be forced (even when already attached)
  117597. * @returns true if successful, false is failed or already attached
  117598. */
  117599. attach(force?: boolean): boolean;
  117600. /**
  117601. * detach this feature.
  117602. *
  117603. * @returns true if successful, false if failed or already detached
  117604. */
  117605. detach(): boolean;
  117606. /**
  117607. * Dispose this feature and all of the resources attached
  117608. */
  117609. dispose(): void;
  117610. /**
  117611. * Code in this function will be executed on each xrFrame received from the browser.
  117612. * This function will not execute after the feature is detached.
  117613. * @param _xrFrame the current frame
  117614. */
  117615. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117616. /**
  117617. * This is used to register callbacks that will automatically be removed when detach is called.
  117618. * @param observable the observable to which the observer will be attached
  117619. * @param callback the callback to register
  117620. */
  117621. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117622. }
  117623. }
  117624. declare module BABYLON {
  117625. /**
  117626. * Renders a layer on top of an existing scene
  117627. */
  117628. export class UtilityLayerRenderer implements IDisposable {
  117629. /** the original scene that will be rendered on top of */
  117630. originalScene: Scene;
  117631. private _pointerCaptures;
  117632. private _lastPointerEvents;
  117633. private static _DefaultUtilityLayer;
  117634. private static _DefaultKeepDepthUtilityLayer;
  117635. private _sharedGizmoLight;
  117636. private _renderCamera;
  117637. /**
  117638. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117639. * @returns the camera that is used when rendering the utility layer
  117640. */
  117641. getRenderCamera(): Camera;
  117642. /**
  117643. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117644. * @param cam the camera that should be used when rendering the utility layer
  117645. */
  117646. setRenderCamera(cam: Nullable<Camera>): void;
  117647. /**
  117648. * @hidden
  117649. * Light which used by gizmos to get light shading
  117650. */
  117651. _getSharedGizmoLight(): HemisphericLight;
  117652. /**
  117653. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117654. */
  117655. pickUtilitySceneFirst: boolean;
  117656. /**
  117657. * 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)
  117658. */
  117659. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117660. /**
  117661. * 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)
  117662. */
  117663. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117664. /**
  117665. * The scene that is rendered on top of the original scene
  117666. */
  117667. utilityLayerScene: Scene;
  117668. /**
  117669. * If the utility layer should automatically be rendered on top of existing scene
  117670. */
  117671. shouldRender: boolean;
  117672. /**
  117673. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117674. */
  117675. onlyCheckPointerDownEvents: boolean;
  117676. /**
  117677. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117678. */
  117679. processAllEvents: boolean;
  117680. /**
  117681. * Observable raised when the pointer move from the utility layer scene to the main scene
  117682. */
  117683. onPointerOutObservable: Observable<number>;
  117684. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117685. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117686. private _afterRenderObserver;
  117687. private _sceneDisposeObserver;
  117688. private _originalPointerObserver;
  117689. /**
  117690. * Instantiates a UtilityLayerRenderer
  117691. * @param originalScene the original scene that will be rendered on top of
  117692. * @param handleEvents boolean indicating if the utility layer should handle events
  117693. */
  117694. constructor(
  117695. /** the original scene that will be rendered on top of */
  117696. originalScene: Scene, handleEvents?: boolean);
  117697. private _notifyObservers;
  117698. /**
  117699. * Renders the utility layers scene on top of the original scene
  117700. */
  117701. render(): void;
  117702. /**
  117703. * Disposes of the renderer
  117704. */
  117705. dispose(): void;
  117706. private _updateCamera;
  117707. }
  117708. }
  117709. declare module BABYLON {
  117710. /**
  117711. * Options interface for the pointer selection module
  117712. */
  117713. export interface IWebXRControllerPointerSelectionOptions {
  117714. /**
  117715. * the xr input to use with this pointer selection
  117716. */
  117717. xrInput: WebXRInput;
  117718. /**
  117719. * Different button type to use instead of the main component
  117720. */
  117721. overrideButtonId?: string;
  117722. /**
  117723. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117724. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117725. * 3000 means 3 seconds between pointing at something and selecting it
  117726. */
  117727. timeToSelect?: number;
  117728. /**
  117729. * 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)
  117730. * If not disabled, the last picked point will be used to execute a pointer up event
  117731. * If disabled, pointer up event will be triggered right after the pointer down event.
  117732. * Used in screen and gaze target ray mode only
  117733. */
  117734. disablePointerUpOnTouchOut: boolean;
  117735. /**
  117736. * For gaze mode (time to select instead of press)
  117737. */
  117738. forceGazeMode: boolean;
  117739. /**
  117740. * 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
  117741. * to start a new countdown to the pointer down event.
  117742. * Defaults to 1.
  117743. */
  117744. gazeModePointerMovedFactor?: number;
  117745. /**
  117746. * Should meshes created here be added to a utility layer or the main scene
  117747. */
  117748. useUtilityLayer?: boolean;
  117749. /**
  117750. * if provided, this scene will be used to render meshes.
  117751. */
  117752. customUtilityLayerScene?: Scene;
  117753. }
  117754. /**
  117755. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117756. */
  117757. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117758. private readonly _options;
  117759. /**
  117760. * The module's name
  117761. */
  117762. static readonly Name: string;
  117763. /**
  117764. * The (Babylon) version of this module.
  117765. * This is an integer representing the implementation version.
  117766. * This number does not correspond to the webxr specs version
  117767. */
  117768. static readonly Version: number;
  117769. /**
  117770. * This color will be set to the laser pointer when selection is triggered
  117771. */
  117772. laserPointerPickedColor: Color3;
  117773. /**
  117774. * This color will be applied to the selection ring when selection is triggered
  117775. */
  117776. selectionMeshPickedColor: Color3;
  117777. /**
  117778. * default color of the selection ring
  117779. */
  117780. selectionMeshDefaultColor: Color3;
  117781. /**
  117782. * Default color of the laser pointer
  117783. */
  117784. lasterPointerDefaultColor: Color3;
  117785. /**
  117786. * Should the laser pointer be displayed
  117787. */
  117788. displayLaserPointer: boolean;
  117789. /**
  117790. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117791. */
  117792. displaySelectionMesh: boolean;
  117793. /**
  117794. * Disable lighting on the laser pointer (so it will always be visible)
  117795. */
  117796. disablePointerLighting: boolean;
  117797. /**
  117798. * Disable lighting on the selection mesh (so it will always be visible)
  117799. */
  117800. disableSelectionMeshLighting: boolean;
  117801. private static _idCounter;
  117802. private _tmpRay;
  117803. private _controllers;
  117804. private _scene;
  117805. /**
  117806. * constructs a new background remover module
  117807. * @param _xrSessionManager the session manager for this module
  117808. * @param _options read-only options to be used in this module
  117809. */
  117810. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117811. /**
  117812. * attach this feature
  117813. * Will usually be called by the features manager
  117814. *
  117815. * @returns true if successful.
  117816. */
  117817. attach(): boolean;
  117818. /**
  117819. * detach this feature.
  117820. * Will usually be called by the features manager
  117821. *
  117822. * @returns true if successful.
  117823. */
  117824. detach(): boolean;
  117825. /**
  117826. * Get the xr controller that correlates to the pointer id in the pointer event
  117827. *
  117828. * @param id the pointer id to search for
  117829. * @returns the controller that correlates to this id or null if not found
  117830. */
  117831. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117832. protected _onXRFrame(_xrFrame: XRFrame): void;
  117833. private _attachController;
  117834. private _attachScreenRayMode;
  117835. private _attachGazeMode;
  117836. private _tmpVectorForPickCompare;
  117837. private _pickingMoved;
  117838. private _attachTrackedPointerRayMode;
  117839. private _detachController;
  117840. private _generateNewMeshPair;
  117841. private _convertNormalToDirectionOfRay;
  117842. private _updatePointerDistance;
  117843. }
  117844. }
  117845. declare module BABYLON {
  117846. /**
  117847. * Button which can be used to enter a different mode of XR
  117848. */
  117849. export class WebXREnterExitUIButton {
  117850. /** button element */
  117851. element: HTMLElement;
  117852. /** XR initialization options for the button */
  117853. sessionMode: XRSessionMode;
  117854. /** Reference space type */
  117855. referenceSpaceType: XRReferenceSpaceType;
  117856. /**
  117857. * Creates a WebXREnterExitUIButton
  117858. * @param element button element
  117859. * @param sessionMode XR initialization session mode
  117860. * @param referenceSpaceType the type of reference space to be used
  117861. */
  117862. constructor(
  117863. /** button element */
  117864. element: HTMLElement,
  117865. /** XR initialization options for the button */
  117866. sessionMode: XRSessionMode,
  117867. /** Reference space type */
  117868. referenceSpaceType: XRReferenceSpaceType);
  117869. /**
  117870. * Overwritable function which can be used to update the button's visuals when the state changes
  117871. * @param activeButton the current active button in the UI
  117872. */
  117873. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117874. }
  117875. /**
  117876. * Options to create the webXR UI
  117877. */
  117878. export class WebXREnterExitUIOptions {
  117879. /**
  117880. * Context to enter xr with
  117881. */
  117882. renderTarget?: Nullable<WebXRRenderTarget>;
  117883. /**
  117884. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117885. */
  117886. customButtons?: Array<WebXREnterExitUIButton>;
  117887. /**
  117888. * A session mode to use when creating the default button.
  117889. * Default is immersive-vr
  117890. */
  117891. sessionMode?: XRSessionMode;
  117892. /**
  117893. * A reference space type to use when creating the default button.
  117894. * Default is local-floor
  117895. */
  117896. referenceSpaceType?: XRReferenceSpaceType;
  117897. }
  117898. /**
  117899. * UI to allow the user to enter/exit XR mode
  117900. */
  117901. export class WebXREnterExitUI implements IDisposable {
  117902. private scene;
  117903. /** version of the options passed to this UI */
  117904. options: WebXREnterExitUIOptions;
  117905. private _overlay;
  117906. private _buttons;
  117907. private _activeButton;
  117908. /**
  117909. * Fired every time the active button is changed.
  117910. *
  117911. * When xr is entered via a button that launches xr that button will be the callback parameter
  117912. *
  117913. * When exiting xr the callback parameter will be null)
  117914. */
  117915. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117916. /**
  117917. * Creates UI to allow the user to enter/exit XR mode
  117918. * @param scene the scene to add the ui to
  117919. * @param helper the xr experience helper to enter/exit xr with
  117920. * @param options options to configure the UI
  117921. * @returns the created ui
  117922. */
  117923. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117924. /**
  117925. *
  117926. * @param scene babylon scene object to use
  117927. * @param options (read-only) version of the options passed to this UI
  117928. */
  117929. private constructor();
  117930. private _updateButtons;
  117931. /**
  117932. * Disposes of the object
  117933. */
  117934. dispose(): void;
  117935. }
  117936. }
  117937. declare module BABYLON {
  117938. /**
  117939. * Class containing static functions to help procedurally build meshes
  117940. */
  117941. export class LinesBuilder {
  117942. /**
  117943. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117944. * * 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
  117945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117946. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117947. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117948. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117949. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117950. * * 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
  117951. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117954. * @param name defines the name of the new line system
  117955. * @param options defines the options used to create the line system
  117956. * @param scene defines the hosting scene
  117957. * @returns a new line system mesh
  117958. */
  117959. static CreateLineSystem(name: string, options: {
  117960. lines: Vector3[][];
  117961. updatable?: boolean;
  117962. instance?: Nullable<LinesMesh>;
  117963. colors?: Nullable<Color4[][]>;
  117964. useVertexAlpha?: boolean;
  117965. }, scene: Nullable<Scene>): LinesMesh;
  117966. /**
  117967. * Creates a line mesh
  117968. * 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
  117969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117970. * * The parameter `points` is an array successive Vector3
  117971. * * 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
  117972. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117974. * * When updating an instance, remember that only point positions can change, not the number of points
  117975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117977. * @param name defines the name of the new line system
  117978. * @param options defines the options used to create the line system
  117979. * @param scene defines the hosting scene
  117980. * @returns a new line mesh
  117981. */
  117982. static CreateLines(name: string, options: {
  117983. points: Vector3[];
  117984. updatable?: boolean;
  117985. instance?: Nullable<LinesMesh>;
  117986. colors?: Color4[];
  117987. useVertexAlpha?: boolean;
  117988. }, scene?: Nullable<Scene>): LinesMesh;
  117989. /**
  117990. * Creates a dashed line mesh
  117991. * * 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
  117992. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117993. * * The parameter `points` is an array successive Vector3
  117994. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117995. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117996. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117997. * * 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
  117998. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117999. * * When updating an instance, remember that only point positions can change, not the number of points
  118000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118001. * @param name defines the name of the mesh
  118002. * @param options defines the options used to create the mesh
  118003. * @param scene defines the hosting scene
  118004. * @returns the dashed line mesh
  118005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118006. */
  118007. static CreateDashedLines(name: string, options: {
  118008. points: Vector3[];
  118009. dashSize?: number;
  118010. gapSize?: number;
  118011. dashNb?: number;
  118012. updatable?: boolean;
  118013. instance?: LinesMesh;
  118014. useVertexAlpha?: boolean;
  118015. }, scene?: Nullable<Scene>): LinesMesh;
  118016. }
  118017. }
  118018. declare module BABYLON {
  118019. /**
  118020. * The options container for the teleportation module
  118021. */
  118022. export interface IWebXRTeleportationOptions {
  118023. /**
  118024. * Babylon XR Input class for controller
  118025. */
  118026. xrInput: WebXRInput;
  118027. /**
  118028. * A list of meshes to use as floor meshes.
  118029. * Meshes can be added and removed after initializing the feature using the
  118030. * addFloorMesh and removeFloorMesh functions
  118031. * If empty, rotation will still work
  118032. */
  118033. floorMeshes?: AbstractMesh[];
  118034. /**
  118035. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118036. * If you want to support rotation, make sure your mesh has a direction indicator.
  118037. *
  118038. * When left untouched, the default mesh will be initialized.
  118039. */
  118040. teleportationTargetMesh?: AbstractMesh;
  118041. /**
  118042. * Values to configure the default target mesh
  118043. */
  118044. defaultTargetMeshOptions?: {
  118045. /**
  118046. * Fill color of the teleportation area
  118047. */
  118048. teleportationFillColor?: string;
  118049. /**
  118050. * Border color for the teleportation area
  118051. */
  118052. teleportationBorderColor?: string;
  118053. /**
  118054. * Disable the mesh's animation sequence
  118055. */
  118056. disableAnimation?: boolean;
  118057. /**
  118058. * Disable lighting on the material or the ring and arrow
  118059. */
  118060. disableLighting?: boolean;
  118061. /**
  118062. * Override the default material of the torus and arrow
  118063. */
  118064. torusArrowMaterial?: Material;
  118065. };
  118066. /**
  118067. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118068. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118069. */
  118070. useMainComponentOnly?: boolean;
  118071. /**
  118072. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118073. */
  118074. timeToTeleport?: number;
  118075. /**
  118076. * Should meshes created here be added to a utility layer or the main scene
  118077. */
  118078. useUtilityLayer?: boolean;
  118079. /**
  118080. * if provided, this scene will be used to render meshes.
  118081. */
  118082. customUtilityLayerScene?: Scene;
  118083. }
  118084. /**
  118085. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118086. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  118087. * the input of the attached controllers.
  118088. */
  118089. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118090. private _options;
  118091. /**
  118092. * The module's name
  118093. */
  118094. static readonly Name: string;
  118095. /**
  118096. * The (Babylon) version of this module.
  118097. * This is an integer representing the implementation version.
  118098. * This number does not correspond to the webxr specs version
  118099. */
  118100. static readonly Version: number;
  118101. /**
  118102. * Is rotation enabled when moving forward?
  118103. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118104. */
  118105. rotationEnabled: boolean;
  118106. /**
  118107. * Should the module support parabolic ray on top of direct ray
  118108. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118109. * Very helpful when moving between floors / different heights
  118110. */
  118111. parabolicRayEnabled: boolean;
  118112. /**
  118113. * The distance from the user to the inspection point in the direction of the controller
  118114. * A higher number will allow the user to move further
  118115. * defaults to 5 (meters, in xr units)
  118116. */
  118117. parabolicCheckRadius: number;
  118118. /**
  118119. * How much rotation should be applied when rotating right and left
  118120. */
  118121. rotationAngle: number;
  118122. /**
  118123. * Is movement backwards enabled
  118124. */
  118125. backwardsMovementEnabled: boolean;
  118126. /**
  118127. * Distance to travel when moving backwards
  118128. */
  118129. backwardsTeleportationDistance: number;
  118130. /**
  118131. * Add a new mesh to the floor meshes array
  118132. * @param mesh the mesh to use as floor mesh
  118133. */
  118134. addFloorMesh(mesh: AbstractMesh): void;
  118135. /**
  118136. * Remove a mesh from the floor meshes array
  118137. * @param mesh the mesh to remove
  118138. */
  118139. removeFloorMesh(mesh: AbstractMesh): void;
  118140. /**
  118141. * Remove a mesh from the floor meshes array using its name
  118142. * @param name the mesh name to remove
  118143. */
  118144. removeFloorMeshByName(name: string): void;
  118145. private _tmpRay;
  118146. private _tmpVector;
  118147. private _floorMeshes;
  118148. private _controllers;
  118149. /**
  118150. * constructs a new anchor system
  118151. * @param _xrSessionManager an instance of WebXRSessionManager
  118152. * @param _options configuration object for this feature
  118153. */
  118154. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118155. private _selectionFeature;
  118156. /**
  118157. * This function sets a selection feature that will be disabled when
  118158. * the forward ray is shown and will be reattached when hidden.
  118159. * This is used to remove the selection rays when moving.
  118160. * @param selectionFeature the feature to disable when forward movement is enabled
  118161. */
  118162. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118163. attach(): boolean;
  118164. detach(): boolean;
  118165. dispose(): void;
  118166. protected _onXRFrame(_xrFrame: XRFrame): void;
  118167. private _currentTeleportationControllerId;
  118168. private _attachController;
  118169. private _teleportForward;
  118170. private _detachController;
  118171. private createDefaultTargetMesh;
  118172. private setTargetMeshVisibility;
  118173. private setTargetMeshPosition;
  118174. private _quadraticBezierCurve;
  118175. private _showParabolicPath;
  118176. }
  118177. }
  118178. declare module BABYLON {
  118179. /**
  118180. * Options for the default xr helper
  118181. */
  118182. export class WebXRDefaultExperienceOptions {
  118183. /**
  118184. * Floor meshes that will be used for teleporting
  118185. */
  118186. floorMeshes?: Array<AbstractMesh>;
  118187. /**
  118188. * Enable or disable default UI to enter XR
  118189. */
  118190. disableDefaultUI?: boolean;
  118191. /**
  118192. * optional configuration for the output canvas
  118193. */
  118194. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118195. /**
  118196. * optional UI options. This can be used among other to change session mode and reference space type
  118197. */
  118198. uiOptions?: WebXREnterExitUIOptions;
  118199. /**
  118200. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118201. */
  118202. inputOptions?: IWebXRInputOptions;
  118203. /**
  118204. * Should teleportation not initialize. defaults to false.
  118205. */
  118206. disableTeleportation?: boolean;
  118207. /**
  118208. * If set to true, the first frame will not be used to reset position
  118209. * The first frame is mainly used when copying transformation from the old camera
  118210. * Mainly used in AR
  118211. */
  118212. ignoreNativeCameraTransformation?: boolean;
  118213. /**
  118214. * When loading teleportation and pointer select, use stable versions instead of latest.
  118215. */
  118216. useStablePlugins?: boolean;
  118217. }
  118218. /**
  118219. * Default experience which provides a similar setup to the previous webVRExperience
  118220. */
  118221. export class WebXRDefaultExperience {
  118222. /**
  118223. * Base experience
  118224. */
  118225. baseExperience: WebXRExperienceHelper;
  118226. /**
  118227. * Input experience extension
  118228. */
  118229. input: WebXRInput;
  118230. /**
  118231. * Enables laser pointer and selection
  118232. */
  118233. pointerSelection: WebXRControllerPointerSelection;
  118234. /**
  118235. * Enables teleportation
  118236. */
  118237. teleportation: WebXRMotionControllerTeleportation;
  118238. /**
  118239. * Enables ui for entering/exiting xr
  118240. */
  118241. enterExitUI: WebXREnterExitUI;
  118242. /**
  118243. * Default target xr should render to
  118244. */
  118245. renderTarget: WebXRRenderTarget;
  118246. /**
  118247. * Creates the default xr experience
  118248. * @param scene scene
  118249. * @param options options for basic configuration
  118250. * @returns resulting WebXRDefaultExperience
  118251. */
  118252. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118253. private constructor();
  118254. /**
  118255. * DIsposes of the experience helper
  118256. */
  118257. dispose(): void;
  118258. }
  118259. }
  118260. declare module BABYLON {
  118261. /**
  118262. * Options to modify the vr teleportation behavior.
  118263. */
  118264. export interface VRTeleportationOptions {
  118265. /**
  118266. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118267. */
  118268. floorMeshName?: string;
  118269. /**
  118270. * A list of meshes to be used as the teleportation floor. (default: empty)
  118271. */
  118272. floorMeshes?: Mesh[];
  118273. /**
  118274. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118275. */
  118276. teleportationMode?: number;
  118277. /**
  118278. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118279. */
  118280. teleportationTime?: number;
  118281. /**
  118282. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118283. */
  118284. teleportationSpeed?: number;
  118285. /**
  118286. * The easing function used in the animation or null for Linear. (default CircleEase)
  118287. */
  118288. easingFunction?: EasingFunction;
  118289. }
  118290. /**
  118291. * Options to modify the vr experience helper's behavior.
  118292. */
  118293. export interface VRExperienceHelperOptions extends WebVROptions {
  118294. /**
  118295. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118296. */
  118297. createDeviceOrientationCamera?: boolean;
  118298. /**
  118299. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118300. */
  118301. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118302. /**
  118303. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118304. */
  118305. laserToggle?: boolean;
  118306. /**
  118307. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118308. */
  118309. floorMeshes?: Mesh[];
  118310. /**
  118311. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118312. */
  118313. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118314. /**
  118315. * Defines if WebXR should be used instead of WebVR (if available)
  118316. */
  118317. useXR?: boolean;
  118318. }
  118319. /**
  118320. * Event containing information after VR has been entered
  118321. */
  118322. export class OnAfterEnteringVRObservableEvent {
  118323. /**
  118324. * If entering vr was successful
  118325. */
  118326. success: boolean;
  118327. }
  118328. /**
  118329. * Helps to quickly add VR support to an existing scene.
  118330. * See http://doc.babylonjs.com/how_to/webvr_helper
  118331. */
  118332. export class VRExperienceHelper {
  118333. /** Options to modify the vr experience helper's behavior. */
  118334. webVROptions: VRExperienceHelperOptions;
  118335. private _scene;
  118336. private _position;
  118337. private _btnVR;
  118338. private _btnVRDisplayed;
  118339. private _webVRsupported;
  118340. private _webVRready;
  118341. private _webVRrequesting;
  118342. private _webVRpresenting;
  118343. private _hasEnteredVR;
  118344. private _fullscreenVRpresenting;
  118345. private _inputElement;
  118346. private _webVRCamera;
  118347. private _vrDeviceOrientationCamera;
  118348. private _deviceOrientationCamera;
  118349. private _existingCamera;
  118350. private _onKeyDown;
  118351. private _onVrDisplayPresentChange;
  118352. private _onVRDisplayChanged;
  118353. private _onVRRequestPresentStart;
  118354. private _onVRRequestPresentComplete;
  118355. /**
  118356. * 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)
  118357. */
  118358. enableGazeEvenWhenNoPointerLock: boolean;
  118359. /**
  118360. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118361. */
  118362. exitVROnDoubleTap: boolean;
  118363. /**
  118364. * Observable raised right before entering VR.
  118365. */
  118366. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118367. /**
  118368. * Observable raised when entering VR has completed.
  118369. */
  118370. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118371. /**
  118372. * Observable raised when exiting VR.
  118373. */
  118374. onExitingVRObservable: Observable<VRExperienceHelper>;
  118375. /**
  118376. * Observable raised when controller mesh is loaded.
  118377. */
  118378. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118379. /** Return this.onEnteringVRObservable
  118380. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118381. */
  118382. get onEnteringVR(): Observable<VRExperienceHelper>;
  118383. /** Return this.onExitingVRObservable
  118384. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118385. */
  118386. get onExitingVR(): Observable<VRExperienceHelper>;
  118387. /** Return this.onControllerMeshLoadedObservable
  118388. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118389. */
  118390. get onControllerMeshLoaded(): Observable<WebVRController>;
  118391. private _rayLength;
  118392. private _useCustomVRButton;
  118393. private _teleportationRequested;
  118394. private _teleportActive;
  118395. private _floorMeshName;
  118396. private _floorMeshesCollection;
  118397. private _teleportationMode;
  118398. private _teleportationTime;
  118399. private _teleportationSpeed;
  118400. private _teleportationEasing;
  118401. private _rotationAllowed;
  118402. private _teleportBackwardsVector;
  118403. private _teleportationTarget;
  118404. private _isDefaultTeleportationTarget;
  118405. private _postProcessMove;
  118406. private _teleportationFillColor;
  118407. private _teleportationBorderColor;
  118408. private _rotationAngle;
  118409. private _haloCenter;
  118410. private _cameraGazer;
  118411. private _padSensibilityUp;
  118412. private _padSensibilityDown;
  118413. private _leftController;
  118414. private _rightController;
  118415. private _gazeColor;
  118416. private _laserColor;
  118417. private _pickedLaserColor;
  118418. private _pickedGazeColor;
  118419. /**
  118420. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118421. */
  118422. onNewMeshSelected: Observable<AbstractMesh>;
  118423. /**
  118424. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118425. * This observable will provide the mesh and the controller used to select the mesh
  118426. */
  118427. onMeshSelectedWithController: Observable<{
  118428. mesh: AbstractMesh;
  118429. controller: WebVRController;
  118430. }>;
  118431. /**
  118432. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118433. */
  118434. onNewMeshPicked: Observable<PickingInfo>;
  118435. private _circleEase;
  118436. /**
  118437. * Observable raised before camera teleportation
  118438. */
  118439. onBeforeCameraTeleport: Observable<Vector3>;
  118440. /**
  118441. * Observable raised after camera teleportation
  118442. */
  118443. onAfterCameraTeleport: Observable<Vector3>;
  118444. /**
  118445. * Observable raised when current selected mesh gets unselected
  118446. */
  118447. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118448. private _raySelectionPredicate;
  118449. /**
  118450. * To be optionaly changed by user to define custom ray selection
  118451. */
  118452. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118453. /**
  118454. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118455. */
  118456. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118457. /**
  118458. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118459. */
  118460. teleportationEnabled: boolean;
  118461. private _defaultHeight;
  118462. private _teleportationInitialized;
  118463. private _interactionsEnabled;
  118464. private _interactionsRequested;
  118465. private _displayGaze;
  118466. private _displayLaserPointer;
  118467. /**
  118468. * The mesh used to display where the user is going to teleport.
  118469. */
  118470. get teleportationTarget(): Mesh;
  118471. /**
  118472. * Sets the mesh to be used to display where the user is going to teleport.
  118473. */
  118474. set teleportationTarget(value: Mesh);
  118475. /**
  118476. * 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
  118477. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118478. * See http://doc.babylonjs.com/resources/baking_transformations
  118479. */
  118480. get gazeTrackerMesh(): Mesh;
  118481. set gazeTrackerMesh(value: Mesh);
  118482. /**
  118483. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118484. */
  118485. updateGazeTrackerScale: boolean;
  118486. /**
  118487. * If the gaze trackers color should be updated when selecting meshes
  118488. */
  118489. updateGazeTrackerColor: boolean;
  118490. /**
  118491. * If the controller laser color should be updated when selecting meshes
  118492. */
  118493. updateControllerLaserColor: boolean;
  118494. /**
  118495. * The gaze tracking mesh corresponding to the left controller
  118496. */
  118497. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118498. /**
  118499. * The gaze tracking mesh corresponding to the right controller
  118500. */
  118501. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118502. /**
  118503. * If the ray of the gaze should be displayed.
  118504. */
  118505. get displayGaze(): boolean;
  118506. /**
  118507. * Sets if the ray of the gaze should be displayed.
  118508. */
  118509. set displayGaze(value: boolean);
  118510. /**
  118511. * If the ray of the LaserPointer should be displayed.
  118512. */
  118513. get displayLaserPointer(): boolean;
  118514. /**
  118515. * Sets if the ray of the LaserPointer should be displayed.
  118516. */
  118517. set displayLaserPointer(value: boolean);
  118518. /**
  118519. * The deviceOrientationCamera used as the camera when not in VR.
  118520. */
  118521. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118522. /**
  118523. * Based on the current WebVR support, returns the current VR camera used.
  118524. */
  118525. get currentVRCamera(): Nullable<Camera>;
  118526. /**
  118527. * The webVRCamera which is used when in VR.
  118528. */
  118529. get webVRCamera(): WebVRFreeCamera;
  118530. /**
  118531. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118532. */
  118533. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118534. /**
  118535. * The html button that is used to trigger entering into VR.
  118536. */
  118537. get vrButton(): Nullable<HTMLButtonElement>;
  118538. private get _teleportationRequestInitiated();
  118539. /**
  118540. * Defines whether or not Pointer lock should be requested when switching to
  118541. * full screen.
  118542. */
  118543. requestPointerLockOnFullScreen: boolean;
  118544. /**
  118545. * If asking to force XR, this will be populated with the default xr experience
  118546. */
  118547. xr: WebXRDefaultExperience;
  118548. /**
  118549. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118550. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118551. */
  118552. xrTestDone: boolean;
  118553. /**
  118554. * Instantiates a VRExperienceHelper.
  118555. * Helps to quickly add VR support to an existing scene.
  118556. * @param scene The scene the VRExperienceHelper belongs to.
  118557. * @param webVROptions Options to modify the vr experience helper's behavior.
  118558. */
  118559. constructor(scene: Scene,
  118560. /** Options to modify the vr experience helper's behavior. */
  118561. webVROptions?: VRExperienceHelperOptions);
  118562. private completeVRInit;
  118563. private _onDefaultMeshLoaded;
  118564. private _onResize;
  118565. private _onFullscreenChange;
  118566. /**
  118567. * Gets a value indicating if we are currently in VR mode.
  118568. */
  118569. get isInVRMode(): boolean;
  118570. private onVrDisplayPresentChange;
  118571. private onVRDisplayChanged;
  118572. private moveButtonToBottomRight;
  118573. private displayVRButton;
  118574. private updateButtonVisibility;
  118575. private _cachedAngularSensibility;
  118576. /**
  118577. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118578. * Otherwise, will use the fullscreen API.
  118579. */
  118580. enterVR(): void;
  118581. /**
  118582. * Attempt to exit VR, or fullscreen.
  118583. */
  118584. exitVR(): void;
  118585. /**
  118586. * The position of the vr experience helper.
  118587. */
  118588. get position(): Vector3;
  118589. /**
  118590. * Sets the position of the vr experience helper.
  118591. */
  118592. set position(value: Vector3);
  118593. /**
  118594. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118595. */
  118596. enableInteractions(): void;
  118597. private get _noControllerIsActive();
  118598. private beforeRender;
  118599. private _isTeleportationFloor;
  118600. /**
  118601. * Adds a floor mesh to be used for teleportation.
  118602. * @param floorMesh the mesh to be used for teleportation.
  118603. */
  118604. addFloorMesh(floorMesh: Mesh): void;
  118605. /**
  118606. * Removes a floor mesh from being used for teleportation.
  118607. * @param floorMesh the mesh to be removed.
  118608. */
  118609. removeFloorMesh(floorMesh: Mesh): void;
  118610. /**
  118611. * Enables interactions and teleportation using the VR controllers and gaze.
  118612. * @param vrTeleportationOptions options to modify teleportation behavior.
  118613. */
  118614. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118615. private _onNewGamepadConnected;
  118616. private _tryEnableInteractionOnController;
  118617. private _onNewGamepadDisconnected;
  118618. private _enableInteractionOnController;
  118619. private _checkTeleportWithRay;
  118620. private _checkRotate;
  118621. private _checkTeleportBackwards;
  118622. private _enableTeleportationOnController;
  118623. private _createTeleportationCircles;
  118624. private _displayTeleportationTarget;
  118625. private _hideTeleportationTarget;
  118626. private _rotateCamera;
  118627. private _moveTeleportationSelectorTo;
  118628. private _workingVector;
  118629. private _workingQuaternion;
  118630. private _workingMatrix;
  118631. /**
  118632. * Time Constant Teleportation Mode
  118633. */
  118634. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118635. /**
  118636. * Speed Constant Teleportation Mode
  118637. */
  118638. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118639. /**
  118640. * Teleports the users feet to the desired location
  118641. * @param location The location where the user's feet should be placed
  118642. */
  118643. teleportCamera(location: Vector3): void;
  118644. private _convertNormalToDirectionOfRay;
  118645. private _castRayAndSelectObject;
  118646. private _notifySelectedMeshUnselected;
  118647. /**
  118648. * Permanently set new colors for the laser pointer
  118649. * @param color the new laser color
  118650. * @param pickedColor the new laser color when picked mesh detected
  118651. */
  118652. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118653. /**
  118654. * Set lighting enabled / disabled on the laser pointer of both controllers
  118655. * @param enabled should the lighting be enabled on the laser pointer
  118656. */
  118657. setLaserLightingState(enabled?: boolean): void;
  118658. /**
  118659. * Permanently set new colors for the gaze pointer
  118660. * @param color the new gaze color
  118661. * @param pickedColor the new gaze color when picked mesh detected
  118662. */
  118663. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118664. /**
  118665. * Sets the color of the laser ray from the vr controllers.
  118666. * @param color new color for the ray.
  118667. */
  118668. changeLaserColor(color: Color3): void;
  118669. /**
  118670. * Sets the color of the ray from the vr headsets gaze.
  118671. * @param color new color for the ray.
  118672. */
  118673. changeGazeColor(color: Color3): void;
  118674. /**
  118675. * Exits VR and disposes of the vr experience helper
  118676. */
  118677. dispose(): void;
  118678. /**
  118679. * Gets the name of the VRExperienceHelper class
  118680. * @returns "VRExperienceHelper"
  118681. */
  118682. getClassName(): string;
  118683. }
  118684. }
  118685. declare module BABYLON {
  118686. /**
  118687. * Contains an array of blocks representing the octree
  118688. */
  118689. export interface IOctreeContainer<T> {
  118690. /**
  118691. * Blocks within the octree
  118692. */
  118693. blocks: Array<OctreeBlock<T>>;
  118694. }
  118695. /**
  118696. * Class used to store a cell in an octree
  118697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118698. */
  118699. export class OctreeBlock<T> {
  118700. /**
  118701. * Gets the content of the current block
  118702. */
  118703. entries: T[];
  118704. /**
  118705. * Gets the list of block children
  118706. */
  118707. blocks: Array<OctreeBlock<T>>;
  118708. private _depth;
  118709. private _maxDepth;
  118710. private _capacity;
  118711. private _minPoint;
  118712. private _maxPoint;
  118713. private _boundingVectors;
  118714. private _creationFunc;
  118715. /**
  118716. * Creates a new block
  118717. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118718. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118719. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118720. * @param depth defines the current depth of this block in the octree
  118721. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118722. * @param creationFunc defines a callback to call when an element is added to the block
  118723. */
  118724. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118725. /**
  118726. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118727. */
  118728. get capacity(): number;
  118729. /**
  118730. * Gets the minimum vector (in world space) of the block's bounding box
  118731. */
  118732. get minPoint(): Vector3;
  118733. /**
  118734. * Gets the maximum vector (in world space) of the block's bounding box
  118735. */
  118736. get maxPoint(): Vector3;
  118737. /**
  118738. * Add a new element to this block
  118739. * @param entry defines the element to add
  118740. */
  118741. addEntry(entry: T): void;
  118742. /**
  118743. * Remove an element from this block
  118744. * @param entry defines the element to remove
  118745. */
  118746. removeEntry(entry: T): void;
  118747. /**
  118748. * Add an array of elements to this block
  118749. * @param entries defines the array of elements to add
  118750. */
  118751. addEntries(entries: T[]): void;
  118752. /**
  118753. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118754. * @param frustumPlanes defines the frustum planes to test
  118755. * @param selection defines the array to store current content if selection is positive
  118756. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118757. */
  118758. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118759. /**
  118760. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118761. * @param sphereCenter defines the bounding sphere center
  118762. * @param sphereRadius defines the bounding sphere radius
  118763. * @param selection defines the array to store current content if selection is positive
  118764. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118765. */
  118766. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118767. /**
  118768. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118769. * @param ray defines the ray to test with
  118770. * @param selection defines the array to store current content if selection is positive
  118771. */
  118772. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118773. /**
  118774. * Subdivide the content into child blocks (this block will then be empty)
  118775. */
  118776. createInnerBlocks(): void;
  118777. /**
  118778. * @hidden
  118779. */
  118780. 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;
  118781. }
  118782. }
  118783. declare module BABYLON {
  118784. /**
  118785. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118786. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118787. */
  118788. export class Octree<T> {
  118789. /** 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.) */
  118790. maxDepth: number;
  118791. /**
  118792. * Blocks within the octree containing objects
  118793. */
  118794. blocks: Array<OctreeBlock<T>>;
  118795. /**
  118796. * Content stored in the octree
  118797. */
  118798. dynamicContent: T[];
  118799. private _maxBlockCapacity;
  118800. private _selectionContent;
  118801. private _creationFunc;
  118802. /**
  118803. * Creates a octree
  118804. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118805. * @param creationFunc function to be used to instatiate the octree
  118806. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118807. * @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.)
  118808. */
  118809. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118810. /** 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. maxDepth?: number);
  118812. /**
  118813. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118814. * @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);
  118815. * @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);
  118816. * @param entries meshes to be added to the octree blocks
  118817. */
  118818. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118819. /**
  118820. * Adds a mesh to the octree
  118821. * @param entry Mesh to add to the octree
  118822. */
  118823. addMesh(entry: T): void;
  118824. /**
  118825. * Remove an element from the octree
  118826. * @param entry defines the element to remove
  118827. */
  118828. removeMesh(entry: T): void;
  118829. /**
  118830. * Selects an array of meshes within the frustum
  118831. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118832. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118833. * @returns array of meshes within the frustum
  118834. */
  118835. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118836. /**
  118837. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118838. * @param sphereCenter defines the bounding sphere center
  118839. * @param sphereRadius defines the bounding sphere radius
  118840. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118841. * @returns an array of objects that intersect the sphere
  118842. */
  118843. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118844. /**
  118845. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118846. * @param ray defines the ray to test with
  118847. * @returns array of intersected objects
  118848. */
  118849. intersectsRay(ray: Ray): SmartArray<T>;
  118850. /**
  118851. * Adds a mesh into the octree block if it intersects the block
  118852. */
  118853. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118854. /**
  118855. * Adds a submesh into the octree block if it intersects the block
  118856. */
  118857. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118858. }
  118859. }
  118860. declare module BABYLON {
  118861. interface Scene {
  118862. /**
  118863. * @hidden
  118864. * Backing Filed
  118865. */
  118866. _selectionOctree: Octree<AbstractMesh>;
  118867. /**
  118868. * Gets the octree used to boost mesh selection (picking)
  118869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118870. */
  118871. selectionOctree: Octree<AbstractMesh>;
  118872. /**
  118873. * Creates or updates the octree used to boost selection (picking)
  118874. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118875. * @param maxCapacity defines the maximum capacity per leaf
  118876. * @param maxDepth defines the maximum depth of the octree
  118877. * @returns an octree of AbstractMesh
  118878. */
  118879. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118880. }
  118881. interface AbstractMesh {
  118882. /**
  118883. * @hidden
  118884. * Backing Field
  118885. */
  118886. _submeshesOctree: Octree<SubMesh>;
  118887. /**
  118888. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118889. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118890. * @param maxCapacity defines the maximum size of each block (64 by default)
  118891. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118892. * @returns the new octree
  118893. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118894. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118895. */
  118896. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118897. }
  118898. /**
  118899. * Defines the octree scene component responsible to manage any octrees
  118900. * in a given scene.
  118901. */
  118902. export class OctreeSceneComponent {
  118903. /**
  118904. * The component name help to identify the component in the list of scene components.
  118905. */
  118906. readonly name: string;
  118907. /**
  118908. * The scene the component belongs to.
  118909. */
  118910. scene: Scene;
  118911. /**
  118912. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118913. */
  118914. readonly checksIsEnabled: boolean;
  118915. /**
  118916. * Creates a new instance of the component for the given scene
  118917. * @param scene Defines the scene to register the component in
  118918. */
  118919. constructor(scene: Scene);
  118920. /**
  118921. * Registers the component in a given scene
  118922. */
  118923. register(): void;
  118924. /**
  118925. * Return the list of active meshes
  118926. * @returns the list of active meshes
  118927. */
  118928. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118929. /**
  118930. * Return the list of active sub meshes
  118931. * @param mesh The mesh to get the candidates sub meshes from
  118932. * @returns the list of active sub meshes
  118933. */
  118934. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118935. private _tempRay;
  118936. /**
  118937. * Return the list of sub meshes intersecting with a given local ray
  118938. * @param mesh defines the mesh to find the submesh for
  118939. * @param localRay defines the ray in local space
  118940. * @returns the list of intersecting sub meshes
  118941. */
  118942. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118943. /**
  118944. * Return the list of sub meshes colliding with a collider
  118945. * @param mesh defines the mesh to find the submesh for
  118946. * @param collider defines the collider to evaluate the collision against
  118947. * @returns the list of colliding sub meshes
  118948. */
  118949. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118950. /**
  118951. * Rebuilds the elements related to this component in case of
  118952. * context lost for instance.
  118953. */
  118954. rebuild(): void;
  118955. /**
  118956. * Disposes the component and the associated ressources.
  118957. */
  118958. dispose(): void;
  118959. }
  118960. }
  118961. declare module BABYLON {
  118962. /**
  118963. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118964. */
  118965. export class Gizmo implements IDisposable {
  118966. /** The utility layer the gizmo will be added to */
  118967. gizmoLayer: UtilityLayerRenderer;
  118968. /**
  118969. * The root mesh of the gizmo
  118970. */
  118971. _rootMesh: Mesh;
  118972. private _attachedMesh;
  118973. /**
  118974. * Ratio for the scale of the gizmo (Default: 1)
  118975. */
  118976. scaleRatio: number;
  118977. /**
  118978. * If a custom mesh has been set (Default: false)
  118979. */
  118980. protected _customMeshSet: boolean;
  118981. /**
  118982. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118983. * * When set, interactions will be enabled
  118984. */
  118985. get attachedMesh(): Nullable<AbstractMesh>;
  118986. set attachedMesh(value: Nullable<AbstractMesh>);
  118987. /**
  118988. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118989. * @param mesh The mesh to replace the default mesh of the gizmo
  118990. */
  118991. setCustomMesh(mesh: Mesh): void;
  118992. /**
  118993. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118994. */
  118995. updateGizmoRotationToMatchAttachedMesh: boolean;
  118996. /**
  118997. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118998. */
  118999. updateGizmoPositionToMatchAttachedMesh: boolean;
  119000. /**
  119001. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119002. */
  119003. updateScale: boolean;
  119004. protected _interactionsEnabled: boolean;
  119005. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119006. private _beforeRenderObserver;
  119007. private _tempVector;
  119008. /**
  119009. * Creates a gizmo
  119010. * @param gizmoLayer The utility layer the gizmo will be added to
  119011. */
  119012. constructor(
  119013. /** The utility layer the gizmo will be added to */
  119014. gizmoLayer?: UtilityLayerRenderer);
  119015. /**
  119016. * Updates the gizmo to match the attached mesh's position/rotation
  119017. */
  119018. protected _update(): void;
  119019. /**
  119020. * Disposes of the gizmo
  119021. */
  119022. dispose(): void;
  119023. }
  119024. }
  119025. declare module BABYLON {
  119026. /**
  119027. * Single plane drag gizmo
  119028. */
  119029. export class PlaneDragGizmo extends Gizmo {
  119030. /**
  119031. * Drag behavior responsible for the gizmos dragging interactions
  119032. */
  119033. dragBehavior: PointerDragBehavior;
  119034. private _pointerObserver;
  119035. /**
  119036. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119037. */
  119038. snapDistance: number;
  119039. /**
  119040. * Event that fires each time the gizmo snaps to a new location.
  119041. * * snapDistance is the the change in distance
  119042. */
  119043. onSnapObservable: Observable<{
  119044. snapDistance: number;
  119045. }>;
  119046. private _plane;
  119047. private _coloredMaterial;
  119048. private _hoverMaterial;
  119049. private _isEnabled;
  119050. private _parent;
  119051. /** @hidden */
  119052. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119053. /** @hidden */
  119054. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119055. /**
  119056. * Creates a PlaneDragGizmo
  119057. * @param gizmoLayer The utility layer the gizmo will be added to
  119058. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119059. * @param color The color of the gizmo
  119060. */
  119061. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119062. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119063. /**
  119064. * If the gizmo is enabled
  119065. */
  119066. set isEnabled(value: boolean);
  119067. get isEnabled(): boolean;
  119068. /**
  119069. * Disposes of the gizmo
  119070. */
  119071. dispose(): void;
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. /**
  119076. * Gizmo that enables dragging a mesh along 3 axis
  119077. */
  119078. export class PositionGizmo extends Gizmo {
  119079. /**
  119080. * Internal gizmo used for interactions on the x axis
  119081. */
  119082. xGizmo: AxisDragGizmo;
  119083. /**
  119084. * Internal gizmo used for interactions on the y axis
  119085. */
  119086. yGizmo: AxisDragGizmo;
  119087. /**
  119088. * Internal gizmo used for interactions on the z axis
  119089. */
  119090. zGizmo: AxisDragGizmo;
  119091. /**
  119092. * Internal gizmo used for interactions on the yz plane
  119093. */
  119094. xPlaneGizmo: PlaneDragGizmo;
  119095. /**
  119096. * Internal gizmo used for interactions on the xz plane
  119097. */
  119098. yPlaneGizmo: PlaneDragGizmo;
  119099. /**
  119100. * Internal gizmo used for interactions on the xy plane
  119101. */
  119102. zPlaneGizmo: PlaneDragGizmo;
  119103. /**
  119104. * private variables
  119105. */
  119106. private _meshAttached;
  119107. private _updateGizmoRotationToMatchAttachedMesh;
  119108. private _snapDistance;
  119109. private _scaleRatio;
  119110. /** Fires an event when any of it's sub gizmos are dragged */
  119111. onDragStartObservable: Observable<unknown>;
  119112. /** Fires an event when any of it's sub gizmos are released from dragging */
  119113. onDragEndObservable: Observable<unknown>;
  119114. /**
  119115. * If set to true, planar drag is enabled
  119116. */
  119117. private _planarGizmoEnabled;
  119118. get attachedMesh(): Nullable<AbstractMesh>;
  119119. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119120. /**
  119121. * Creates a PositionGizmo
  119122. * @param gizmoLayer The utility layer the gizmo will be added to
  119123. */
  119124. constructor(gizmoLayer?: UtilityLayerRenderer);
  119125. /**
  119126. * If the planar drag gizmo is enabled
  119127. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119128. */
  119129. set planarGizmoEnabled(value: boolean);
  119130. get planarGizmoEnabled(): boolean;
  119131. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119132. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119133. /**
  119134. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119135. */
  119136. set snapDistance(value: number);
  119137. get snapDistance(): number;
  119138. /**
  119139. * Ratio for the scale of the gizmo (Default: 1)
  119140. */
  119141. set scaleRatio(value: number);
  119142. get scaleRatio(): number;
  119143. /**
  119144. * Disposes of the gizmo
  119145. */
  119146. dispose(): void;
  119147. /**
  119148. * CustomMeshes are not supported by this gizmo
  119149. * @param mesh The mesh to replace the default mesh of the gizmo
  119150. */
  119151. setCustomMesh(mesh: Mesh): void;
  119152. }
  119153. }
  119154. declare module BABYLON {
  119155. /**
  119156. * Single axis drag gizmo
  119157. */
  119158. export class AxisDragGizmo extends Gizmo {
  119159. /**
  119160. * Drag behavior responsible for the gizmos dragging interactions
  119161. */
  119162. dragBehavior: PointerDragBehavior;
  119163. private _pointerObserver;
  119164. /**
  119165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119166. */
  119167. snapDistance: number;
  119168. /**
  119169. * Event that fires each time the gizmo snaps to a new location.
  119170. * * snapDistance is the the change in distance
  119171. */
  119172. onSnapObservable: Observable<{
  119173. snapDistance: number;
  119174. }>;
  119175. private _isEnabled;
  119176. private _parent;
  119177. private _arrow;
  119178. private _coloredMaterial;
  119179. private _hoverMaterial;
  119180. /** @hidden */
  119181. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119182. /** @hidden */
  119183. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119184. /**
  119185. * Creates an AxisDragGizmo
  119186. * @param gizmoLayer The utility layer the gizmo will be added to
  119187. * @param dragAxis The axis which the gizmo will be able to drag on
  119188. * @param color The color of the gizmo
  119189. */
  119190. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119191. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119192. /**
  119193. * If the gizmo is enabled
  119194. */
  119195. set isEnabled(value: boolean);
  119196. get isEnabled(): boolean;
  119197. /**
  119198. * Disposes of the gizmo
  119199. */
  119200. dispose(): void;
  119201. }
  119202. }
  119203. declare module BABYLON.Debug {
  119204. /**
  119205. * The Axes viewer will show 3 axes in a specific point in space
  119206. */
  119207. export class AxesViewer {
  119208. private _xAxis;
  119209. private _yAxis;
  119210. private _zAxis;
  119211. private _scaleLinesFactor;
  119212. private _instanced;
  119213. /**
  119214. * Gets the hosting scene
  119215. */
  119216. scene: Scene;
  119217. /**
  119218. * Gets or sets a number used to scale line length
  119219. */
  119220. scaleLines: number;
  119221. /** Gets the node hierarchy used to render x-axis */
  119222. get xAxis(): TransformNode;
  119223. /** Gets the node hierarchy used to render y-axis */
  119224. get yAxis(): TransformNode;
  119225. /** Gets the node hierarchy used to render z-axis */
  119226. get zAxis(): TransformNode;
  119227. /**
  119228. * Creates a new AxesViewer
  119229. * @param scene defines the hosting scene
  119230. * @param scaleLines defines a number used to scale line length (1 by default)
  119231. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119232. * @param xAxis defines the node hierarchy used to render the x-axis
  119233. * @param yAxis defines the node hierarchy used to render the y-axis
  119234. * @param zAxis defines the node hierarchy used to render the z-axis
  119235. */
  119236. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119237. /**
  119238. * Force the viewer to update
  119239. * @param position defines the position of the viewer
  119240. * @param xaxis defines the x axis of the viewer
  119241. * @param yaxis defines the y axis of the viewer
  119242. * @param zaxis defines the z axis of the viewer
  119243. */
  119244. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119245. /**
  119246. * Creates an instance of this axes viewer.
  119247. * @returns a new axes viewer with instanced meshes
  119248. */
  119249. createInstance(): AxesViewer;
  119250. /** Releases resources */
  119251. dispose(): void;
  119252. private static _SetRenderingGroupId;
  119253. }
  119254. }
  119255. declare module BABYLON.Debug {
  119256. /**
  119257. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119258. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119259. */
  119260. export class BoneAxesViewer extends AxesViewer {
  119261. /**
  119262. * Gets or sets the target mesh where to display the axes viewer
  119263. */
  119264. mesh: Nullable<Mesh>;
  119265. /**
  119266. * Gets or sets the target bone where to display the axes viewer
  119267. */
  119268. bone: Nullable<Bone>;
  119269. /** Gets current position */
  119270. pos: Vector3;
  119271. /** Gets direction of X axis */
  119272. xaxis: Vector3;
  119273. /** Gets direction of Y axis */
  119274. yaxis: Vector3;
  119275. /** Gets direction of Z axis */
  119276. zaxis: Vector3;
  119277. /**
  119278. * Creates a new BoneAxesViewer
  119279. * @param scene defines the hosting scene
  119280. * @param bone defines the target bone
  119281. * @param mesh defines the target mesh
  119282. * @param scaleLines defines a scaling factor for line length (1 by default)
  119283. */
  119284. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119285. /**
  119286. * Force the viewer to update
  119287. */
  119288. update(): void;
  119289. /** Releases resources */
  119290. dispose(): void;
  119291. }
  119292. }
  119293. declare module BABYLON {
  119294. /**
  119295. * Interface used to define scene explorer extensibility option
  119296. */
  119297. export interface IExplorerExtensibilityOption {
  119298. /**
  119299. * Define the option label
  119300. */
  119301. label: string;
  119302. /**
  119303. * Defines the action to execute on click
  119304. */
  119305. action: (entity: any) => void;
  119306. }
  119307. /**
  119308. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119309. */
  119310. export interface IExplorerExtensibilityGroup {
  119311. /**
  119312. * Defines a predicate to test if a given type mut be extended
  119313. */
  119314. predicate: (entity: any) => boolean;
  119315. /**
  119316. * Gets the list of options added to a type
  119317. */
  119318. entries: IExplorerExtensibilityOption[];
  119319. }
  119320. /**
  119321. * Interface used to define the options to use to create the Inspector
  119322. */
  119323. export interface IInspectorOptions {
  119324. /**
  119325. * Display in overlay mode (default: false)
  119326. */
  119327. overlay?: boolean;
  119328. /**
  119329. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119330. */
  119331. globalRoot?: HTMLElement;
  119332. /**
  119333. * Display the Scene explorer
  119334. */
  119335. showExplorer?: boolean;
  119336. /**
  119337. * Display the property inspector
  119338. */
  119339. showInspector?: boolean;
  119340. /**
  119341. * Display in embed mode (both panes on the right)
  119342. */
  119343. embedMode?: boolean;
  119344. /**
  119345. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119346. */
  119347. handleResize?: boolean;
  119348. /**
  119349. * Allow the panes to popup (default: true)
  119350. */
  119351. enablePopup?: boolean;
  119352. /**
  119353. * Allow the panes to be closed by users (default: true)
  119354. */
  119355. enableClose?: boolean;
  119356. /**
  119357. * Optional list of extensibility entries
  119358. */
  119359. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119360. /**
  119361. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119362. */
  119363. inspectorURL?: string;
  119364. /**
  119365. * Optional initial tab (default to DebugLayerTab.Properties)
  119366. */
  119367. initialTab?: DebugLayerTab;
  119368. }
  119369. interface Scene {
  119370. /**
  119371. * @hidden
  119372. * Backing field
  119373. */
  119374. _debugLayer: DebugLayer;
  119375. /**
  119376. * Gets the debug layer (aka Inspector) associated with the scene
  119377. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119378. */
  119379. debugLayer: DebugLayer;
  119380. }
  119381. /**
  119382. * Enum of inspector action tab
  119383. */
  119384. export enum DebugLayerTab {
  119385. /**
  119386. * Properties tag (default)
  119387. */
  119388. Properties = 0,
  119389. /**
  119390. * Debug tab
  119391. */
  119392. Debug = 1,
  119393. /**
  119394. * Statistics tab
  119395. */
  119396. Statistics = 2,
  119397. /**
  119398. * Tools tab
  119399. */
  119400. Tools = 3,
  119401. /**
  119402. * Settings tab
  119403. */
  119404. Settings = 4
  119405. }
  119406. /**
  119407. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119408. * what is happening in your scene
  119409. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119410. */
  119411. export class DebugLayer {
  119412. /**
  119413. * Define the url to get the inspector script from.
  119414. * By default it uses the babylonjs CDN.
  119415. * @ignoreNaming
  119416. */
  119417. static InspectorURL: string;
  119418. private _scene;
  119419. private BJSINSPECTOR;
  119420. private _onPropertyChangedObservable?;
  119421. /**
  119422. * Observable triggered when a property is changed through the inspector.
  119423. */
  119424. get onPropertyChangedObservable(): any;
  119425. /**
  119426. * Instantiates a new debug layer.
  119427. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119428. * what is happening in your scene
  119429. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119430. * @param scene Defines the scene to inspect
  119431. */
  119432. constructor(scene: Scene);
  119433. /** Creates the inspector window. */
  119434. private _createInspector;
  119435. /**
  119436. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119437. * @param entity defines the entity to select
  119438. * @param lineContainerTitle defines the specific block to highlight
  119439. */
  119440. select(entity: any, lineContainerTitle?: string): void;
  119441. /** Get the inspector from bundle or global */
  119442. private _getGlobalInspector;
  119443. /**
  119444. * Get if the inspector is visible or not.
  119445. * @returns true if visible otherwise, false
  119446. */
  119447. isVisible(): boolean;
  119448. /**
  119449. * Hide the inspector and close its window.
  119450. */
  119451. hide(): void;
  119452. /**
  119453. * Launch the debugLayer.
  119454. * @param config Define the configuration of the inspector
  119455. * @return a promise fulfilled when the debug layer is visible
  119456. */
  119457. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119458. }
  119459. }
  119460. declare module BABYLON {
  119461. /**
  119462. * Class containing static functions to help procedurally build meshes
  119463. */
  119464. export class BoxBuilder {
  119465. /**
  119466. * Creates a box mesh
  119467. * * The parameter `size` sets the size (float) of each box side (default 1)
  119468. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119469. * * 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)
  119470. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119472. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119474. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119475. * @param name defines the name of the mesh
  119476. * @param options defines the options used to create the mesh
  119477. * @param scene defines the hosting scene
  119478. * @returns the box mesh
  119479. */
  119480. static CreateBox(name: string, options: {
  119481. size?: number;
  119482. width?: number;
  119483. height?: number;
  119484. depth?: number;
  119485. faceUV?: Vector4[];
  119486. faceColors?: Color4[];
  119487. sideOrientation?: number;
  119488. frontUVs?: Vector4;
  119489. backUVs?: Vector4;
  119490. wrap?: boolean;
  119491. topBaseAt?: number;
  119492. bottomBaseAt?: number;
  119493. updatable?: boolean;
  119494. }, scene?: Nullable<Scene>): Mesh;
  119495. }
  119496. }
  119497. declare module BABYLON.Debug {
  119498. /**
  119499. * Used to show the physics impostor around the specific mesh
  119500. */
  119501. export class PhysicsViewer {
  119502. /** @hidden */
  119503. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119504. /** @hidden */
  119505. protected _meshes: Array<Nullable<AbstractMesh>>;
  119506. /** @hidden */
  119507. protected _scene: Nullable<Scene>;
  119508. /** @hidden */
  119509. protected _numMeshes: number;
  119510. /** @hidden */
  119511. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119512. private _renderFunction;
  119513. private _utilityLayer;
  119514. private _debugBoxMesh;
  119515. private _debugSphereMesh;
  119516. private _debugCylinderMesh;
  119517. private _debugMaterial;
  119518. private _debugMeshMeshes;
  119519. /**
  119520. * Creates a new PhysicsViewer
  119521. * @param scene defines the hosting scene
  119522. */
  119523. constructor(scene: Scene);
  119524. /** @hidden */
  119525. protected _updateDebugMeshes(): void;
  119526. /**
  119527. * Renders a specified physic impostor
  119528. * @param impostor defines the impostor to render
  119529. * @param targetMesh defines the mesh represented by the impostor
  119530. * @returns the new debug mesh used to render the impostor
  119531. */
  119532. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119533. /**
  119534. * Hides a specified physic impostor
  119535. * @param impostor defines the impostor to hide
  119536. */
  119537. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119538. private _getDebugMaterial;
  119539. private _getDebugBoxMesh;
  119540. private _getDebugSphereMesh;
  119541. private _getDebugCylinderMesh;
  119542. private _getDebugMeshMesh;
  119543. private _getDebugMesh;
  119544. /** Releases all resources */
  119545. dispose(): void;
  119546. }
  119547. }
  119548. declare module BABYLON {
  119549. /**
  119550. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119551. * in order to better appreciate the issue one might have.
  119552. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119553. */
  119554. export class RayHelper {
  119555. /**
  119556. * Defines the ray we are currently tryin to visualize.
  119557. */
  119558. ray: Nullable<Ray>;
  119559. private _renderPoints;
  119560. private _renderLine;
  119561. private _renderFunction;
  119562. private _scene;
  119563. private _updateToMeshFunction;
  119564. private _attachedToMesh;
  119565. private _meshSpaceDirection;
  119566. private _meshSpaceOrigin;
  119567. /**
  119568. * Helper function to create a colored helper in a scene in one line.
  119569. * @param ray Defines the ray we are currently tryin to visualize
  119570. * @param scene Defines the scene the ray is used in
  119571. * @param color Defines the color we want to see the ray in
  119572. * @returns The newly created ray helper.
  119573. */
  119574. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119575. /**
  119576. * Instantiate a new ray helper.
  119577. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119578. * in order to better appreciate the issue one might have.
  119579. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119580. * @param ray Defines the ray we are currently tryin to visualize
  119581. */
  119582. constructor(ray: Ray);
  119583. /**
  119584. * Shows the ray we are willing to debug.
  119585. * @param scene Defines the scene the ray needs to be rendered in
  119586. * @param color Defines the color the ray needs to be rendered in
  119587. */
  119588. show(scene: Scene, color?: Color3): void;
  119589. /**
  119590. * Hides the ray we are debugging.
  119591. */
  119592. hide(): void;
  119593. private _render;
  119594. /**
  119595. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119596. * @param mesh Defines the mesh we want the helper attached to
  119597. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119598. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119599. * @param length Defines the length of the ray
  119600. */
  119601. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119602. /**
  119603. * Detach the ray helper from the mesh it has previously been attached to.
  119604. */
  119605. detachFromMesh(): void;
  119606. private _updateToMesh;
  119607. /**
  119608. * Dispose the helper and release its associated resources.
  119609. */
  119610. dispose(): void;
  119611. }
  119612. }
  119613. declare module BABYLON.Debug {
  119614. /**
  119615. * Class used to render a debug view of a given skeleton
  119616. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119617. */
  119618. export class SkeletonViewer {
  119619. /** defines the skeleton to render */
  119620. skeleton: Skeleton;
  119621. /** defines the mesh attached to the skeleton */
  119622. mesh: AbstractMesh;
  119623. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119624. autoUpdateBonesMatrices: boolean;
  119625. /** defines the rendering group id to use with the viewer */
  119626. renderingGroupId: number;
  119627. /** Gets or sets the color used to render the skeleton */
  119628. color: Color3;
  119629. private _scene;
  119630. private _debugLines;
  119631. private _debugMesh;
  119632. private _isEnabled;
  119633. private _renderFunction;
  119634. private _utilityLayer;
  119635. /**
  119636. * Returns the mesh used to render the bones
  119637. */
  119638. get debugMesh(): Nullable<LinesMesh>;
  119639. /**
  119640. * Creates a new SkeletonViewer
  119641. * @param skeleton defines the skeleton to render
  119642. * @param mesh defines the mesh attached to the skeleton
  119643. * @param scene defines the hosting scene
  119644. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119645. * @param renderingGroupId defines the rendering group id to use with the viewer
  119646. */
  119647. constructor(
  119648. /** defines the skeleton to render */
  119649. skeleton: Skeleton,
  119650. /** defines the mesh attached to the skeleton */
  119651. mesh: AbstractMesh, scene: Scene,
  119652. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119653. autoUpdateBonesMatrices?: boolean,
  119654. /** defines the rendering group id to use with the viewer */
  119655. renderingGroupId?: number);
  119656. /** Gets or sets a boolean indicating if the viewer is enabled */
  119657. set isEnabled(value: boolean);
  119658. get isEnabled(): boolean;
  119659. private _getBonePosition;
  119660. private _getLinesForBonesWithLength;
  119661. private _getLinesForBonesNoLength;
  119662. /** Update the viewer to sync with current skeleton state */
  119663. update(): void;
  119664. /** Release associated resources */
  119665. dispose(): void;
  119666. }
  119667. }
  119668. declare module BABYLON {
  119669. /**
  119670. * Options to create the null engine
  119671. */
  119672. export class NullEngineOptions {
  119673. /**
  119674. * Render width (Default: 512)
  119675. */
  119676. renderWidth: number;
  119677. /**
  119678. * Render height (Default: 256)
  119679. */
  119680. renderHeight: number;
  119681. /**
  119682. * Texture size (Default: 512)
  119683. */
  119684. textureSize: number;
  119685. /**
  119686. * If delta time between frames should be constant
  119687. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119688. */
  119689. deterministicLockstep: boolean;
  119690. /**
  119691. * Maximum about of steps between frames (Default: 4)
  119692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119693. */
  119694. lockstepMaxSteps: number;
  119695. }
  119696. /**
  119697. * The null engine class provides support for headless version of babylon.js.
  119698. * This can be used in server side scenario or for testing purposes
  119699. */
  119700. export class NullEngine extends Engine {
  119701. private _options;
  119702. /**
  119703. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119704. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119705. * @returns true if engine is in deterministic lock step mode
  119706. */
  119707. isDeterministicLockStep(): boolean;
  119708. /**
  119709. * Gets the max steps when engine is running in deterministic lock step
  119710. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119711. * @returns the max steps
  119712. */
  119713. getLockstepMaxSteps(): number;
  119714. /**
  119715. * Gets the current hardware scaling level.
  119716. * By default the hardware scaling level is computed from the window device ratio.
  119717. * 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.
  119718. * @returns a number indicating the current hardware scaling level
  119719. */
  119720. getHardwareScalingLevel(): number;
  119721. constructor(options?: NullEngineOptions);
  119722. /**
  119723. * Creates a vertex buffer
  119724. * @param vertices the data for the vertex buffer
  119725. * @returns the new WebGL static buffer
  119726. */
  119727. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119728. /**
  119729. * Creates a new index buffer
  119730. * @param indices defines the content of the index buffer
  119731. * @param updatable defines if the index buffer must be updatable
  119732. * @returns a new webGL buffer
  119733. */
  119734. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119735. /**
  119736. * Clear the current render buffer or the current render target (if any is set up)
  119737. * @param color defines the color to use
  119738. * @param backBuffer defines if the back buffer must be cleared
  119739. * @param depth defines if the depth buffer must be cleared
  119740. * @param stencil defines if the stencil buffer must be cleared
  119741. */
  119742. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119743. /**
  119744. * Gets the current render width
  119745. * @param useScreen defines if screen size must be used (or the current render target if any)
  119746. * @returns a number defining the current render width
  119747. */
  119748. getRenderWidth(useScreen?: boolean): number;
  119749. /**
  119750. * Gets the current render height
  119751. * @param useScreen defines if screen size must be used (or the current render target if any)
  119752. * @returns a number defining the current render height
  119753. */
  119754. getRenderHeight(useScreen?: boolean): number;
  119755. /**
  119756. * Set the WebGL's viewport
  119757. * @param viewport defines the viewport element to be used
  119758. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119759. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119760. */
  119761. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119762. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119763. /**
  119764. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119765. * @param pipelineContext defines the pipeline context to use
  119766. * @param uniformsNames defines the list of uniform names
  119767. * @returns an array of webGL uniform locations
  119768. */
  119769. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119770. /**
  119771. * Gets the lsit of active attributes for a given webGL program
  119772. * @param pipelineContext defines the pipeline context to use
  119773. * @param attributesNames defines the list of attribute names to get
  119774. * @returns an array of indices indicating the offset of each attribute
  119775. */
  119776. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119777. /**
  119778. * Binds an effect to the webGL context
  119779. * @param effect defines the effect to bind
  119780. */
  119781. bindSamplers(effect: Effect): void;
  119782. /**
  119783. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119784. * @param effect defines the effect to activate
  119785. */
  119786. enableEffect(effect: Effect): void;
  119787. /**
  119788. * Set various states to the webGL context
  119789. * @param culling defines backface culling state
  119790. * @param zOffset defines the value to apply to zOffset (0 by default)
  119791. * @param force defines if states must be applied even if cache is up to date
  119792. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119793. */
  119794. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119795. /**
  119796. * Set the value of an uniform to an array of int32
  119797. * @param uniform defines the webGL uniform location where to store the value
  119798. * @param array defines the array of int32 to store
  119799. */
  119800. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119801. /**
  119802. * Set the value of an uniform to an array of int32 (stored as vec2)
  119803. * @param uniform defines the webGL uniform location where to store the value
  119804. * @param array defines the array of int32 to store
  119805. */
  119806. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119807. /**
  119808. * Set the value of an uniform to an array of int32 (stored as vec3)
  119809. * @param uniform defines the webGL uniform location where to store the value
  119810. * @param array defines the array of int32 to store
  119811. */
  119812. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119813. /**
  119814. * Set the value of an uniform to an array of int32 (stored as vec4)
  119815. * @param uniform defines the webGL uniform location where to store the value
  119816. * @param array defines the array of int32 to store
  119817. */
  119818. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119819. /**
  119820. * Set the value of an uniform to an array of float32
  119821. * @param uniform defines the webGL uniform location where to store the value
  119822. * @param array defines the array of float32 to store
  119823. */
  119824. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119825. /**
  119826. * Set the value of an uniform to an array of float32 (stored as vec2)
  119827. * @param uniform defines the webGL uniform location where to store the value
  119828. * @param array defines the array of float32 to store
  119829. */
  119830. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119831. /**
  119832. * Set the value of an uniform to an array of float32 (stored as vec3)
  119833. * @param uniform defines the webGL uniform location where to store the value
  119834. * @param array defines the array of float32 to store
  119835. */
  119836. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119837. /**
  119838. * Set the value of an uniform to an array of float32 (stored as vec4)
  119839. * @param uniform defines the webGL uniform location where to store the value
  119840. * @param array defines the array of float32 to store
  119841. */
  119842. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119843. /**
  119844. * Set the value of an uniform to an array of number
  119845. * @param uniform defines the webGL uniform location where to store the value
  119846. * @param array defines the array of number to store
  119847. */
  119848. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119849. /**
  119850. * Set the value of an uniform to an array of number (stored as vec2)
  119851. * @param uniform defines the webGL uniform location where to store the value
  119852. * @param array defines the array of number to store
  119853. */
  119854. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119855. /**
  119856. * Set the value of an uniform to an array of number (stored as vec3)
  119857. * @param uniform defines the webGL uniform location where to store the value
  119858. * @param array defines the array of number to store
  119859. */
  119860. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119861. /**
  119862. * Set the value of an uniform to an array of number (stored as vec4)
  119863. * @param uniform defines the webGL uniform location where to store the value
  119864. * @param array defines the array of number to store
  119865. */
  119866. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119867. /**
  119868. * Set the value of an uniform to an array of float32 (stored as matrices)
  119869. * @param uniform defines the webGL uniform location where to store the value
  119870. * @param matrices defines the array of float32 to store
  119871. */
  119872. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119873. /**
  119874. * Set the value of an uniform to a matrix (3x3)
  119875. * @param uniform defines the webGL uniform location where to store the value
  119876. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119877. */
  119878. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119879. /**
  119880. * Set the value of an uniform to a matrix (2x2)
  119881. * @param uniform defines the webGL uniform location where to store the value
  119882. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119883. */
  119884. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119885. /**
  119886. * Set the value of an uniform to a number (float)
  119887. * @param uniform defines the webGL uniform location where to store the value
  119888. * @param value defines the float number to store
  119889. */
  119890. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119891. /**
  119892. * Set the value of an uniform to a vec2
  119893. * @param uniform defines the webGL uniform location where to store the value
  119894. * @param x defines the 1st component of the value
  119895. * @param y defines the 2nd component of the value
  119896. */
  119897. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119898. /**
  119899. * Set the value of an uniform to a vec3
  119900. * @param uniform defines the webGL uniform location where to store the value
  119901. * @param x defines the 1st component of the value
  119902. * @param y defines the 2nd component of the value
  119903. * @param z defines the 3rd component of the value
  119904. */
  119905. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119906. /**
  119907. * Set the value of an uniform to a boolean
  119908. * @param uniform defines the webGL uniform location where to store the value
  119909. * @param bool defines the boolean to store
  119910. */
  119911. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119912. /**
  119913. * Set the value of an uniform to a vec4
  119914. * @param uniform defines the webGL uniform location where to store the value
  119915. * @param x defines the 1st component of the value
  119916. * @param y defines the 2nd component of the value
  119917. * @param z defines the 3rd component of the value
  119918. * @param w defines the 4th component of the value
  119919. */
  119920. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119921. /**
  119922. * Sets the current alpha mode
  119923. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119924. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119925. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119926. */
  119927. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119928. /**
  119929. * Bind webGl buffers directly to the webGL context
  119930. * @param vertexBuffers defines the vertex buffer to bind
  119931. * @param indexBuffer defines the index buffer to bind
  119932. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119933. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119934. * @param effect defines the effect associated with the vertex buffer
  119935. */
  119936. bindBuffers(vertexBuffers: {
  119937. [key: string]: VertexBuffer;
  119938. }, indexBuffer: DataBuffer, effect: Effect): void;
  119939. /**
  119940. * Force the entire cache to be cleared
  119941. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119942. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119943. */
  119944. wipeCaches(bruteForce?: boolean): void;
  119945. /**
  119946. * Send a draw order
  119947. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119948. * @param indexStart defines the starting index
  119949. * @param indexCount defines the number of index to draw
  119950. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119951. */
  119952. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119953. /**
  119954. * Draw a list of indexed primitives
  119955. * @param fillMode defines the primitive to use
  119956. * @param indexStart defines the starting index
  119957. * @param indexCount defines the number of index to draw
  119958. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119959. */
  119960. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119961. /**
  119962. * Draw a list of unindexed primitives
  119963. * @param fillMode defines the primitive to use
  119964. * @param verticesStart defines the index of first vertex to draw
  119965. * @param verticesCount defines the count of vertices to draw
  119966. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119967. */
  119968. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119969. /** @hidden */
  119970. _createTexture(): WebGLTexture;
  119971. /** @hidden */
  119972. _releaseTexture(texture: InternalTexture): void;
  119973. /**
  119974. * Usually called from Texture.ts.
  119975. * Passed information to create a WebGLTexture
  119976. * @param urlArg defines a value which contains one of the following:
  119977. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119978. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119979. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119980. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119981. * @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)
  119982. * @param scene needed for loading to the correct scene
  119983. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119984. * @param onLoad optional callback to be called upon successful completion
  119985. * @param onError optional callback to be called upon failure
  119986. * @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
  119987. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119988. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119989. * @param forcedExtension defines the extension to use to pick the right loader
  119990. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  119991. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119992. */
  119993. 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;
  119994. /**
  119995. * Creates a new render target texture
  119996. * @param size defines the size of the texture
  119997. * @param options defines the options used to create the texture
  119998. * @returns a new render target texture stored in an InternalTexture
  119999. */
  120000. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120001. /**
  120002. * Update the sampling mode of a given texture
  120003. * @param samplingMode defines the required sampling mode
  120004. * @param texture defines the texture to update
  120005. */
  120006. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120007. /**
  120008. * Binds the frame buffer to the specified texture.
  120009. * @param texture The texture to render to or null for the default canvas
  120010. * @param faceIndex The face of the texture to render to in case of cube texture
  120011. * @param requiredWidth The width of the target to render to
  120012. * @param requiredHeight The height of the target to render to
  120013. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120014. * @param lodLevel defines le lod level to bind to the frame buffer
  120015. */
  120016. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120017. /**
  120018. * Unbind the current render target texture from the webGL context
  120019. * @param texture defines the render target texture to unbind
  120020. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120021. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120022. */
  120023. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120024. /**
  120025. * Creates a dynamic vertex buffer
  120026. * @param vertices the data for the dynamic vertex buffer
  120027. * @returns the new WebGL dynamic buffer
  120028. */
  120029. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120030. /**
  120031. * Update the content of a dynamic texture
  120032. * @param texture defines the texture to update
  120033. * @param canvas defines the canvas containing the source
  120034. * @param invertY defines if data must be stored with Y axis inverted
  120035. * @param premulAlpha defines if alpha is stored as premultiplied
  120036. * @param format defines the format of the data
  120037. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120038. */
  120039. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120040. /**
  120041. * Gets a boolean indicating if all created effects are ready
  120042. * @returns true if all effects are ready
  120043. */
  120044. areAllEffectsReady(): boolean;
  120045. /**
  120046. * @hidden
  120047. * Get the current error code of the webGL context
  120048. * @returns the error code
  120049. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120050. */
  120051. getError(): number;
  120052. /** @hidden */
  120053. _getUnpackAlignement(): number;
  120054. /** @hidden */
  120055. _unpackFlipY(value: boolean): void;
  120056. /**
  120057. * Update a dynamic index buffer
  120058. * @param indexBuffer defines the target index buffer
  120059. * @param indices defines the data to update
  120060. * @param offset defines the offset in the target index buffer where update should start
  120061. */
  120062. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120063. /**
  120064. * Updates a dynamic vertex buffer.
  120065. * @param vertexBuffer the vertex buffer to update
  120066. * @param vertices the data used to update the vertex buffer
  120067. * @param byteOffset the byte offset of the data (optional)
  120068. * @param byteLength the byte length of the data (optional)
  120069. */
  120070. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120071. /** @hidden */
  120072. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120073. /** @hidden */
  120074. _bindTexture(channel: number, texture: InternalTexture): void;
  120075. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120076. /**
  120077. * 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
  120078. */
  120079. releaseEffects(): void;
  120080. displayLoadingUI(): void;
  120081. hideLoadingUI(): void;
  120082. /** @hidden */
  120083. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120084. /** @hidden */
  120085. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120086. /** @hidden */
  120087. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120088. /** @hidden */
  120089. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120090. }
  120091. }
  120092. declare module BABYLON {
  120093. /**
  120094. * @hidden
  120095. **/
  120096. export class _TimeToken {
  120097. _startTimeQuery: Nullable<WebGLQuery>;
  120098. _endTimeQuery: Nullable<WebGLQuery>;
  120099. _timeElapsedQuery: Nullable<WebGLQuery>;
  120100. _timeElapsedQueryEnded: boolean;
  120101. }
  120102. }
  120103. declare module BABYLON {
  120104. /** @hidden */
  120105. export class _OcclusionDataStorage {
  120106. /** @hidden */
  120107. occlusionInternalRetryCounter: number;
  120108. /** @hidden */
  120109. isOcclusionQueryInProgress: boolean;
  120110. /** @hidden */
  120111. isOccluded: boolean;
  120112. /** @hidden */
  120113. occlusionRetryCount: number;
  120114. /** @hidden */
  120115. occlusionType: number;
  120116. /** @hidden */
  120117. occlusionQueryAlgorithmType: number;
  120118. }
  120119. interface Engine {
  120120. /**
  120121. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120122. * @return the new query
  120123. */
  120124. createQuery(): WebGLQuery;
  120125. /**
  120126. * Delete and release a webGL query
  120127. * @param query defines the query to delete
  120128. * @return the current engine
  120129. */
  120130. deleteQuery(query: WebGLQuery): Engine;
  120131. /**
  120132. * Check if a given query has resolved and got its value
  120133. * @param query defines the query to check
  120134. * @returns true if the query got its value
  120135. */
  120136. isQueryResultAvailable(query: WebGLQuery): boolean;
  120137. /**
  120138. * Gets the value of a given query
  120139. * @param query defines the query to check
  120140. * @returns the value of the query
  120141. */
  120142. getQueryResult(query: WebGLQuery): number;
  120143. /**
  120144. * Initiates an occlusion query
  120145. * @param algorithmType defines the algorithm to use
  120146. * @param query defines the query to use
  120147. * @returns the current engine
  120148. * @see http://doc.babylonjs.com/features/occlusionquery
  120149. */
  120150. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120151. /**
  120152. * Ends an occlusion query
  120153. * @see http://doc.babylonjs.com/features/occlusionquery
  120154. * @param algorithmType defines the algorithm to use
  120155. * @returns the current engine
  120156. */
  120157. endOcclusionQuery(algorithmType: number): Engine;
  120158. /**
  120159. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120160. * Please note that only one query can be issued at a time
  120161. * @returns a time token used to track the time span
  120162. */
  120163. startTimeQuery(): Nullable<_TimeToken>;
  120164. /**
  120165. * Ends a time query
  120166. * @param token defines the token used to measure the time span
  120167. * @returns the time spent (in ns)
  120168. */
  120169. endTimeQuery(token: _TimeToken): int;
  120170. /** @hidden */
  120171. _currentNonTimestampToken: Nullable<_TimeToken>;
  120172. /** @hidden */
  120173. _createTimeQuery(): WebGLQuery;
  120174. /** @hidden */
  120175. _deleteTimeQuery(query: WebGLQuery): void;
  120176. /** @hidden */
  120177. _getGlAlgorithmType(algorithmType: number): number;
  120178. /** @hidden */
  120179. _getTimeQueryResult(query: WebGLQuery): any;
  120180. /** @hidden */
  120181. _getTimeQueryAvailability(query: WebGLQuery): any;
  120182. }
  120183. interface AbstractMesh {
  120184. /**
  120185. * Backing filed
  120186. * @hidden
  120187. */
  120188. __occlusionDataStorage: _OcclusionDataStorage;
  120189. /**
  120190. * Access property
  120191. * @hidden
  120192. */
  120193. _occlusionDataStorage: _OcclusionDataStorage;
  120194. /**
  120195. * 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.
  120196. * The default value is -1 which means don't break the query and wait till the result
  120197. * @see http://doc.babylonjs.com/features/occlusionquery
  120198. */
  120199. occlusionRetryCount: number;
  120200. /**
  120201. * 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:
  120202. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120203. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120204. * * 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.
  120205. * @see http://doc.babylonjs.com/features/occlusionquery
  120206. */
  120207. occlusionType: number;
  120208. /**
  120209. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120210. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120211. * * 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.
  120212. * @see http://doc.babylonjs.com/features/occlusionquery
  120213. */
  120214. occlusionQueryAlgorithmType: number;
  120215. /**
  120216. * 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
  120217. * @see http://doc.babylonjs.com/features/occlusionquery
  120218. */
  120219. isOccluded: boolean;
  120220. /**
  120221. * Flag to check the progress status of the query
  120222. * @see http://doc.babylonjs.com/features/occlusionquery
  120223. */
  120224. isOcclusionQueryInProgress: boolean;
  120225. }
  120226. }
  120227. declare module BABYLON {
  120228. /** @hidden */
  120229. export var _forceTransformFeedbackToBundle: boolean;
  120230. interface Engine {
  120231. /**
  120232. * Creates a webGL transform feedback object
  120233. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120234. * @returns the webGL transform feedback object
  120235. */
  120236. createTransformFeedback(): WebGLTransformFeedback;
  120237. /**
  120238. * Delete a webGL transform feedback object
  120239. * @param value defines the webGL transform feedback object to delete
  120240. */
  120241. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120242. /**
  120243. * Bind a webGL transform feedback object to the webgl context
  120244. * @param value defines the webGL transform feedback object to bind
  120245. */
  120246. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120247. /**
  120248. * Begins a transform feedback operation
  120249. * @param usePoints defines if points or triangles must be used
  120250. */
  120251. beginTransformFeedback(usePoints: boolean): void;
  120252. /**
  120253. * Ends a transform feedback operation
  120254. */
  120255. endTransformFeedback(): void;
  120256. /**
  120257. * Specify the varyings to use with transform feedback
  120258. * @param program defines the associated webGL program
  120259. * @param value defines the list of strings representing the varying names
  120260. */
  120261. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120262. /**
  120263. * Bind a webGL buffer for a transform feedback operation
  120264. * @param value defines the webGL buffer to bind
  120265. */
  120266. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120267. }
  120268. }
  120269. declare module BABYLON {
  120270. /**
  120271. * Creation options of the multi render target texture.
  120272. */
  120273. export interface IMultiRenderTargetOptions {
  120274. /**
  120275. * Define if the texture needs to create mip maps after render.
  120276. */
  120277. generateMipMaps?: boolean;
  120278. /**
  120279. * Define the types of all the draw buffers we want to create
  120280. */
  120281. types?: number[];
  120282. /**
  120283. * Define the sampling modes of all the draw buffers we want to create
  120284. */
  120285. samplingModes?: number[];
  120286. /**
  120287. * Define if a depth buffer is required
  120288. */
  120289. generateDepthBuffer?: boolean;
  120290. /**
  120291. * Define if a stencil buffer is required
  120292. */
  120293. generateStencilBuffer?: boolean;
  120294. /**
  120295. * Define if a depth texture is required instead of a depth buffer
  120296. */
  120297. generateDepthTexture?: boolean;
  120298. /**
  120299. * Define the number of desired draw buffers
  120300. */
  120301. textureCount?: number;
  120302. /**
  120303. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120304. */
  120305. doNotChangeAspectRatio?: boolean;
  120306. /**
  120307. * Define the default type of the buffers we are creating
  120308. */
  120309. defaultType?: number;
  120310. }
  120311. /**
  120312. * A multi render target, like a render target provides the ability to render to a texture.
  120313. * Unlike the render target, it can render to several draw buffers in one draw.
  120314. * This is specially interesting in deferred rendering or for any effects requiring more than
  120315. * just one color from a single pass.
  120316. */
  120317. export class MultiRenderTarget extends RenderTargetTexture {
  120318. private _internalTextures;
  120319. private _textures;
  120320. private _multiRenderTargetOptions;
  120321. /**
  120322. * Get if draw buffers are currently supported by the used hardware and browser.
  120323. */
  120324. get isSupported(): boolean;
  120325. /**
  120326. * Get the list of textures generated by the multi render target.
  120327. */
  120328. get textures(): Texture[];
  120329. /**
  120330. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120331. */
  120332. get depthTexture(): Texture;
  120333. /**
  120334. * Set the wrapping mode on U of all the textures we are rendering to.
  120335. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120336. */
  120337. set wrapU(wrap: number);
  120338. /**
  120339. * Set the wrapping mode on V of all the textures we are rendering to.
  120340. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120341. */
  120342. set wrapV(wrap: number);
  120343. /**
  120344. * Instantiate a new multi render target texture.
  120345. * A multi render target, like a render target provides the ability to render to a texture.
  120346. * Unlike the render target, it can render to several draw buffers in one draw.
  120347. * This is specially interesting in deferred rendering or for any effects requiring more than
  120348. * just one color from a single pass.
  120349. * @param name Define the name of the texture
  120350. * @param size Define the size of the buffers to render to
  120351. * @param count Define the number of target we are rendering into
  120352. * @param scene Define the scene the texture belongs to
  120353. * @param options Define the options used to create the multi render target
  120354. */
  120355. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120356. /** @hidden */
  120357. _rebuild(): void;
  120358. private _createInternalTextures;
  120359. private _createTextures;
  120360. /**
  120361. * Define the number of samples used if MSAA is enabled.
  120362. */
  120363. get samples(): number;
  120364. set samples(value: number);
  120365. /**
  120366. * Resize all the textures in the multi render target.
  120367. * Be carrefull as it will recreate all the data in the new texture.
  120368. * @param size Define the new size
  120369. */
  120370. resize(size: any): void;
  120371. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120372. /**
  120373. * Dispose the render targets and their associated resources
  120374. */
  120375. dispose(): void;
  120376. /**
  120377. * Release all the underlying texture used as draw buffers.
  120378. */
  120379. releaseInternalTextures(): void;
  120380. }
  120381. }
  120382. declare module BABYLON {
  120383. interface ThinEngine {
  120384. /**
  120385. * Unbind a list of render target textures from the webGL context
  120386. * This is used only when drawBuffer extension or webGL2 are active
  120387. * @param textures defines the render target textures to unbind
  120388. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120389. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120390. */
  120391. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120392. /**
  120393. * Create a multi render target texture
  120394. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120395. * @param size defines the size of the texture
  120396. * @param options defines the creation options
  120397. * @returns the cube texture as an InternalTexture
  120398. */
  120399. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120400. /**
  120401. * Update the sample count for a given multiple render target texture
  120402. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120403. * @param textures defines the textures to update
  120404. * @param samples defines the sample count to set
  120405. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120406. */
  120407. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120408. }
  120409. }
  120410. declare module BABYLON {
  120411. /**
  120412. * Class used to define an additional view for the engine
  120413. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120414. */
  120415. export class EngineView {
  120416. /** Defines the canvas where to render the view */
  120417. target: HTMLCanvasElement;
  120418. /** Defines an optional camera used to render the view (will use active camera else) */
  120419. camera?: Camera;
  120420. }
  120421. interface Engine {
  120422. /**
  120423. * Gets or sets the HTML element to use for attaching events
  120424. */
  120425. inputElement: Nullable<HTMLElement>;
  120426. /**
  120427. * Gets the current engine view
  120428. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120429. */
  120430. activeView: Nullable<EngineView>;
  120431. /** Gets or sets the list of views */
  120432. views: EngineView[];
  120433. /**
  120434. * Register a new child canvas
  120435. * @param canvas defines the canvas to register
  120436. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120437. * @returns the associated view
  120438. */
  120439. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120440. /**
  120441. * Remove a registered child canvas
  120442. * @param canvas defines the canvas to remove
  120443. * @returns the current engine
  120444. */
  120445. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120446. }
  120447. }
  120448. declare module BABYLON {
  120449. /**
  120450. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120451. */
  120452. export interface CubeMapInfo {
  120453. /**
  120454. * The pixel array for the front face.
  120455. * This is stored in format, left to right, up to down format.
  120456. */
  120457. front: Nullable<ArrayBufferView>;
  120458. /**
  120459. * The pixel array for the back face.
  120460. * This is stored in format, left to right, up to down format.
  120461. */
  120462. back: Nullable<ArrayBufferView>;
  120463. /**
  120464. * The pixel array for the left face.
  120465. * This is stored in format, left to right, up to down format.
  120466. */
  120467. left: Nullable<ArrayBufferView>;
  120468. /**
  120469. * The pixel array for the right face.
  120470. * This is stored in format, left to right, up to down format.
  120471. */
  120472. right: Nullable<ArrayBufferView>;
  120473. /**
  120474. * The pixel array for the up face.
  120475. * This is stored in format, left to right, up to down format.
  120476. */
  120477. up: Nullable<ArrayBufferView>;
  120478. /**
  120479. * The pixel array for the down face.
  120480. * This is stored in format, left to right, up to down format.
  120481. */
  120482. down: Nullable<ArrayBufferView>;
  120483. /**
  120484. * The size of the cubemap stored.
  120485. *
  120486. * Each faces will be size * size pixels.
  120487. */
  120488. size: number;
  120489. /**
  120490. * The format of the texture.
  120491. *
  120492. * RGBA, RGB.
  120493. */
  120494. format: number;
  120495. /**
  120496. * The type of the texture data.
  120497. *
  120498. * UNSIGNED_INT, FLOAT.
  120499. */
  120500. type: number;
  120501. /**
  120502. * Specifies whether the texture is in gamma space.
  120503. */
  120504. gammaSpace: boolean;
  120505. }
  120506. /**
  120507. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120508. */
  120509. export class PanoramaToCubeMapTools {
  120510. private static FACE_FRONT;
  120511. private static FACE_BACK;
  120512. private static FACE_RIGHT;
  120513. private static FACE_LEFT;
  120514. private static FACE_DOWN;
  120515. private static FACE_UP;
  120516. /**
  120517. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120518. *
  120519. * @param float32Array The source data.
  120520. * @param inputWidth The width of the input panorama.
  120521. * @param inputHeight The height of the input panorama.
  120522. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120523. * @return The cubemap data
  120524. */
  120525. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120526. private static CreateCubemapTexture;
  120527. private static CalcProjectionSpherical;
  120528. }
  120529. }
  120530. declare module BABYLON {
  120531. /**
  120532. * Helper class dealing with the extraction of spherical polynomial dataArray
  120533. * from a cube map.
  120534. */
  120535. export class CubeMapToSphericalPolynomialTools {
  120536. private static FileFaces;
  120537. /**
  120538. * Converts a texture to the according Spherical Polynomial data.
  120539. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120540. *
  120541. * @param texture The texture to extract the information from.
  120542. * @return The Spherical Polynomial data.
  120543. */
  120544. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120545. /**
  120546. * Converts a cubemap to the according Spherical Polynomial data.
  120547. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120548. *
  120549. * @param cubeInfo The Cube map to extract the information from.
  120550. * @return The Spherical Polynomial data.
  120551. */
  120552. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120553. }
  120554. }
  120555. declare module BABYLON {
  120556. interface BaseTexture {
  120557. /**
  120558. * Get the polynomial representation of the texture data.
  120559. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120560. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120561. */
  120562. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120563. }
  120564. }
  120565. declare module BABYLON {
  120566. /** @hidden */
  120567. export var rgbdEncodePixelShader: {
  120568. name: string;
  120569. shader: string;
  120570. };
  120571. }
  120572. declare module BABYLON {
  120573. /** @hidden */
  120574. export var rgbdDecodePixelShader: {
  120575. name: string;
  120576. shader: string;
  120577. };
  120578. }
  120579. declare module BABYLON {
  120580. /**
  120581. * Raw texture data and descriptor sufficient for WebGL texture upload
  120582. */
  120583. export interface EnvironmentTextureInfo {
  120584. /**
  120585. * Version of the environment map
  120586. */
  120587. version: number;
  120588. /**
  120589. * Width of image
  120590. */
  120591. width: number;
  120592. /**
  120593. * Irradiance information stored in the file.
  120594. */
  120595. irradiance: any;
  120596. /**
  120597. * Specular information stored in the file.
  120598. */
  120599. specular: any;
  120600. }
  120601. /**
  120602. * Defines One Image in the file. It requires only the position in the file
  120603. * as well as the length.
  120604. */
  120605. interface BufferImageData {
  120606. /**
  120607. * Length of the image data.
  120608. */
  120609. length: number;
  120610. /**
  120611. * Position of the data from the null terminator delimiting the end of the JSON.
  120612. */
  120613. position: number;
  120614. }
  120615. /**
  120616. * Defines the specular data enclosed in the file.
  120617. * This corresponds to the version 1 of the data.
  120618. */
  120619. export interface EnvironmentTextureSpecularInfoV1 {
  120620. /**
  120621. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120622. */
  120623. specularDataPosition?: number;
  120624. /**
  120625. * This contains all the images data needed to reconstruct the cubemap.
  120626. */
  120627. mipmaps: Array<BufferImageData>;
  120628. /**
  120629. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120630. */
  120631. lodGenerationScale: number;
  120632. }
  120633. /**
  120634. * Sets of helpers addressing the serialization and deserialization of environment texture
  120635. * stored in a BabylonJS env file.
  120636. * Those files are usually stored as .env files.
  120637. */
  120638. export class EnvironmentTextureTools {
  120639. /**
  120640. * Magic number identifying the env file.
  120641. */
  120642. private static _MagicBytes;
  120643. /**
  120644. * Gets the environment info from an env file.
  120645. * @param data The array buffer containing the .env bytes.
  120646. * @returns the environment file info (the json header) if successfully parsed.
  120647. */
  120648. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120649. /**
  120650. * Creates an environment texture from a loaded cube texture.
  120651. * @param texture defines the cube texture to convert in env file
  120652. * @return a promise containing the environment data if succesfull.
  120653. */
  120654. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120655. /**
  120656. * Creates a JSON representation of the spherical data.
  120657. * @param texture defines the texture containing the polynomials
  120658. * @return the JSON representation of the spherical info
  120659. */
  120660. private static _CreateEnvTextureIrradiance;
  120661. /**
  120662. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120663. * @param data the image data
  120664. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120665. * @return the views described by info providing access to the underlying buffer
  120666. */
  120667. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120668. /**
  120669. * Uploads the texture info contained in the env file to the GPU.
  120670. * @param texture defines the internal texture to upload to
  120671. * @param data defines the data to load
  120672. * @param info defines the texture info retrieved through the GetEnvInfo method
  120673. * @returns a promise
  120674. */
  120675. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120676. private static _OnImageReadyAsync;
  120677. /**
  120678. * Uploads the levels of image data to the GPU.
  120679. * @param texture defines the internal texture to upload to
  120680. * @param imageData defines the array buffer views of image data [mipmap][face]
  120681. * @returns a promise
  120682. */
  120683. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120684. /**
  120685. * Uploads spherical polynomials information to the texture.
  120686. * @param texture defines the texture we are trying to upload the information to
  120687. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120688. */
  120689. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120690. /** @hidden */
  120691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120692. }
  120693. }
  120694. declare module BABYLON {
  120695. /**
  120696. * Contains position and normal vectors for a vertex
  120697. */
  120698. export class PositionNormalVertex {
  120699. /** the position of the vertex (defaut: 0,0,0) */
  120700. position: Vector3;
  120701. /** the normal of the vertex (defaut: 0,1,0) */
  120702. normal: Vector3;
  120703. /**
  120704. * Creates a PositionNormalVertex
  120705. * @param position the position of the vertex (defaut: 0,0,0)
  120706. * @param normal the normal of the vertex (defaut: 0,1,0)
  120707. */
  120708. constructor(
  120709. /** the position of the vertex (defaut: 0,0,0) */
  120710. position?: Vector3,
  120711. /** the normal of the vertex (defaut: 0,1,0) */
  120712. normal?: Vector3);
  120713. /**
  120714. * Clones the PositionNormalVertex
  120715. * @returns the cloned PositionNormalVertex
  120716. */
  120717. clone(): PositionNormalVertex;
  120718. }
  120719. /**
  120720. * Contains position, normal and uv vectors for a vertex
  120721. */
  120722. export class PositionNormalTextureVertex {
  120723. /** the position of the vertex (defaut: 0,0,0) */
  120724. position: Vector3;
  120725. /** the normal of the vertex (defaut: 0,1,0) */
  120726. normal: Vector3;
  120727. /** the uv of the vertex (default: 0,0) */
  120728. uv: Vector2;
  120729. /**
  120730. * Creates a PositionNormalTextureVertex
  120731. * @param position the position of the vertex (defaut: 0,0,0)
  120732. * @param normal the normal of the vertex (defaut: 0,1,0)
  120733. * @param uv the uv of the vertex (default: 0,0)
  120734. */
  120735. constructor(
  120736. /** the position of the vertex (defaut: 0,0,0) */
  120737. position?: Vector3,
  120738. /** the normal of the vertex (defaut: 0,1,0) */
  120739. normal?: Vector3,
  120740. /** the uv of the vertex (default: 0,0) */
  120741. uv?: Vector2);
  120742. /**
  120743. * Clones the PositionNormalTextureVertex
  120744. * @returns the cloned PositionNormalTextureVertex
  120745. */
  120746. clone(): PositionNormalTextureVertex;
  120747. }
  120748. }
  120749. declare module BABYLON {
  120750. /** @hidden */
  120751. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120752. private _genericAttributeLocation;
  120753. private _varyingLocationCount;
  120754. private _varyingLocationMap;
  120755. private _replacements;
  120756. private _textureCount;
  120757. private _uniforms;
  120758. lineProcessor(line: string): string;
  120759. attributeProcessor(attribute: string): string;
  120760. varyingProcessor(varying: string, isFragment: boolean): string;
  120761. uniformProcessor(uniform: string): string;
  120762. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120763. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120764. }
  120765. }
  120766. declare module BABYLON {
  120767. /**
  120768. * Container for accessors for natively-stored mesh data buffers.
  120769. */
  120770. class NativeDataBuffer extends DataBuffer {
  120771. /**
  120772. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120773. */
  120774. nativeIndexBuffer?: any;
  120775. /**
  120776. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120777. */
  120778. nativeVertexBuffer?: any;
  120779. }
  120780. /** @hidden */
  120781. class NativeTexture extends InternalTexture {
  120782. getInternalTexture(): InternalTexture;
  120783. getViewCount(): number;
  120784. }
  120785. /** @hidden */
  120786. export class NativeEngine extends Engine {
  120787. private readonly _native;
  120788. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120789. private readonly INVALID_HANDLE;
  120790. getHardwareScalingLevel(): number;
  120791. constructor();
  120792. /**
  120793. * Can be used to override the current requestAnimationFrame requester.
  120794. * @hidden
  120795. */
  120796. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120797. /**
  120798. * Override default engine behavior.
  120799. * @param color
  120800. * @param backBuffer
  120801. * @param depth
  120802. * @param stencil
  120803. */
  120804. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120805. /**
  120806. * Gets host document
  120807. * @returns the host document object
  120808. */
  120809. getHostDocument(): Nullable<Document>;
  120810. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120811. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120812. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120813. recordVertexArrayObject(vertexBuffers: {
  120814. [key: string]: VertexBuffer;
  120815. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120816. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120817. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120818. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120819. /**
  120820. * Draw a list of indexed primitives
  120821. * @param fillMode defines the primitive to use
  120822. * @param indexStart defines the starting index
  120823. * @param indexCount defines the number of index to draw
  120824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120825. */
  120826. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120827. /**
  120828. * Draw a list of unindexed primitives
  120829. * @param fillMode defines the primitive to use
  120830. * @param verticesStart defines the index of first vertex to draw
  120831. * @param verticesCount defines the count of vertices to draw
  120832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120833. */
  120834. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120835. createPipelineContext(): IPipelineContext;
  120836. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120837. /** @hidden */
  120838. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120839. /** @hidden */
  120840. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120841. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120842. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120843. protected _setProgram(program: WebGLProgram): void;
  120844. _releaseEffect(effect: Effect): void;
  120845. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120846. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120847. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120848. bindSamplers(effect: Effect): void;
  120849. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120850. getRenderWidth(useScreen?: boolean): number;
  120851. getRenderHeight(useScreen?: boolean): number;
  120852. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120853. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120854. /**
  120855. * Set the z offset to apply to current rendering
  120856. * @param value defines the offset to apply
  120857. */
  120858. setZOffset(value: number): void;
  120859. /**
  120860. * Gets the current value of the zOffset
  120861. * @returns the current zOffset state
  120862. */
  120863. getZOffset(): number;
  120864. /**
  120865. * Enable or disable depth buffering
  120866. * @param enable defines the state to set
  120867. */
  120868. setDepthBuffer(enable: boolean): void;
  120869. /**
  120870. * Gets a boolean indicating if depth writing is enabled
  120871. * @returns the current depth writing state
  120872. */
  120873. getDepthWrite(): boolean;
  120874. /**
  120875. * Enable or disable depth writing
  120876. * @param enable defines the state to set
  120877. */
  120878. setDepthWrite(enable: boolean): void;
  120879. /**
  120880. * Enable or disable color writing
  120881. * @param enable defines the state to set
  120882. */
  120883. setColorWrite(enable: boolean): void;
  120884. /**
  120885. * Gets a boolean indicating if color writing is enabled
  120886. * @returns the current color writing state
  120887. */
  120888. getColorWrite(): boolean;
  120889. /**
  120890. * Sets alpha constants used by some alpha blending modes
  120891. * @param r defines the red component
  120892. * @param g defines the green component
  120893. * @param b defines the blue component
  120894. * @param a defines the alpha component
  120895. */
  120896. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120897. /**
  120898. * Sets the current alpha mode
  120899. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120900. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120901. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120902. */
  120903. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120904. /**
  120905. * Gets the current alpha mode
  120906. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120907. * @returns the current alpha mode
  120908. */
  120909. getAlphaMode(): number;
  120910. setInt(uniform: WebGLUniformLocation, int: number): void;
  120911. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120912. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120913. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120914. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120915. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120916. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120917. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120918. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120919. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120920. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120921. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120922. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120923. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120924. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120925. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120926. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120927. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120928. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120929. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120930. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120931. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120932. wipeCaches(bruteForce?: boolean): void;
  120933. _createTexture(): WebGLTexture;
  120934. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120935. /**
  120936. * Usually called from BABYLON.Texture.ts.
  120937. * Passed information to create a WebGLTexture
  120938. * @param urlArg defines a value which contains one of the following:
  120939. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120940. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120941. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120942. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120943. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  120944. * @param scene needed for loading to the correct scene
  120945. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  120946. * @param onLoad optional callback to be called upon successful completion
  120947. * @param onError optional callback to be called upon failure
  120948. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  120949. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120950. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120951. * @param forcedExtension defines the extension to use to pick the right loader
  120952. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120953. */
  120954. 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;
  120955. /**
  120956. * Creates a cube texture
  120957. * @param rootUrl defines the url where the files to load is located
  120958. * @param scene defines the current scene
  120959. * @param files defines the list of files to load (1 per face)
  120960. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120961. * @param onLoad defines an optional callback raised when the texture is loaded
  120962. * @param onError defines an optional callback raised if there is an issue to load the texture
  120963. * @param format defines the format of the data
  120964. * @param forcedExtension defines the extension to use to pick the right loader
  120965. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120968. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120969. * @returns the cube texture as an InternalTexture
  120970. */
  120971. 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;
  120972. private _getSamplingFilter;
  120973. private static _GetNativeTextureFormat;
  120974. createRenderTargetTexture(size: number | {
  120975. width: number;
  120976. height: number;
  120977. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120978. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120979. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120980. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120981. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120982. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120983. /**
  120984. * Updates a dynamic vertex buffer.
  120985. * @param vertexBuffer the vertex buffer to update
  120986. * @param data the data used to update the vertex buffer
  120987. * @param byteOffset the byte offset of the data (optional)
  120988. * @param byteLength the byte length of the data (optional)
  120989. */
  120990. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120991. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120992. private _updateAnisotropicLevel;
  120993. private _getAddressMode;
  120994. /** @hidden */
  120995. _bindTexture(channel: number, texture: InternalTexture): void;
  120996. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120997. releaseEffects(): void;
  120998. /** @hidden */
  120999. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121000. /** @hidden */
  121001. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121002. /** @hidden */
  121003. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121004. /** @hidden */
  121005. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121006. }
  121007. }
  121008. declare module BABYLON {
  121009. /**
  121010. * Gather the list of clipboard event types as constants.
  121011. */
  121012. export class ClipboardEventTypes {
  121013. /**
  121014. * The clipboard event is fired when a copy command is active (pressed).
  121015. */
  121016. static readonly COPY: number;
  121017. /**
  121018. * The clipboard event is fired when a cut command is active (pressed).
  121019. */
  121020. static readonly CUT: number;
  121021. /**
  121022. * The clipboard event is fired when a paste command is active (pressed).
  121023. */
  121024. static readonly PASTE: number;
  121025. }
  121026. /**
  121027. * This class is used to store clipboard related info for the onClipboardObservable event.
  121028. */
  121029. export class ClipboardInfo {
  121030. /**
  121031. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121032. */
  121033. type: number;
  121034. /**
  121035. * Defines the related dom event
  121036. */
  121037. event: ClipboardEvent;
  121038. /**
  121039. *Creates an instance of ClipboardInfo.
  121040. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121041. * @param event Defines the related dom event
  121042. */
  121043. constructor(
  121044. /**
  121045. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121046. */
  121047. type: number,
  121048. /**
  121049. * Defines the related dom event
  121050. */
  121051. event: ClipboardEvent);
  121052. /**
  121053. * Get the clipboard event's type from the keycode.
  121054. * @param keyCode Defines the keyCode for the current keyboard event.
  121055. * @return {number}
  121056. */
  121057. static GetTypeFromCharacter(keyCode: number): number;
  121058. }
  121059. }
  121060. declare module BABYLON {
  121061. /**
  121062. * Google Daydream controller
  121063. */
  121064. export class DaydreamController extends WebVRController {
  121065. /**
  121066. * Base Url for the controller model.
  121067. */
  121068. static MODEL_BASE_URL: string;
  121069. /**
  121070. * File name for the controller model.
  121071. */
  121072. static MODEL_FILENAME: string;
  121073. /**
  121074. * Gamepad Id prefix used to identify Daydream Controller.
  121075. */
  121076. static readonly GAMEPAD_ID_PREFIX: string;
  121077. /**
  121078. * Creates a new DaydreamController from a gamepad
  121079. * @param vrGamepad the gamepad that the controller should be created from
  121080. */
  121081. constructor(vrGamepad: any);
  121082. /**
  121083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121084. * @param scene scene in which to add meshes
  121085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121086. */
  121087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121088. /**
  121089. * Called once for each button that changed state since the last frame
  121090. * @param buttonIdx Which button index changed
  121091. * @param state New state of the button
  121092. * @param changes Which properties on the state changed since last frame
  121093. */
  121094. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121095. }
  121096. }
  121097. declare module BABYLON {
  121098. /**
  121099. * Gear VR Controller
  121100. */
  121101. export class GearVRController extends WebVRController {
  121102. /**
  121103. * Base Url for the controller model.
  121104. */
  121105. static MODEL_BASE_URL: string;
  121106. /**
  121107. * File name for the controller model.
  121108. */
  121109. static MODEL_FILENAME: string;
  121110. /**
  121111. * Gamepad Id prefix used to identify this controller.
  121112. */
  121113. static readonly GAMEPAD_ID_PREFIX: string;
  121114. private readonly _buttonIndexToObservableNameMap;
  121115. /**
  121116. * Creates a new GearVRController from a gamepad
  121117. * @param vrGamepad the gamepad that the controller should be created from
  121118. */
  121119. constructor(vrGamepad: any);
  121120. /**
  121121. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121122. * @param scene scene in which to add meshes
  121123. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121124. */
  121125. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121126. /**
  121127. * Called once for each button that changed state since the last frame
  121128. * @param buttonIdx Which button index changed
  121129. * @param state New state of the button
  121130. * @param changes Which properties on the state changed since last frame
  121131. */
  121132. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121133. }
  121134. }
  121135. declare module BABYLON {
  121136. /**
  121137. * Generic Controller
  121138. */
  121139. export class GenericController extends WebVRController {
  121140. /**
  121141. * Base Url for the controller model.
  121142. */
  121143. static readonly MODEL_BASE_URL: string;
  121144. /**
  121145. * File name for the controller model.
  121146. */
  121147. static readonly MODEL_FILENAME: string;
  121148. /**
  121149. * Creates a new GenericController from a gamepad
  121150. * @param vrGamepad the gamepad that the controller should be created from
  121151. */
  121152. constructor(vrGamepad: any);
  121153. /**
  121154. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121155. * @param scene scene in which to add meshes
  121156. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121157. */
  121158. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121159. /**
  121160. * Called once for each button that changed state since the last frame
  121161. * @param buttonIdx Which button index changed
  121162. * @param state New state of the button
  121163. * @param changes Which properties on the state changed since last frame
  121164. */
  121165. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121166. }
  121167. }
  121168. declare module BABYLON {
  121169. /**
  121170. * Oculus Touch Controller
  121171. */
  121172. export class OculusTouchController extends WebVRController {
  121173. /**
  121174. * Base Url for the controller model.
  121175. */
  121176. static MODEL_BASE_URL: string;
  121177. /**
  121178. * File name for the left controller model.
  121179. */
  121180. static MODEL_LEFT_FILENAME: string;
  121181. /**
  121182. * File name for the right controller model.
  121183. */
  121184. static MODEL_RIGHT_FILENAME: string;
  121185. /**
  121186. * Base Url for the Quest controller model.
  121187. */
  121188. static QUEST_MODEL_BASE_URL: string;
  121189. /**
  121190. * @hidden
  121191. * If the controllers are running on a device that needs the updated Quest controller models
  121192. */
  121193. static _IsQuest: boolean;
  121194. /**
  121195. * Fired when the secondary trigger on this controller is modified
  121196. */
  121197. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121198. /**
  121199. * Fired when the thumb rest on this controller is modified
  121200. */
  121201. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121202. /**
  121203. * Creates a new OculusTouchController from a gamepad
  121204. * @param vrGamepad the gamepad that the controller should be created from
  121205. */
  121206. constructor(vrGamepad: any);
  121207. /**
  121208. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121209. * @param scene scene in which to add meshes
  121210. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121211. */
  121212. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121213. /**
  121214. * Fired when the A button on this controller is modified
  121215. */
  121216. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121217. /**
  121218. * Fired when the B button on this controller is modified
  121219. */
  121220. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121221. /**
  121222. * Fired when the X button on this controller is modified
  121223. */
  121224. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121225. /**
  121226. * Fired when the Y button on this controller is modified
  121227. */
  121228. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121229. /**
  121230. * Called once for each button that changed state since the last frame
  121231. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121232. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121233. * 2) secondary trigger (same)
  121234. * 3) A (right) X (left), touch, pressed = value
  121235. * 4) B / Y
  121236. * 5) thumb rest
  121237. * @param buttonIdx Which button index changed
  121238. * @param state New state of the button
  121239. * @param changes Which properties on the state changed since last frame
  121240. */
  121241. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121242. }
  121243. }
  121244. declare module BABYLON {
  121245. /**
  121246. * Vive Controller
  121247. */
  121248. export class ViveController extends WebVRController {
  121249. /**
  121250. * Base Url for the controller model.
  121251. */
  121252. static MODEL_BASE_URL: string;
  121253. /**
  121254. * File name for the controller model.
  121255. */
  121256. static MODEL_FILENAME: string;
  121257. /**
  121258. * Creates a new ViveController from a gamepad
  121259. * @param vrGamepad the gamepad that the controller should be created from
  121260. */
  121261. constructor(vrGamepad: any);
  121262. /**
  121263. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121264. * @param scene scene in which to add meshes
  121265. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121266. */
  121267. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121268. /**
  121269. * Fired when the left button on this controller is modified
  121270. */
  121271. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121272. /**
  121273. * Fired when the right button on this controller is modified
  121274. */
  121275. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121276. /**
  121277. * Fired when the menu button on this controller is modified
  121278. */
  121279. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121280. /**
  121281. * Called once for each button that changed state since the last frame
  121282. * Vive mapping:
  121283. * 0: touchpad
  121284. * 1: trigger
  121285. * 2: left AND right buttons
  121286. * 3: menu button
  121287. * @param buttonIdx Which button index changed
  121288. * @param state New state of the button
  121289. * @param changes Which properties on the state changed since last frame
  121290. */
  121291. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121292. }
  121293. }
  121294. declare module BABYLON {
  121295. /**
  121296. * Defines the WindowsMotionController object that the state of the windows motion controller
  121297. */
  121298. export class WindowsMotionController extends WebVRController {
  121299. /**
  121300. * The base url used to load the left and right controller models
  121301. */
  121302. static MODEL_BASE_URL: string;
  121303. /**
  121304. * The name of the left controller model file
  121305. */
  121306. static MODEL_LEFT_FILENAME: string;
  121307. /**
  121308. * The name of the right controller model file
  121309. */
  121310. static MODEL_RIGHT_FILENAME: string;
  121311. /**
  121312. * The controller name prefix for this controller type
  121313. */
  121314. static readonly GAMEPAD_ID_PREFIX: string;
  121315. /**
  121316. * The controller id pattern for this controller type
  121317. */
  121318. private static readonly GAMEPAD_ID_PATTERN;
  121319. private _loadedMeshInfo;
  121320. protected readonly _mapping: {
  121321. buttons: string[];
  121322. buttonMeshNames: {
  121323. 'trigger': string;
  121324. 'menu': string;
  121325. 'grip': string;
  121326. 'thumbstick': string;
  121327. 'trackpad': string;
  121328. };
  121329. buttonObservableNames: {
  121330. 'trigger': string;
  121331. 'menu': string;
  121332. 'grip': string;
  121333. 'thumbstick': string;
  121334. 'trackpad': string;
  121335. };
  121336. axisMeshNames: string[];
  121337. pointingPoseMeshName: string;
  121338. };
  121339. /**
  121340. * Fired when the trackpad on this controller is clicked
  121341. */
  121342. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121343. /**
  121344. * Fired when the trackpad on this controller is modified
  121345. */
  121346. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121347. /**
  121348. * The current x and y values of this controller's trackpad
  121349. */
  121350. trackpad: StickValues;
  121351. /**
  121352. * Creates a new WindowsMotionController from a gamepad
  121353. * @param vrGamepad the gamepad that the controller should be created from
  121354. */
  121355. constructor(vrGamepad: any);
  121356. /**
  121357. * Fired when the trigger on this controller is modified
  121358. */
  121359. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121360. /**
  121361. * Fired when the menu button on this controller is modified
  121362. */
  121363. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121364. /**
  121365. * Fired when the grip button on this controller is modified
  121366. */
  121367. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121368. /**
  121369. * Fired when the thumbstick button on this controller is modified
  121370. */
  121371. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121372. /**
  121373. * Fired when the touchpad button on this controller is modified
  121374. */
  121375. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121376. /**
  121377. * Fired when the touchpad values on this controller are modified
  121378. */
  121379. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121380. protected _updateTrackpad(): void;
  121381. /**
  121382. * Called once per frame by the engine.
  121383. */
  121384. update(): void;
  121385. /**
  121386. * Called once for each button that changed state since the last frame
  121387. * @param buttonIdx Which button index changed
  121388. * @param state New state of the button
  121389. * @param changes Which properties on the state changed since last frame
  121390. */
  121391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121392. /**
  121393. * Moves the buttons on the controller mesh based on their current state
  121394. * @param buttonName the name of the button to move
  121395. * @param buttonValue the value of the button which determines the buttons new position
  121396. */
  121397. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121398. /**
  121399. * Moves the axis on the controller mesh based on its current state
  121400. * @param axis the index of the axis
  121401. * @param axisValue the value of the axis which determines the meshes new position
  121402. * @hidden
  121403. */
  121404. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121405. /**
  121406. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121407. * @param scene scene in which to add meshes
  121408. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121409. */
  121410. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121411. /**
  121412. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121413. * can be transformed by button presses and axes values, based on this._mapping.
  121414. *
  121415. * @param scene scene in which the meshes exist
  121416. * @param meshes list of meshes that make up the controller model to process
  121417. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121418. */
  121419. private processModel;
  121420. private createMeshInfo;
  121421. /**
  121422. * Gets the ray of the controller in the direction the controller is pointing
  121423. * @param length the length the resulting ray should be
  121424. * @returns a ray in the direction the controller is pointing
  121425. */
  121426. getForwardRay(length?: number): Ray;
  121427. /**
  121428. * Disposes of the controller
  121429. */
  121430. dispose(): void;
  121431. }
  121432. /**
  121433. * This class represents a new windows motion controller in XR.
  121434. */
  121435. export class XRWindowsMotionController extends WindowsMotionController {
  121436. /**
  121437. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121438. */
  121439. protected readonly _mapping: {
  121440. buttons: string[];
  121441. buttonMeshNames: {
  121442. 'trigger': string;
  121443. 'menu': string;
  121444. 'grip': string;
  121445. 'thumbstick': string;
  121446. 'trackpad': string;
  121447. };
  121448. buttonObservableNames: {
  121449. 'trigger': string;
  121450. 'menu': string;
  121451. 'grip': string;
  121452. 'thumbstick': string;
  121453. 'trackpad': string;
  121454. };
  121455. axisMeshNames: string[];
  121456. pointingPoseMeshName: string;
  121457. };
  121458. /**
  121459. * Construct a new XR-Based windows motion controller
  121460. *
  121461. * @param gamepadInfo the gamepad object from the browser
  121462. */
  121463. constructor(gamepadInfo: any);
  121464. /**
  121465. * holds the thumbstick values (X,Y)
  121466. */
  121467. thumbstickValues: StickValues;
  121468. /**
  121469. * Fired when the thumbstick on this controller is clicked
  121470. */
  121471. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121472. /**
  121473. * Fired when the thumbstick on this controller is modified
  121474. */
  121475. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121476. /**
  121477. * Fired when the touchpad button on this controller is modified
  121478. */
  121479. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121480. /**
  121481. * Fired when the touchpad values on this controller are modified
  121482. */
  121483. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121484. /**
  121485. * Fired when the thumbstick button on this controller is modified
  121486. * here to prevent breaking changes
  121487. */
  121488. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121489. /**
  121490. * updating the thumbstick(!) and not the trackpad.
  121491. * This is named this way due to the difference between WebVR and XR and to avoid
  121492. * changing the parent class.
  121493. */
  121494. protected _updateTrackpad(): void;
  121495. /**
  121496. * Disposes the class with joy
  121497. */
  121498. dispose(): void;
  121499. }
  121500. }
  121501. declare module BABYLON {
  121502. /**
  121503. * Class containing static functions to help procedurally build meshes
  121504. */
  121505. export class PolyhedronBuilder {
  121506. /**
  121507. * Creates a polyhedron mesh
  121508. * * 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
  121509. * * The parameter `size` (positive float, default 1) sets the polygon size
  121510. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121511. * * 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`
  121512. * * 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
  121513. * * 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)`)
  121514. * * 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
  121515. * * 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
  121516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121519. * @param name defines the name of the mesh
  121520. * @param options defines the options used to create the mesh
  121521. * @param scene defines the hosting scene
  121522. * @returns the polyhedron mesh
  121523. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121524. */
  121525. static CreatePolyhedron(name: string, options: {
  121526. type?: number;
  121527. size?: number;
  121528. sizeX?: number;
  121529. sizeY?: number;
  121530. sizeZ?: number;
  121531. custom?: any;
  121532. faceUV?: Vector4[];
  121533. faceColors?: Color4[];
  121534. flat?: boolean;
  121535. updatable?: boolean;
  121536. sideOrientation?: number;
  121537. frontUVs?: Vector4;
  121538. backUVs?: Vector4;
  121539. }, scene?: Nullable<Scene>): Mesh;
  121540. }
  121541. }
  121542. declare module BABYLON {
  121543. /**
  121544. * Gizmo that enables scaling a mesh along 3 axis
  121545. */
  121546. export class ScaleGizmo extends Gizmo {
  121547. /**
  121548. * Internal gizmo used for interactions on the x axis
  121549. */
  121550. xGizmo: AxisScaleGizmo;
  121551. /**
  121552. * Internal gizmo used for interactions on the y axis
  121553. */
  121554. yGizmo: AxisScaleGizmo;
  121555. /**
  121556. * Internal gizmo used for interactions on the z axis
  121557. */
  121558. zGizmo: AxisScaleGizmo;
  121559. /**
  121560. * Internal gizmo used to scale all axis equally
  121561. */
  121562. uniformScaleGizmo: AxisScaleGizmo;
  121563. private _meshAttached;
  121564. private _updateGizmoRotationToMatchAttachedMesh;
  121565. private _snapDistance;
  121566. private _scaleRatio;
  121567. private _uniformScalingMesh;
  121568. private _octahedron;
  121569. private _sensitivity;
  121570. /** Fires an event when any of it's sub gizmos are dragged */
  121571. onDragStartObservable: Observable<unknown>;
  121572. /** Fires an event when any of it's sub gizmos are released from dragging */
  121573. onDragEndObservable: Observable<unknown>;
  121574. get attachedMesh(): Nullable<AbstractMesh>;
  121575. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121576. /**
  121577. * Creates a ScaleGizmo
  121578. * @param gizmoLayer The utility layer the gizmo will be added to
  121579. */
  121580. constructor(gizmoLayer?: UtilityLayerRenderer);
  121581. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121582. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121583. /**
  121584. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121585. */
  121586. set snapDistance(value: number);
  121587. get snapDistance(): number;
  121588. /**
  121589. * Ratio for the scale of the gizmo (Default: 1)
  121590. */
  121591. set scaleRatio(value: number);
  121592. get scaleRatio(): number;
  121593. /**
  121594. * Sensitivity factor for dragging (Default: 1)
  121595. */
  121596. set sensitivity(value: number);
  121597. get sensitivity(): number;
  121598. /**
  121599. * Disposes of the gizmo
  121600. */
  121601. dispose(): void;
  121602. }
  121603. }
  121604. declare module BABYLON {
  121605. /**
  121606. * Single axis scale gizmo
  121607. */
  121608. export class AxisScaleGizmo extends Gizmo {
  121609. /**
  121610. * Drag behavior responsible for the gizmos dragging interactions
  121611. */
  121612. dragBehavior: PointerDragBehavior;
  121613. private _pointerObserver;
  121614. /**
  121615. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121616. */
  121617. snapDistance: number;
  121618. /**
  121619. * Event that fires each time the gizmo snaps to a new location.
  121620. * * snapDistance is the the change in distance
  121621. */
  121622. onSnapObservable: Observable<{
  121623. snapDistance: number;
  121624. }>;
  121625. /**
  121626. * If the scaling operation should be done on all axis (default: false)
  121627. */
  121628. uniformScaling: boolean;
  121629. /**
  121630. * Custom sensitivity value for the drag strength
  121631. */
  121632. sensitivity: number;
  121633. private _isEnabled;
  121634. private _parent;
  121635. private _arrow;
  121636. private _coloredMaterial;
  121637. private _hoverMaterial;
  121638. /**
  121639. * Creates an AxisScaleGizmo
  121640. * @param gizmoLayer The utility layer the gizmo will be added to
  121641. * @param dragAxis The axis which the gizmo will be able to scale on
  121642. * @param color The color of the gizmo
  121643. */
  121644. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121645. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121646. /**
  121647. * If the gizmo is enabled
  121648. */
  121649. set isEnabled(value: boolean);
  121650. get isEnabled(): boolean;
  121651. /**
  121652. * Disposes of the gizmo
  121653. */
  121654. dispose(): void;
  121655. /**
  121656. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121657. * @param mesh The mesh to replace the default mesh of the gizmo
  121658. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121659. */
  121660. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /**
  121665. * Bounding box gizmo
  121666. */
  121667. export class BoundingBoxGizmo extends Gizmo {
  121668. private _lineBoundingBox;
  121669. private _rotateSpheresParent;
  121670. private _scaleBoxesParent;
  121671. private _boundingDimensions;
  121672. private _renderObserver;
  121673. private _pointerObserver;
  121674. private _scaleDragSpeed;
  121675. private _tmpQuaternion;
  121676. private _tmpVector;
  121677. private _tmpRotationMatrix;
  121678. /**
  121679. * 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)
  121680. */
  121681. ignoreChildren: boolean;
  121682. /**
  121683. * 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)
  121684. */
  121685. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121686. /**
  121687. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121688. */
  121689. rotationSphereSize: number;
  121690. /**
  121691. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121692. */
  121693. scaleBoxSize: number;
  121694. /**
  121695. * 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)
  121696. */
  121697. fixedDragMeshScreenSize: boolean;
  121698. /**
  121699. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121700. */
  121701. fixedDragMeshScreenSizeDistanceFactor: number;
  121702. /**
  121703. * Fired when a rotation sphere or scale box is dragged
  121704. */
  121705. onDragStartObservable: Observable<{}>;
  121706. /**
  121707. * Fired when a scale box is dragged
  121708. */
  121709. onScaleBoxDragObservable: Observable<{}>;
  121710. /**
  121711. * Fired when a scale box drag is ended
  121712. */
  121713. onScaleBoxDragEndObservable: Observable<{}>;
  121714. /**
  121715. * Fired when a rotation sphere is dragged
  121716. */
  121717. onRotationSphereDragObservable: Observable<{}>;
  121718. /**
  121719. * Fired when a rotation sphere drag is ended
  121720. */
  121721. onRotationSphereDragEndObservable: Observable<{}>;
  121722. /**
  121723. * 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)
  121724. */
  121725. scalePivot: Nullable<Vector3>;
  121726. /**
  121727. * Mesh used as a pivot to rotate the attached mesh
  121728. */
  121729. private _anchorMesh;
  121730. private _existingMeshScale;
  121731. private _dragMesh;
  121732. private pointerDragBehavior;
  121733. private coloredMaterial;
  121734. private hoverColoredMaterial;
  121735. /**
  121736. * Sets the color of the bounding box gizmo
  121737. * @param color the color to set
  121738. */
  121739. setColor(color: Color3): void;
  121740. /**
  121741. * Creates an BoundingBoxGizmo
  121742. * @param gizmoLayer The utility layer the gizmo will be added to
  121743. * @param color The color of the gizmo
  121744. */
  121745. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121746. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121747. private _selectNode;
  121748. /**
  121749. * Updates the bounding box information for the Gizmo
  121750. */
  121751. updateBoundingBox(): void;
  121752. private _updateRotationSpheres;
  121753. private _updateScaleBoxes;
  121754. /**
  121755. * Enables rotation on the specified axis and disables rotation on the others
  121756. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121757. */
  121758. setEnabledRotationAxis(axis: string): void;
  121759. /**
  121760. * Enables/disables scaling
  121761. * @param enable if scaling should be enabled
  121762. */
  121763. setEnabledScaling(enable: boolean): void;
  121764. private _updateDummy;
  121765. /**
  121766. * Enables a pointer drag behavior on the bounding box of the gizmo
  121767. */
  121768. enableDragBehavior(): void;
  121769. /**
  121770. * Disposes of the gizmo
  121771. */
  121772. dispose(): void;
  121773. /**
  121774. * 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)
  121775. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121776. * @returns the bounding box mesh with the passed in mesh as a child
  121777. */
  121778. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121779. /**
  121780. * CustomMeshes are not supported by this gizmo
  121781. * @param mesh The mesh to replace the default mesh of the gizmo
  121782. */
  121783. setCustomMesh(mesh: Mesh): void;
  121784. }
  121785. }
  121786. declare module BABYLON {
  121787. /**
  121788. * Single plane rotation gizmo
  121789. */
  121790. export class PlaneRotationGizmo extends Gizmo {
  121791. /**
  121792. * Drag behavior responsible for the gizmos dragging interactions
  121793. */
  121794. dragBehavior: PointerDragBehavior;
  121795. private _pointerObserver;
  121796. /**
  121797. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121798. */
  121799. snapDistance: number;
  121800. /**
  121801. * Event that fires each time the gizmo snaps to a new location.
  121802. * * snapDistance is the the change in distance
  121803. */
  121804. onSnapObservable: Observable<{
  121805. snapDistance: number;
  121806. }>;
  121807. private _isEnabled;
  121808. private _parent;
  121809. /**
  121810. * Creates a PlaneRotationGizmo
  121811. * @param gizmoLayer The utility layer the gizmo will be added to
  121812. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121813. * @param color The color of the gizmo
  121814. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121815. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121816. */
  121817. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121818. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121819. /**
  121820. * If the gizmo is enabled
  121821. */
  121822. set isEnabled(value: boolean);
  121823. get isEnabled(): boolean;
  121824. /**
  121825. * Disposes of the gizmo
  121826. */
  121827. dispose(): void;
  121828. }
  121829. }
  121830. declare module BABYLON {
  121831. /**
  121832. * Gizmo that enables rotating a mesh along 3 axis
  121833. */
  121834. export class RotationGizmo extends Gizmo {
  121835. /**
  121836. * Internal gizmo used for interactions on the x axis
  121837. */
  121838. xGizmo: PlaneRotationGizmo;
  121839. /**
  121840. * Internal gizmo used for interactions on the y axis
  121841. */
  121842. yGizmo: PlaneRotationGizmo;
  121843. /**
  121844. * Internal gizmo used for interactions on the z axis
  121845. */
  121846. zGizmo: PlaneRotationGizmo;
  121847. /** Fires an event when any of it's sub gizmos are dragged */
  121848. onDragStartObservable: Observable<unknown>;
  121849. /** Fires an event when any of it's sub gizmos are released from dragging */
  121850. onDragEndObservable: Observable<unknown>;
  121851. private _meshAttached;
  121852. get attachedMesh(): Nullable<AbstractMesh>;
  121853. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121854. /**
  121855. * Creates a RotationGizmo
  121856. * @param gizmoLayer The utility layer the gizmo will be added to
  121857. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121858. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121859. */
  121860. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121861. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121862. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121863. /**
  121864. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121865. */
  121866. set snapDistance(value: number);
  121867. get snapDistance(): number;
  121868. /**
  121869. * Ratio for the scale of the gizmo (Default: 1)
  121870. */
  121871. set scaleRatio(value: number);
  121872. get scaleRatio(): number;
  121873. /**
  121874. * Disposes of the gizmo
  121875. */
  121876. dispose(): void;
  121877. /**
  121878. * CustomMeshes are not supported by this gizmo
  121879. * @param mesh The mesh to replace the default mesh of the gizmo
  121880. */
  121881. setCustomMesh(mesh: Mesh): void;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121887. */
  121888. export class GizmoManager implements IDisposable {
  121889. private scene;
  121890. /**
  121891. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121892. */
  121893. gizmos: {
  121894. positionGizmo: Nullable<PositionGizmo>;
  121895. rotationGizmo: Nullable<RotationGizmo>;
  121896. scaleGizmo: Nullable<ScaleGizmo>;
  121897. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121898. };
  121899. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121900. clearGizmoOnEmptyPointerEvent: boolean;
  121901. /** Fires an event when the manager is attached to a mesh */
  121902. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121903. private _gizmosEnabled;
  121904. private _pointerObserver;
  121905. private _attachedMesh;
  121906. private _boundingBoxColor;
  121907. private _defaultUtilityLayer;
  121908. private _defaultKeepDepthUtilityLayer;
  121909. /**
  121910. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121911. */
  121912. boundingBoxDragBehavior: SixDofDragBehavior;
  121913. /**
  121914. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121915. */
  121916. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121917. /**
  121918. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121919. */
  121920. usePointerToAttachGizmos: boolean;
  121921. /**
  121922. * Utility layer that the bounding box gizmo belongs to
  121923. */
  121924. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121925. /**
  121926. * Utility layer that all gizmos besides bounding box belong to
  121927. */
  121928. get utilityLayer(): UtilityLayerRenderer;
  121929. /**
  121930. * Instatiates a gizmo manager
  121931. * @param scene the scene to overlay the gizmos on top of
  121932. */
  121933. constructor(scene: Scene);
  121934. /**
  121935. * Attaches a set of gizmos to the specified mesh
  121936. * @param mesh The mesh the gizmo's should be attached to
  121937. */
  121938. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121939. /**
  121940. * If the position gizmo is enabled
  121941. */
  121942. set positionGizmoEnabled(value: boolean);
  121943. get positionGizmoEnabled(): boolean;
  121944. /**
  121945. * If the rotation gizmo is enabled
  121946. */
  121947. set rotationGizmoEnabled(value: boolean);
  121948. get rotationGizmoEnabled(): boolean;
  121949. /**
  121950. * If the scale gizmo is enabled
  121951. */
  121952. set scaleGizmoEnabled(value: boolean);
  121953. get scaleGizmoEnabled(): boolean;
  121954. /**
  121955. * If the boundingBox gizmo is enabled
  121956. */
  121957. set boundingBoxGizmoEnabled(value: boolean);
  121958. get boundingBoxGizmoEnabled(): boolean;
  121959. /**
  121960. * Disposes of the gizmo manager
  121961. */
  121962. dispose(): void;
  121963. }
  121964. }
  121965. declare module BABYLON {
  121966. /**
  121967. * A directional light is defined by a direction (what a surprise!).
  121968. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121969. * 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.
  121970. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121971. */
  121972. export class DirectionalLight extends ShadowLight {
  121973. private _shadowFrustumSize;
  121974. /**
  121975. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121976. */
  121977. get shadowFrustumSize(): number;
  121978. /**
  121979. * Specifies a fix frustum size for the shadow generation.
  121980. */
  121981. set shadowFrustumSize(value: number);
  121982. private _shadowOrthoScale;
  121983. /**
  121984. * Gets the shadow projection scale against the optimal computed one.
  121985. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121986. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121987. */
  121988. get shadowOrthoScale(): number;
  121989. /**
  121990. * Sets the shadow projection scale against the optimal computed one.
  121991. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121992. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121993. */
  121994. set shadowOrthoScale(value: number);
  121995. /**
  121996. * Automatically compute the projection matrix to best fit (including all the casters)
  121997. * on each frame.
  121998. */
  121999. autoUpdateExtends: boolean;
  122000. /**
  122001. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122002. * on each frame. autoUpdateExtends must be set to true for this to work
  122003. */
  122004. autoCalcShadowZBounds: boolean;
  122005. private _orthoLeft;
  122006. private _orthoRight;
  122007. private _orthoTop;
  122008. private _orthoBottom;
  122009. /**
  122010. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122011. * The directional light is emitted from everywhere in the given direction.
  122012. * It can cast shadows.
  122013. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122014. * @param name The friendly name of the light
  122015. * @param direction The direction of the light
  122016. * @param scene The scene the light belongs to
  122017. */
  122018. constructor(name: string, direction: Vector3, scene: Scene);
  122019. /**
  122020. * Returns the string "DirectionalLight".
  122021. * @return The class name
  122022. */
  122023. getClassName(): string;
  122024. /**
  122025. * Returns the integer 1.
  122026. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122027. */
  122028. getTypeID(): number;
  122029. /**
  122030. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122031. * Returns the DirectionalLight Shadow projection matrix.
  122032. */
  122033. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122034. /**
  122035. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122036. * Returns the DirectionalLight Shadow projection matrix.
  122037. */
  122038. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122039. /**
  122040. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122041. * Returns the DirectionalLight Shadow projection matrix.
  122042. */
  122043. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122044. protected _buildUniformLayout(): void;
  122045. /**
  122046. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122047. * @param effect The effect to update
  122048. * @param lightIndex The index of the light in the effect to update
  122049. * @returns The directional light
  122050. */
  122051. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122052. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122053. /**
  122054. * Gets the minZ used for shadow according to both the scene and the light.
  122055. *
  122056. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122057. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122058. * @param activeCamera The camera we are returning the min for
  122059. * @returns the depth min z
  122060. */
  122061. getDepthMinZ(activeCamera: Camera): number;
  122062. /**
  122063. * Gets the maxZ used for shadow according to both the scene and the light.
  122064. *
  122065. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122066. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122067. * @param activeCamera The camera we are returning the max for
  122068. * @returns the depth max z
  122069. */
  122070. getDepthMaxZ(activeCamera: Camera): number;
  122071. /**
  122072. * Prepares the list of defines specific to the light type.
  122073. * @param defines the list of defines
  122074. * @param lightIndex defines the index of the light for the effect
  122075. */
  122076. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /**
  122081. * Class containing static functions to help procedurally build meshes
  122082. */
  122083. export class HemisphereBuilder {
  122084. /**
  122085. * Creates a hemisphere mesh
  122086. * @param name defines the name of the mesh
  122087. * @param options defines the options used to create the mesh
  122088. * @param scene defines the hosting scene
  122089. * @returns the hemisphere mesh
  122090. */
  122091. static CreateHemisphere(name: string, options: {
  122092. segments?: number;
  122093. diameter?: number;
  122094. sideOrientation?: number;
  122095. }, scene: any): Mesh;
  122096. }
  122097. }
  122098. declare module BABYLON {
  122099. /**
  122100. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122101. * These values define a cone of light starting from the position, emitting toward the direction.
  122102. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122103. * and the exponent defines the speed of the decay of the light with distance (reach).
  122104. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122105. */
  122106. export class SpotLight extends ShadowLight {
  122107. private _angle;
  122108. private _innerAngle;
  122109. private _cosHalfAngle;
  122110. private _lightAngleScale;
  122111. private _lightAngleOffset;
  122112. /**
  122113. * Gets the cone angle of the spot light in Radians.
  122114. */
  122115. get angle(): number;
  122116. /**
  122117. * Sets the cone angle of the spot light in Radians.
  122118. */
  122119. set angle(value: number);
  122120. /**
  122121. * Only used in gltf falloff mode, this defines the angle where
  122122. * the directional falloff will start before cutting at angle which could be seen
  122123. * as outer angle.
  122124. */
  122125. get innerAngle(): number;
  122126. /**
  122127. * Only used in gltf falloff mode, this defines the angle where
  122128. * the directional falloff will start before cutting at angle which could be seen
  122129. * as outer angle.
  122130. */
  122131. set innerAngle(value: number);
  122132. private _shadowAngleScale;
  122133. /**
  122134. * Allows scaling the angle of the light for shadow generation only.
  122135. */
  122136. get shadowAngleScale(): number;
  122137. /**
  122138. * Allows scaling the angle of the light for shadow generation only.
  122139. */
  122140. set shadowAngleScale(value: number);
  122141. /**
  122142. * The light decay speed with the distance from the emission spot.
  122143. */
  122144. exponent: number;
  122145. private _projectionTextureMatrix;
  122146. /**
  122147. * Allows reading the projecton texture
  122148. */
  122149. get projectionTextureMatrix(): Matrix;
  122150. protected _projectionTextureLightNear: number;
  122151. /**
  122152. * Gets the near clip of the Spotlight for texture projection.
  122153. */
  122154. get projectionTextureLightNear(): number;
  122155. /**
  122156. * Sets the near clip of the Spotlight for texture projection.
  122157. */
  122158. set projectionTextureLightNear(value: number);
  122159. protected _projectionTextureLightFar: number;
  122160. /**
  122161. * Gets the far clip of the Spotlight for texture projection.
  122162. */
  122163. get projectionTextureLightFar(): number;
  122164. /**
  122165. * Sets the far clip of the Spotlight for texture projection.
  122166. */
  122167. set projectionTextureLightFar(value: number);
  122168. protected _projectionTextureUpDirection: Vector3;
  122169. /**
  122170. * Gets the Up vector of the Spotlight for texture projection.
  122171. */
  122172. get projectionTextureUpDirection(): Vector3;
  122173. /**
  122174. * Sets the Up vector of the Spotlight for texture projection.
  122175. */
  122176. set projectionTextureUpDirection(value: Vector3);
  122177. private _projectionTexture;
  122178. /**
  122179. * Gets the projection texture of the light.
  122180. */
  122181. get projectionTexture(): Nullable<BaseTexture>;
  122182. /**
  122183. * Sets the projection texture of the light.
  122184. */
  122185. set projectionTexture(value: Nullable<BaseTexture>);
  122186. private _projectionTextureViewLightDirty;
  122187. private _projectionTextureProjectionLightDirty;
  122188. private _projectionTextureDirty;
  122189. private _projectionTextureViewTargetVector;
  122190. private _projectionTextureViewLightMatrix;
  122191. private _projectionTextureProjectionLightMatrix;
  122192. private _projectionTextureScalingMatrix;
  122193. /**
  122194. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122195. * It can cast shadows.
  122196. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122197. * @param name The light friendly name
  122198. * @param position The position of the spot light in the scene
  122199. * @param direction The direction of the light in the scene
  122200. * @param angle The cone angle of the light in Radians
  122201. * @param exponent The light decay speed with the distance from the emission spot
  122202. * @param scene The scene the lights belongs to
  122203. */
  122204. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122205. /**
  122206. * Returns the string "SpotLight".
  122207. * @returns the class name
  122208. */
  122209. getClassName(): string;
  122210. /**
  122211. * Returns the integer 2.
  122212. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122213. */
  122214. getTypeID(): number;
  122215. /**
  122216. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122217. */
  122218. protected _setDirection(value: Vector3): void;
  122219. /**
  122220. * Overrides the position setter to recompute the projection texture view light Matrix.
  122221. */
  122222. protected _setPosition(value: Vector3): void;
  122223. /**
  122224. * 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.
  122225. * Returns the SpotLight.
  122226. */
  122227. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122228. protected _computeProjectionTextureViewLightMatrix(): void;
  122229. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122230. /**
  122231. * Main function for light texture projection matrix computing.
  122232. */
  122233. protected _computeProjectionTextureMatrix(): void;
  122234. protected _buildUniformLayout(): void;
  122235. private _computeAngleValues;
  122236. /**
  122237. * Sets the passed Effect "effect" with the Light textures.
  122238. * @param effect The effect to update
  122239. * @param lightIndex The index of the light in the effect to update
  122240. * @returns The light
  122241. */
  122242. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122243. /**
  122244. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122245. * @param effect The effect to update
  122246. * @param lightIndex The index of the light in the effect to update
  122247. * @returns The spot light
  122248. */
  122249. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122250. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122251. /**
  122252. * Disposes the light and the associated resources.
  122253. */
  122254. dispose(): void;
  122255. /**
  122256. * Prepares the list of defines specific to the light type.
  122257. * @param defines the list of defines
  122258. * @param lightIndex defines the index of the light for the effect
  122259. */
  122260. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122261. }
  122262. }
  122263. declare module BABYLON {
  122264. /**
  122265. * Gizmo that enables viewing a light
  122266. */
  122267. export class LightGizmo extends Gizmo {
  122268. private _lightMesh;
  122269. private _material;
  122270. private _cachedPosition;
  122271. private _cachedForward;
  122272. private _attachedMeshParent;
  122273. /**
  122274. * Creates a LightGizmo
  122275. * @param gizmoLayer The utility layer the gizmo will be added to
  122276. */
  122277. constructor(gizmoLayer?: UtilityLayerRenderer);
  122278. private _light;
  122279. /**
  122280. * The light that the gizmo is attached to
  122281. */
  122282. set light(light: Nullable<Light>);
  122283. get light(): Nullable<Light>;
  122284. /**
  122285. * Gets the material used to render the light gizmo
  122286. */
  122287. get material(): StandardMaterial;
  122288. /**
  122289. * @hidden
  122290. * Updates the gizmo to match the attached mesh's position/rotation
  122291. */
  122292. protected _update(): void;
  122293. private static _Scale;
  122294. /**
  122295. * Creates the lines for a light mesh
  122296. */
  122297. private static _CreateLightLines;
  122298. /**
  122299. * Disposes of the light gizmo
  122300. */
  122301. dispose(): void;
  122302. private static _CreateHemisphericLightMesh;
  122303. private static _CreatePointLightMesh;
  122304. private static _CreateSpotLightMesh;
  122305. private static _CreateDirectionalLightMesh;
  122306. }
  122307. }
  122308. declare module BABYLON {
  122309. /** @hidden */
  122310. export var backgroundFragmentDeclaration: {
  122311. name: string;
  122312. shader: string;
  122313. };
  122314. }
  122315. declare module BABYLON {
  122316. /** @hidden */
  122317. export var backgroundUboDeclaration: {
  122318. name: string;
  122319. shader: string;
  122320. };
  122321. }
  122322. declare module BABYLON {
  122323. /** @hidden */
  122324. export var backgroundPixelShader: {
  122325. name: string;
  122326. shader: string;
  122327. };
  122328. }
  122329. declare module BABYLON {
  122330. /** @hidden */
  122331. export var backgroundVertexDeclaration: {
  122332. name: string;
  122333. shader: string;
  122334. };
  122335. }
  122336. declare module BABYLON {
  122337. /** @hidden */
  122338. export var backgroundVertexShader: {
  122339. name: string;
  122340. shader: string;
  122341. };
  122342. }
  122343. declare module BABYLON {
  122344. /**
  122345. * Background material used to create an efficient environement around your scene.
  122346. */
  122347. export class BackgroundMaterial extends PushMaterial {
  122348. /**
  122349. * Standard reflectance value at parallel view angle.
  122350. */
  122351. static StandardReflectance0: number;
  122352. /**
  122353. * Standard reflectance value at grazing angle.
  122354. */
  122355. static StandardReflectance90: number;
  122356. protected _primaryColor: Color3;
  122357. /**
  122358. * Key light Color (multiply against the environement texture)
  122359. */
  122360. primaryColor: Color3;
  122361. protected __perceptualColor: Nullable<Color3>;
  122362. /**
  122363. * Experimental Internal Use Only.
  122364. *
  122365. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122366. * This acts as a helper to set the primary color to a more "human friendly" value.
  122367. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122368. * output color as close as possible from the chosen value.
  122369. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122370. * part of lighting setup.)
  122371. */
  122372. get _perceptualColor(): Nullable<Color3>;
  122373. set _perceptualColor(value: Nullable<Color3>);
  122374. protected _primaryColorShadowLevel: float;
  122375. /**
  122376. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122377. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122378. */
  122379. get primaryColorShadowLevel(): float;
  122380. set primaryColorShadowLevel(value: float);
  122381. protected _primaryColorHighlightLevel: float;
  122382. /**
  122383. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122384. * The primary color is used at the level chosen to define what the white area would look.
  122385. */
  122386. get primaryColorHighlightLevel(): float;
  122387. set primaryColorHighlightLevel(value: float);
  122388. protected _reflectionTexture: Nullable<BaseTexture>;
  122389. /**
  122390. * Reflection Texture used in the material.
  122391. * Should be author in a specific way for the best result (refer to the documentation).
  122392. */
  122393. reflectionTexture: Nullable<BaseTexture>;
  122394. protected _reflectionBlur: float;
  122395. /**
  122396. * Reflection Texture level of blur.
  122397. *
  122398. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122399. * texture twice.
  122400. */
  122401. reflectionBlur: float;
  122402. protected _diffuseTexture: Nullable<BaseTexture>;
  122403. /**
  122404. * Diffuse Texture used in the material.
  122405. * Should be author in a specific way for the best result (refer to the documentation).
  122406. */
  122407. diffuseTexture: Nullable<BaseTexture>;
  122408. protected _shadowLights: Nullable<IShadowLight[]>;
  122409. /**
  122410. * Specify the list of lights casting shadow on the material.
  122411. * All scene shadow lights will be included if null.
  122412. */
  122413. shadowLights: Nullable<IShadowLight[]>;
  122414. protected _shadowLevel: float;
  122415. /**
  122416. * Helps adjusting the shadow to a softer level if required.
  122417. * 0 means black shadows and 1 means no shadows.
  122418. */
  122419. shadowLevel: float;
  122420. protected _sceneCenter: Vector3;
  122421. /**
  122422. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122423. * It is usually zero but might be interesting to modify according to your setup.
  122424. */
  122425. sceneCenter: Vector3;
  122426. protected _opacityFresnel: boolean;
  122427. /**
  122428. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122429. * This helps ensuring a nice transition when the camera goes under the ground.
  122430. */
  122431. opacityFresnel: boolean;
  122432. protected _reflectionFresnel: boolean;
  122433. /**
  122434. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122435. * This helps adding a mirror texture on the ground.
  122436. */
  122437. reflectionFresnel: boolean;
  122438. protected _reflectionFalloffDistance: number;
  122439. /**
  122440. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122441. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122442. */
  122443. reflectionFalloffDistance: number;
  122444. protected _reflectionAmount: number;
  122445. /**
  122446. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122447. */
  122448. reflectionAmount: number;
  122449. protected _reflectionReflectance0: number;
  122450. /**
  122451. * This specifies the weight of the reflection at grazing angle.
  122452. */
  122453. reflectionReflectance0: number;
  122454. protected _reflectionReflectance90: number;
  122455. /**
  122456. * This specifies the weight of the reflection at a perpendicular point of view.
  122457. */
  122458. reflectionReflectance90: number;
  122459. /**
  122460. * Sets the reflection reflectance fresnel values according to the default standard
  122461. * empirically know to work well :-)
  122462. */
  122463. set reflectionStandardFresnelWeight(value: number);
  122464. protected _useRGBColor: boolean;
  122465. /**
  122466. * Helps to directly use the maps channels instead of their level.
  122467. */
  122468. useRGBColor: boolean;
  122469. protected _enableNoise: boolean;
  122470. /**
  122471. * This helps reducing the banding effect that could occur on the background.
  122472. */
  122473. enableNoise: boolean;
  122474. /**
  122475. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122476. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122477. * Recommended to be keep at 1.0 except for special cases.
  122478. */
  122479. get fovMultiplier(): number;
  122480. set fovMultiplier(value: number);
  122481. private _fovMultiplier;
  122482. /**
  122483. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122484. */
  122485. useEquirectangularFOV: boolean;
  122486. private _maxSimultaneousLights;
  122487. /**
  122488. * Number of Simultaneous lights allowed on the material.
  122489. */
  122490. maxSimultaneousLights: int;
  122491. /**
  122492. * Default configuration related to image processing available in the Background Material.
  122493. */
  122494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122495. /**
  122496. * Keep track of the image processing observer to allow dispose and replace.
  122497. */
  122498. private _imageProcessingObserver;
  122499. /**
  122500. * Attaches a new image processing configuration to the PBR Material.
  122501. * @param configuration (if null the scene configuration will be use)
  122502. */
  122503. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122504. /**
  122505. * Gets the image processing configuration used either in this material.
  122506. */
  122507. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122508. /**
  122509. * Sets the Default image processing configuration used either in the this material.
  122510. *
  122511. * If sets to null, the scene one is in use.
  122512. */
  122513. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122514. /**
  122515. * Gets wether the color curves effect is enabled.
  122516. */
  122517. get cameraColorCurvesEnabled(): boolean;
  122518. /**
  122519. * Sets wether the color curves effect is enabled.
  122520. */
  122521. set cameraColorCurvesEnabled(value: boolean);
  122522. /**
  122523. * Gets wether the color grading effect is enabled.
  122524. */
  122525. get cameraColorGradingEnabled(): boolean;
  122526. /**
  122527. * Gets wether the color grading effect is enabled.
  122528. */
  122529. set cameraColorGradingEnabled(value: boolean);
  122530. /**
  122531. * Gets wether tonemapping is enabled or not.
  122532. */
  122533. get cameraToneMappingEnabled(): boolean;
  122534. /**
  122535. * Sets wether tonemapping is enabled or not
  122536. */
  122537. set cameraToneMappingEnabled(value: boolean);
  122538. /**
  122539. * The camera exposure used on this material.
  122540. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122541. * This corresponds to a photographic exposure.
  122542. */
  122543. get cameraExposure(): float;
  122544. /**
  122545. * The camera exposure used on this material.
  122546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122547. * This corresponds to a photographic exposure.
  122548. */
  122549. set cameraExposure(value: float);
  122550. /**
  122551. * Gets The camera contrast used on this material.
  122552. */
  122553. get cameraContrast(): float;
  122554. /**
  122555. * Sets The camera contrast used on this material.
  122556. */
  122557. set cameraContrast(value: float);
  122558. /**
  122559. * Gets the Color Grading 2D Lookup Texture.
  122560. */
  122561. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122562. /**
  122563. * Sets the Color Grading 2D Lookup Texture.
  122564. */
  122565. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122566. /**
  122567. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122568. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122569. * 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;
  122570. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122571. */
  122572. get cameraColorCurves(): Nullable<ColorCurves>;
  122573. /**
  122574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122576. * 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;
  122577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122578. */
  122579. set cameraColorCurves(value: Nullable<ColorCurves>);
  122580. /**
  122581. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122582. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122583. */
  122584. switchToBGR: boolean;
  122585. private _renderTargets;
  122586. private _reflectionControls;
  122587. private _white;
  122588. private _primaryShadowColor;
  122589. private _primaryHighlightColor;
  122590. /**
  122591. * Instantiates a Background Material in the given scene
  122592. * @param name The friendly name of the material
  122593. * @param scene The scene to add the material to
  122594. */
  122595. constructor(name: string, scene: Scene);
  122596. /**
  122597. * Gets a boolean indicating that current material needs to register RTT
  122598. */
  122599. get hasRenderTargetTextures(): boolean;
  122600. /**
  122601. * The entire material has been created in order to prevent overdraw.
  122602. * @returns false
  122603. */
  122604. needAlphaTesting(): boolean;
  122605. /**
  122606. * The entire material has been created in order to prevent overdraw.
  122607. * @returns true if blending is enable
  122608. */
  122609. needAlphaBlending(): boolean;
  122610. /**
  122611. * Checks wether the material is ready to be rendered for a given mesh.
  122612. * @param mesh The mesh to render
  122613. * @param subMesh The submesh to check against
  122614. * @param useInstances Specify wether or not the material is used with instances
  122615. * @returns true if all the dependencies are ready (Textures, Effects...)
  122616. */
  122617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122618. /**
  122619. * Compute the primary color according to the chosen perceptual color.
  122620. */
  122621. private _computePrimaryColorFromPerceptualColor;
  122622. /**
  122623. * Compute the highlights and shadow colors according to their chosen levels.
  122624. */
  122625. private _computePrimaryColors;
  122626. /**
  122627. * Build the uniform buffer used in the material.
  122628. */
  122629. buildUniformLayout(): void;
  122630. /**
  122631. * Unbind the material.
  122632. */
  122633. unbind(): void;
  122634. /**
  122635. * Bind only the world matrix to the material.
  122636. * @param world The world matrix to bind.
  122637. */
  122638. bindOnlyWorldMatrix(world: Matrix): void;
  122639. /**
  122640. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122641. * @param world The world matrix to bind.
  122642. * @param subMesh The submesh to bind for.
  122643. */
  122644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122645. /**
  122646. * Checks to see if a texture is used in the material.
  122647. * @param texture - Base texture to use.
  122648. * @returns - Boolean specifying if a texture is used in the material.
  122649. */
  122650. hasTexture(texture: BaseTexture): boolean;
  122651. /**
  122652. * Dispose the material.
  122653. * @param forceDisposeEffect Force disposal of the associated effect.
  122654. * @param forceDisposeTextures Force disposal of the associated textures.
  122655. */
  122656. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122657. /**
  122658. * Clones the material.
  122659. * @param name The cloned name.
  122660. * @returns The cloned material.
  122661. */
  122662. clone(name: string): BackgroundMaterial;
  122663. /**
  122664. * Serializes the current material to its JSON representation.
  122665. * @returns The JSON representation.
  122666. */
  122667. serialize(): any;
  122668. /**
  122669. * Gets the class name of the material
  122670. * @returns "BackgroundMaterial"
  122671. */
  122672. getClassName(): string;
  122673. /**
  122674. * Parse a JSON input to create back a background material.
  122675. * @param source The JSON data to parse
  122676. * @param scene The scene to create the parsed material in
  122677. * @param rootUrl The root url of the assets the material depends upon
  122678. * @returns the instantiated BackgroundMaterial.
  122679. */
  122680. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122681. }
  122682. }
  122683. declare module BABYLON {
  122684. /**
  122685. * Represents the different options available during the creation of
  122686. * a Environment helper.
  122687. *
  122688. * This can control the default ground, skybox and image processing setup of your scene.
  122689. */
  122690. export interface IEnvironmentHelperOptions {
  122691. /**
  122692. * Specifies whether or not to create a ground.
  122693. * True by default.
  122694. */
  122695. createGround: boolean;
  122696. /**
  122697. * Specifies the ground size.
  122698. * 15 by default.
  122699. */
  122700. groundSize: number;
  122701. /**
  122702. * The texture used on the ground for the main color.
  122703. * Comes from the BabylonJS CDN by default.
  122704. *
  122705. * Remarks: Can be either a texture or a url.
  122706. */
  122707. groundTexture: string | BaseTexture;
  122708. /**
  122709. * The color mixed in the ground texture by default.
  122710. * BabylonJS clearColor by default.
  122711. */
  122712. groundColor: Color3;
  122713. /**
  122714. * Specifies the ground opacity.
  122715. * 1 by default.
  122716. */
  122717. groundOpacity: number;
  122718. /**
  122719. * Enables the ground to receive shadows.
  122720. * True by default.
  122721. */
  122722. enableGroundShadow: boolean;
  122723. /**
  122724. * Helps preventing the shadow to be fully black on the ground.
  122725. * 0.5 by default.
  122726. */
  122727. groundShadowLevel: number;
  122728. /**
  122729. * Creates a mirror texture attach to the ground.
  122730. * false by default.
  122731. */
  122732. enableGroundMirror: boolean;
  122733. /**
  122734. * Specifies the ground mirror size ratio.
  122735. * 0.3 by default as the default kernel is 64.
  122736. */
  122737. groundMirrorSizeRatio: number;
  122738. /**
  122739. * Specifies the ground mirror blur kernel size.
  122740. * 64 by default.
  122741. */
  122742. groundMirrorBlurKernel: number;
  122743. /**
  122744. * Specifies the ground mirror visibility amount.
  122745. * 1 by default
  122746. */
  122747. groundMirrorAmount: number;
  122748. /**
  122749. * Specifies the ground mirror reflectance weight.
  122750. * This uses the standard weight of the background material to setup the fresnel effect
  122751. * of the mirror.
  122752. * 1 by default.
  122753. */
  122754. groundMirrorFresnelWeight: number;
  122755. /**
  122756. * Specifies the ground mirror Falloff distance.
  122757. * This can helps reducing the size of the reflection.
  122758. * 0 by Default.
  122759. */
  122760. groundMirrorFallOffDistance: number;
  122761. /**
  122762. * Specifies the ground mirror texture type.
  122763. * Unsigned Int by Default.
  122764. */
  122765. groundMirrorTextureType: number;
  122766. /**
  122767. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122768. * the shown objects.
  122769. */
  122770. groundYBias: number;
  122771. /**
  122772. * Specifies whether or not to create a skybox.
  122773. * True by default.
  122774. */
  122775. createSkybox: boolean;
  122776. /**
  122777. * Specifies the skybox size.
  122778. * 20 by default.
  122779. */
  122780. skyboxSize: number;
  122781. /**
  122782. * The texture used on the skybox for the main color.
  122783. * Comes from the BabylonJS CDN by default.
  122784. *
  122785. * Remarks: Can be either a texture or a url.
  122786. */
  122787. skyboxTexture: string | BaseTexture;
  122788. /**
  122789. * The color mixed in the skybox texture by default.
  122790. * BabylonJS clearColor by default.
  122791. */
  122792. skyboxColor: Color3;
  122793. /**
  122794. * The background rotation around the Y axis of the scene.
  122795. * This helps aligning the key lights of your scene with the background.
  122796. * 0 by default.
  122797. */
  122798. backgroundYRotation: number;
  122799. /**
  122800. * Compute automatically the size of the elements to best fit with the scene.
  122801. */
  122802. sizeAuto: boolean;
  122803. /**
  122804. * Default position of the rootMesh if autoSize is not true.
  122805. */
  122806. rootPosition: Vector3;
  122807. /**
  122808. * Sets up the image processing in the scene.
  122809. * true by default.
  122810. */
  122811. setupImageProcessing: boolean;
  122812. /**
  122813. * The texture used as your environment texture in the scene.
  122814. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122815. *
  122816. * Remarks: Can be either a texture or a url.
  122817. */
  122818. environmentTexture: string | BaseTexture;
  122819. /**
  122820. * The value of the exposure to apply to the scene.
  122821. * 0.6 by default if setupImageProcessing is true.
  122822. */
  122823. cameraExposure: number;
  122824. /**
  122825. * The value of the contrast to apply to the scene.
  122826. * 1.6 by default if setupImageProcessing is true.
  122827. */
  122828. cameraContrast: number;
  122829. /**
  122830. * Specifies whether or not tonemapping should be enabled in the scene.
  122831. * true by default if setupImageProcessing is true.
  122832. */
  122833. toneMappingEnabled: boolean;
  122834. }
  122835. /**
  122836. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122837. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122838. * It also helps with the default setup of your imageProcessing configuration.
  122839. */
  122840. export class EnvironmentHelper {
  122841. /**
  122842. * Default ground texture URL.
  122843. */
  122844. private static _groundTextureCDNUrl;
  122845. /**
  122846. * Default skybox texture URL.
  122847. */
  122848. private static _skyboxTextureCDNUrl;
  122849. /**
  122850. * Default environment texture URL.
  122851. */
  122852. private static _environmentTextureCDNUrl;
  122853. /**
  122854. * Creates the default options for the helper.
  122855. */
  122856. private static _getDefaultOptions;
  122857. private _rootMesh;
  122858. /**
  122859. * Gets the root mesh created by the helper.
  122860. */
  122861. get rootMesh(): Mesh;
  122862. private _skybox;
  122863. /**
  122864. * Gets the skybox created by the helper.
  122865. */
  122866. get skybox(): Nullable<Mesh>;
  122867. private _skyboxTexture;
  122868. /**
  122869. * Gets the skybox texture created by the helper.
  122870. */
  122871. get skyboxTexture(): Nullable<BaseTexture>;
  122872. private _skyboxMaterial;
  122873. /**
  122874. * Gets the skybox material created by the helper.
  122875. */
  122876. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122877. private _ground;
  122878. /**
  122879. * Gets the ground mesh created by the helper.
  122880. */
  122881. get ground(): Nullable<Mesh>;
  122882. private _groundTexture;
  122883. /**
  122884. * Gets the ground texture created by the helper.
  122885. */
  122886. get groundTexture(): Nullable<BaseTexture>;
  122887. private _groundMirror;
  122888. /**
  122889. * Gets the ground mirror created by the helper.
  122890. */
  122891. get groundMirror(): Nullable<MirrorTexture>;
  122892. /**
  122893. * Gets the ground mirror render list to helps pushing the meshes
  122894. * you wish in the ground reflection.
  122895. */
  122896. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122897. private _groundMaterial;
  122898. /**
  122899. * Gets the ground material created by the helper.
  122900. */
  122901. get groundMaterial(): Nullable<BackgroundMaterial>;
  122902. /**
  122903. * Stores the creation options.
  122904. */
  122905. private readonly _scene;
  122906. private _options;
  122907. /**
  122908. * This observable will be notified with any error during the creation of the environment,
  122909. * mainly texture creation errors.
  122910. */
  122911. onErrorObservable: Observable<{
  122912. message?: string;
  122913. exception?: any;
  122914. }>;
  122915. /**
  122916. * constructor
  122917. * @param options Defines the options we want to customize the helper
  122918. * @param scene The scene to add the material to
  122919. */
  122920. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122921. /**
  122922. * Updates the background according to the new options
  122923. * @param options
  122924. */
  122925. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122926. /**
  122927. * Sets the primary color of all the available elements.
  122928. * @param color the main color to affect to the ground and the background
  122929. */
  122930. setMainColor(color: Color3): void;
  122931. /**
  122932. * Setup the image processing according to the specified options.
  122933. */
  122934. private _setupImageProcessing;
  122935. /**
  122936. * Setup the environment texture according to the specified options.
  122937. */
  122938. private _setupEnvironmentTexture;
  122939. /**
  122940. * Setup the background according to the specified options.
  122941. */
  122942. private _setupBackground;
  122943. /**
  122944. * Get the scene sizes according to the setup.
  122945. */
  122946. private _getSceneSize;
  122947. /**
  122948. * Setup the ground according to the specified options.
  122949. */
  122950. private _setupGround;
  122951. /**
  122952. * Setup the ground material according to the specified options.
  122953. */
  122954. private _setupGroundMaterial;
  122955. /**
  122956. * Setup the ground diffuse texture according to the specified options.
  122957. */
  122958. private _setupGroundDiffuseTexture;
  122959. /**
  122960. * Setup the ground mirror texture according to the specified options.
  122961. */
  122962. private _setupGroundMirrorTexture;
  122963. /**
  122964. * Setup the ground to receive the mirror texture.
  122965. */
  122966. private _setupMirrorInGroundMaterial;
  122967. /**
  122968. * Setup the skybox according to the specified options.
  122969. */
  122970. private _setupSkybox;
  122971. /**
  122972. * Setup the skybox material according to the specified options.
  122973. */
  122974. private _setupSkyboxMaterial;
  122975. /**
  122976. * Setup the skybox reflection texture according to the specified options.
  122977. */
  122978. private _setupSkyboxReflectionTexture;
  122979. private _errorHandler;
  122980. /**
  122981. * Dispose all the elements created by the Helper.
  122982. */
  122983. dispose(): void;
  122984. }
  122985. }
  122986. declare module BABYLON {
  122987. /**
  122988. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122989. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122990. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122991. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122992. */
  122993. export class PhotoDome extends TransformNode {
  122994. /**
  122995. * Define the image as a Monoscopic panoramic 360 image.
  122996. */
  122997. static readonly MODE_MONOSCOPIC: number;
  122998. /**
  122999. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123000. */
  123001. static readonly MODE_TOPBOTTOM: number;
  123002. /**
  123003. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123004. */
  123005. static readonly MODE_SIDEBYSIDE: number;
  123006. private _useDirectMapping;
  123007. /**
  123008. * The texture being displayed on the sphere
  123009. */
  123010. protected _photoTexture: Texture;
  123011. /**
  123012. * Gets or sets the texture being displayed on the sphere
  123013. */
  123014. get photoTexture(): Texture;
  123015. set photoTexture(value: Texture);
  123016. /**
  123017. * Observable raised when an error occured while loading the 360 image
  123018. */
  123019. onLoadErrorObservable: Observable<string>;
  123020. /**
  123021. * The skybox material
  123022. */
  123023. protected _material: BackgroundMaterial;
  123024. /**
  123025. * The surface used for the skybox
  123026. */
  123027. protected _mesh: Mesh;
  123028. /**
  123029. * Gets the mesh used for the skybox.
  123030. */
  123031. get mesh(): Mesh;
  123032. /**
  123033. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123034. * Also see the options.resolution property.
  123035. */
  123036. get fovMultiplier(): number;
  123037. set fovMultiplier(value: number);
  123038. private _imageMode;
  123039. /**
  123040. * Gets or set the current video mode for the video. It can be:
  123041. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123042. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123043. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123044. */
  123045. get imageMode(): number;
  123046. set imageMode(value: number);
  123047. /**
  123048. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123049. * @param name Element's name, child elements will append suffixes for their own names.
  123050. * @param urlsOfPhoto defines the url of the photo to display
  123051. * @param options defines an object containing optional or exposed sub element properties
  123052. * @param onError defines a callback called when an error occured while loading the texture
  123053. */
  123054. constructor(name: string, urlOfPhoto: string, options: {
  123055. resolution?: number;
  123056. size?: number;
  123057. useDirectMapping?: boolean;
  123058. faceForward?: boolean;
  123059. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123060. private _onBeforeCameraRenderObserver;
  123061. private _changeImageMode;
  123062. /**
  123063. * Releases resources associated with this node.
  123064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123066. */
  123067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123068. }
  123069. }
  123070. declare module BABYLON {
  123071. /**
  123072. * Class used to host RGBD texture specific utilities
  123073. */
  123074. export class RGBDTextureTools {
  123075. /**
  123076. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123077. * @param texture the texture to expand.
  123078. */
  123079. static ExpandRGBDTexture(texture: Texture): void;
  123080. }
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * Class used to host texture specific utilities
  123085. */
  123086. export class BRDFTextureTools {
  123087. /**
  123088. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123089. * @param scene defines the hosting scene
  123090. * @returns the environment BRDF texture
  123091. */
  123092. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123093. private static _environmentBRDFBase64Texture;
  123094. }
  123095. }
  123096. declare module BABYLON {
  123097. /**
  123098. * @hidden
  123099. */
  123100. export interface IMaterialClearCoatDefines {
  123101. CLEARCOAT: boolean;
  123102. CLEARCOAT_DEFAULTIOR: boolean;
  123103. CLEARCOAT_TEXTURE: boolean;
  123104. CLEARCOAT_TEXTUREDIRECTUV: number;
  123105. CLEARCOAT_BUMP: boolean;
  123106. CLEARCOAT_BUMPDIRECTUV: number;
  123107. CLEARCOAT_TINT: boolean;
  123108. CLEARCOAT_TINT_TEXTURE: boolean;
  123109. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123110. /** @hidden */
  123111. _areTexturesDirty: boolean;
  123112. }
  123113. /**
  123114. * Define the code related to the clear coat parameters of the pbr material.
  123115. */
  123116. export class PBRClearCoatConfiguration {
  123117. /**
  123118. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123119. * The default fits with a polyurethane material.
  123120. */
  123121. private static readonly _DefaultIndexOfRefraction;
  123122. private _isEnabled;
  123123. /**
  123124. * Defines if the clear coat is enabled in the material.
  123125. */
  123126. isEnabled: boolean;
  123127. /**
  123128. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123129. */
  123130. intensity: number;
  123131. /**
  123132. * Defines the clear coat layer roughness.
  123133. */
  123134. roughness: number;
  123135. private _indexOfRefraction;
  123136. /**
  123137. * Defines the index of refraction of the clear coat.
  123138. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123139. * The default fits with a polyurethane material.
  123140. * Changing the default value is more performance intensive.
  123141. */
  123142. indexOfRefraction: number;
  123143. private _texture;
  123144. /**
  123145. * Stores the clear coat values in a texture.
  123146. */
  123147. texture: Nullable<BaseTexture>;
  123148. private _bumpTexture;
  123149. /**
  123150. * Define the clear coat specific bump texture.
  123151. */
  123152. bumpTexture: Nullable<BaseTexture>;
  123153. private _isTintEnabled;
  123154. /**
  123155. * Defines if the clear coat tint is enabled in the material.
  123156. */
  123157. isTintEnabled: boolean;
  123158. /**
  123159. * Defines the clear coat tint of the material.
  123160. * This is only use if tint is enabled
  123161. */
  123162. tintColor: Color3;
  123163. /**
  123164. * Defines the distance at which the tint color should be found in the
  123165. * clear coat media.
  123166. * This is only use if tint is enabled
  123167. */
  123168. tintColorAtDistance: number;
  123169. /**
  123170. * Defines the clear coat layer thickness.
  123171. * This is only use if tint is enabled
  123172. */
  123173. tintThickness: number;
  123174. private _tintTexture;
  123175. /**
  123176. * Stores the clear tint values in a texture.
  123177. * rgb is tint
  123178. * a is a thickness factor
  123179. */
  123180. tintTexture: Nullable<BaseTexture>;
  123181. /** @hidden */
  123182. private _internalMarkAllSubMeshesAsTexturesDirty;
  123183. /** @hidden */
  123184. _markAllSubMeshesAsTexturesDirty(): void;
  123185. /**
  123186. * Instantiate a new istance of clear coat configuration.
  123187. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123188. */
  123189. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123190. /**
  123191. * Gets wehter the submesh is ready to be used or not.
  123192. * @param defines the list of "defines" to update.
  123193. * @param scene defines the scene the material belongs to.
  123194. * @param engine defines the engine the material belongs to.
  123195. * @param disableBumpMap defines wether the material disables bump or not.
  123196. * @returns - boolean indicating that the submesh is ready or not.
  123197. */
  123198. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123199. /**
  123200. * Checks to see if a texture is used in the material.
  123201. * @param defines the list of "defines" to update.
  123202. * @param scene defines the scene to the material belongs to.
  123203. */
  123204. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123205. /**
  123206. * Binds the material data.
  123207. * @param uniformBuffer defines the Uniform buffer to fill in.
  123208. * @param scene defines the scene the material belongs to.
  123209. * @param engine defines the engine the material belongs to.
  123210. * @param disableBumpMap defines wether the material disables bump or not.
  123211. * @param isFrozen defines wether the material is frozen or not.
  123212. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123213. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123214. */
  123215. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123216. /**
  123217. * Checks to see if a texture is used in the material.
  123218. * @param texture - Base texture to use.
  123219. * @returns - Boolean specifying if a texture is used in the material.
  123220. */
  123221. hasTexture(texture: BaseTexture): boolean;
  123222. /**
  123223. * Returns an array of the actively used textures.
  123224. * @param activeTextures Array of BaseTextures
  123225. */
  123226. getActiveTextures(activeTextures: BaseTexture[]): void;
  123227. /**
  123228. * Returns the animatable textures.
  123229. * @param animatables Array of animatable textures.
  123230. */
  123231. getAnimatables(animatables: IAnimatable[]): void;
  123232. /**
  123233. * Disposes the resources of the material.
  123234. * @param forceDisposeTextures - Forces the disposal of all textures.
  123235. */
  123236. dispose(forceDisposeTextures?: boolean): void;
  123237. /**
  123238. * Get the current class name of the texture useful for serialization or dynamic coding.
  123239. * @returns "PBRClearCoatConfiguration"
  123240. */
  123241. getClassName(): string;
  123242. /**
  123243. * Add fallbacks to the effect fallbacks list.
  123244. * @param defines defines the Base texture to use.
  123245. * @param fallbacks defines the current fallback list.
  123246. * @param currentRank defines the current fallback rank.
  123247. * @returns the new fallback rank.
  123248. */
  123249. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123250. /**
  123251. * Add the required uniforms to the current list.
  123252. * @param uniforms defines the current uniform list.
  123253. */
  123254. static AddUniforms(uniforms: string[]): void;
  123255. /**
  123256. * Add the required samplers to the current list.
  123257. * @param samplers defines the current sampler list.
  123258. */
  123259. static AddSamplers(samplers: string[]): void;
  123260. /**
  123261. * Add the required uniforms to the current buffer.
  123262. * @param uniformBuffer defines the current uniform buffer.
  123263. */
  123264. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123265. /**
  123266. * Makes a duplicate of the current configuration into another one.
  123267. * @param clearCoatConfiguration define the config where to copy the info
  123268. */
  123269. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123270. /**
  123271. * Serializes this clear coat configuration.
  123272. * @returns - An object with the serialized config.
  123273. */
  123274. serialize(): any;
  123275. /**
  123276. * Parses a anisotropy Configuration from a serialized object.
  123277. * @param source - Serialized object.
  123278. * @param scene Defines the scene we are parsing for
  123279. * @param rootUrl Defines the rootUrl to load from
  123280. */
  123281. parse(source: any, scene: Scene, rootUrl: string): void;
  123282. }
  123283. }
  123284. declare module BABYLON {
  123285. /**
  123286. * @hidden
  123287. */
  123288. export interface IMaterialAnisotropicDefines {
  123289. ANISOTROPIC: boolean;
  123290. ANISOTROPIC_TEXTURE: boolean;
  123291. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123292. MAINUV1: boolean;
  123293. _areTexturesDirty: boolean;
  123294. _needUVs: boolean;
  123295. }
  123296. /**
  123297. * Define the code related to the anisotropic parameters of the pbr material.
  123298. */
  123299. export class PBRAnisotropicConfiguration {
  123300. private _isEnabled;
  123301. /**
  123302. * Defines if the anisotropy is enabled in the material.
  123303. */
  123304. isEnabled: boolean;
  123305. /**
  123306. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123307. */
  123308. intensity: number;
  123309. /**
  123310. * Defines if the effect is along the tangents, bitangents or in between.
  123311. * By default, the effect is "strectching" the highlights along the tangents.
  123312. */
  123313. direction: Vector2;
  123314. private _texture;
  123315. /**
  123316. * Stores the anisotropy values in a texture.
  123317. * rg is direction (like normal from -1 to 1)
  123318. * b is a intensity
  123319. */
  123320. texture: Nullable<BaseTexture>;
  123321. /** @hidden */
  123322. private _internalMarkAllSubMeshesAsTexturesDirty;
  123323. /** @hidden */
  123324. _markAllSubMeshesAsTexturesDirty(): void;
  123325. /**
  123326. * Instantiate a new istance of anisotropy configuration.
  123327. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123328. */
  123329. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123330. /**
  123331. * Specifies that the submesh is ready to be used.
  123332. * @param defines the list of "defines" to update.
  123333. * @param scene defines the scene the material belongs to.
  123334. * @returns - boolean indicating that the submesh is ready or not.
  123335. */
  123336. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123337. /**
  123338. * Checks to see if a texture is used in the material.
  123339. * @param defines the list of "defines" to update.
  123340. * @param mesh the mesh we are preparing the defines for.
  123341. * @param scene defines the scene the material belongs to.
  123342. */
  123343. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123344. /**
  123345. * Binds the material data.
  123346. * @param uniformBuffer defines the Uniform buffer to fill in.
  123347. * @param scene defines the scene the material belongs to.
  123348. * @param isFrozen defines wether the material is frozen or not.
  123349. */
  123350. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123351. /**
  123352. * Checks to see if a texture is used in the material.
  123353. * @param texture - Base texture to use.
  123354. * @returns - Boolean specifying if a texture is used in the material.
  123355. */
  123356. hasTexture(texture: BaseTexture): boolean;
  123357. /**
  123358. * Returns an array of the actively used textures.
  123359. * @param activeTextures Array of BaseTextures
  123360. */
  123361. getActiveTextures(activeTextures: BaseTexture[]): void;
  123362. /**
  123363. * Returns the animatable textures.
  123364. * @param animatables Array of animatable textures.
  123365. */
  123366. getAnimatables(animatables: IAnimatable[]): void;
  123367. /**
  123368. * Disposes the resources of the material.
  123369. * @param forceDisposeTextures - Forces the disposal of all textures.
  123370. */
  123371. dispose(forceDisposeTextures?: boolean): void;
  123372. /**
  123373. * Get the current class name of the texture useful for serialization or dynamic coding.
  123374. * @returns "PBRAnisotropicConfiguration"
  123375. */
  123376. getClassName(): string;
  123377. /**
  123378. * Add fallbacks to the effect fallbacks list.
  123379. * @param defines defines the Base texture to use.
  123380. * @param fallbacks defines the current fallback list.
  123381. * @param currentRank defines the current fallback rank.
  123382. * @returns the new fallback rank.
  123383. */
  123384. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123385. /**
  123386. * Add the required uniforms to the current list.
  123387. * @param uniforms defines the current uniform list.
  123388. */
  123389. static AddUniforms(uniforms: string[]): void;
  123390. /**
  123391. * Add the required uniforms to the current buffer.
  123392. * @param uniformBuffer defines the current uniform buffer.
  123393. */
  123394. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123395. /**
  123396. * Add the required samplers to the current list.
  123397. * @param samplers defines the current sampler list.
  123398. */
  123399. static AddSamplers(samplers: string[]): void;
  123400. /**
  123401. * Makes a duplicate of the current configuration into another one.
  123402. * @param anisotropicConfiguration define the config where to copy the info
  123403. */
  123404. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123405. /**
  123406. * Serializes this anisotropy configuration.
  123407. * @returns - An object with the serialized config.
  123408. */
  123409. serialize(): any;
  123410. /**
  123411. * Parses a anisotropy Configuration from a serialized object.
  123412. * @param source - Serialized object.
  123413. * @param scene Defines the scene we are parsing for
  123414. * @param rootUrl Defines the rootUrl to load from
  123415. */
  123416. parse(source: any, scene: Scene, rootUrl: string): void;
  123417. }
  123418. }
  123419. declare module BABYLON {
  123420. /**
  123421. * @hidden
  123422. */
  123423. export interface IMaterialBRDFDefines {
  123424. BRDF_V_HEIGHT_CORRELATED: boolean;
  123425. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123426. SPHERICAL_HARMONICS: boolean;
  123427. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123428. /** @hidden */
  123429. _areMiscDirty: boolean;
  123430. }
  123431. /**
  123432. * Define the code related to the BRDF parameters of the pbr material.
  123433. */
  123434. export class PBRBRDFConfiguration {
  123435. /**
  123436. * Default value used for the energy conservation.
  123437. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123438. */
  123439. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123440. /**
  123441. * Default value used for the Smith Visibility Height Correlated mode.
  123442. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123443. */
  123444. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123445. /**
  123446. * Default value used for the IBL diffuse part.
  123447. * This can help switching back to the polynomials mode globally which is a tiny bit
  123448. * less GPU intensive at the drawback of a lower quality.
  123449. */
  123450. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123451. /**
  123452. * Default value used for activating energy conservation for the specular workflow.
  123453. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123454. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123455. */
  123456. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123457. private _useEnergyConservation;
  123458. /**
  123459. * Defines if the material uses energy conservation.
  123460. */
  123461. useEnergyConservation: boolean;
  123462. private _useSmithVisibilityHeightCorrelated;
  123463. /**
  123464. * LEGACY Mode set to false
  123465. * Defines if the material uses height smith correlated visibility term.
  123466. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123467. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123468. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123469. * Not relying on height correlated will also disable energy conservation.
  123470. */
  123471. useSmithVisibilityHeightCorrelated: boolean;
  123472. private _useSphericalHarmonics;
  123473. /**
  123474. * LEGACY Mode set to false
  123475. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123476. * diffuse part of the IBL.
  123477. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123478. * to the ground truth.
  123479. */
  123480. useSphericalHarmonics: boolean;
  123481. private _useSpecularGlossinessInputEnergyConservation;
  123482. /**
  123483. * Defines if the material uses energy conservation, when the specular workflow is active.
  123484. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123485. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123486. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123487. */
  123488. useSpecularGlossinessInputEnergyConservation: boolean;
  123489. /** @hidden */
  123490. private _internalMarkAllSubMeshesAsMiscDirty;
  123491. /** @hidden */
  123492. _markAllSubMeshesAsMiscDirty(): void;
  123493. /**
  123494. * Instantiate a new istance of clear coat configuration.
  123495. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123496. */
  123497. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123498. /**
  123499. * Checks to see if a texture is used in the material.
  123500. * @param defines the list of "defines" to update.
  123501. */
  123502. prepareDefines(defines: IMaterialBRDFDefines): void;
  123503. /**
  123504. * Get the current class name of the texture useful for serialization or dynamic coding.
  123505. * @returns "PBRClearCoatConfiguration"
  123506. */
  123507. getClassName(): string;
  123508. /**
  123509. * Makes a duplicate of the current configuration into another one.
  123510. * @param brdfConfiguration define the config where to copy the info
  123511. */
  123512. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123513. /**
  123514. * Serializes this BRDF configuration.
  123515. * @returns - An object with the serialized config.
  123516. */
  123517. serialize(): any;
  123518. /**
  123519. * Parses a anisotropy Configuration from a serialized object.
  123520. * @param source - Serialized object.
  123521. * @param scene Defines the scene we are parsing for
  123522. * @param rootUrl Defines the rootUrl to load from
  123523. */
  123524. parse(source: any, scene: Scene, rootUrl: string): void;
  123525. }
  123526. }
  123527. declare module BABYLON {
  123528. /**
  123529. * @hidden
  123530. */
  123531. export interface IMaterialSheenDefines {
  123532. SHEEN: boolean;
  123533. SHEEN_TEXTURE: boolean;
  123534. SHEEN_TEXTUREDIRECTUV: number;
  123535. SHEEN_LINKWITHALBEDO: boolean;
  123536. /** @hidden */
  123537. _areTexturesDirty: boolean;
  123538. }
  123539. /**
  123540. * Define the code related to the Sheen parameters of the pbr material.
  123541. */
  123542. export class PBRSheenConfiguration {
  123543. private _isEnabled;
  123544. /**
  123545. * Defines if the material uses sheen.
  123546. */
  123547. isEnabled: boolean;
  123548. private _linkSheenWithAlbedo;
  123549. /**
  123550. * Defines if the sheen is linked to the sheen color.
  123551. */
  123552. linkSheenWithAlbedo: boolean;
  123553. /**
  123554. * Defines the sheen intensity.
  123555. */
  123556. intensity: number;
  123557. /**
  123558. * Defines the sheen color.
  123559. */
  123560. color: Color3;
  123561. private _texture;
  123562. /**
  123563. * Stores the sheen tint values in a texture.
  123564. * rgb is tint
  123565. * a is a intensity
  123566. */
  123567. texture: Nullable<BaseTexture>;
  123568. /** @hidden */
  123569. private _internalMarkAllSubMeshesAsTexturesDirty;
  123570. /** @hidden */
  123571. _markAllSubMeshesAsTexturesDirty(): void;
  123572. /**
  123573. * Instantiate a new istance of clear coat configuration.
  123574. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123575. */
  123576. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123577. /**
  123578. * Specifies that the submesh is ready to be used.
  123579. * @param defines the list of "defines" to update.
  123580. * @param scene defines the scene the material belongs to.
  123581. * @returns - boolean indicating that the submesh is ready or not.
  123582. */
  123583. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123584. /**
  123585. * Checks to see if a texture is used in the material.
  123586. * @param defines the list of "defines" to update.
  123587. * @param scene defines the scene the material belongs to.
  123588. */
  123589. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123590. /**
  123591. * Binds the material data.
  123592. * @param uniformBuffer defines the Uniform buffer to fill in.
  123593. * @param scene defines the scene the material belongs to.
  123594. * @param isFrozen defines wether the material is frozen or not.
  123595. */
  123596. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123597. /**
  123598. * Checks to see if a texture is used in the material.
  123599. * @param texture - Base texture to use.
  123600. * @returns - Boolean specifying if a texture is used in the material.
  123601. */
  123602. hasTexture(texture: BaseTexture): boolean;
  123603. /**
  123604. * Returns an array of the actively used textures.
  123605. * @param activeTextures Array of BaseTextures
  123606. */
  123607. getActiveTextures(activeTextures: BaseTexture[]): void;
  123608. /**
  123609. * Returns the animatable textures.
  123610. * @param animatables Array of animatable textures.
  123611. */
  123612. getAnimatables(animatables: IAnimatable[]): void;
  123613. /**
  123614. * Disposes the resources of the material.
  123615. * @param forceDisposeTextures - Forces the disposal of all textures.
  123616. */
  123617. dispose(forceDisposeTextures?: boolean): void;
  123618. /**
  123619. * Get the current class name of the texture useful for serialization or dynamic coding.
  123620. * @returns "PBRSheenConfiguration"
  123621. */
  123622. getClassName(): string;
  123623. /**
  123624. * Add fallbacks to the effect fallbacks list.
  123625. * @param defines defines the Base texture to use.
  123626. * @param fallbacks defines the current fallback list.
  123627. * @param currentRank defines the current fallback rank.
  123628. * @returns the new fallback rank.
  123629. */
  123630. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123631. /**
  123632. * Add the required uniforms to the current list.
  123633. * @param uniforms defines the current uniform list.
  123634. */
  123635. static AddUniforms(uniforms: string[]): void;
  123636. /**
  123637. * Add the required uniforms to the current buffer.
  123638. * @param uniformBuffer defines the current uniform buffer.
  123639. */
  123640. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123641. /**
  123642. * Add the required samplers to the current list.
  123643. * @param samplers defines the current sampler list.
  123644. */
  123645. static AddSamplers(samplers: string[]): void;
  123646. /**
  123647. * Makes a duplicate of the current configuration into another one.
  123648. * @param sheenConfiguration define the config where to copy the info
  123649. */
  123650. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123651. /**
  123652. * Serializes this BRDF configuration.
  123653. * @returns - An object with the serialized config.
  123654. */
  123655. serialize(): any;
  123656. /**
  123657. * Parses a anisotropy Configuration from a serialized object.
  123658. * @param source - Serialized object.
  123659. * @param scene Defines the scene we are parsing for
  123660. * @param rootUrl Defines the rootUrl to load from
  123661. */
  123662. parse(source: any, scene: Scene, rootUrl: string): void;
  123663. }
  123664. }
  123665. declare module BABYLON {
  123666. /**
  123667. * @hidden
  123668. */
  123669. export interface IMaterialSubSurfaceDefines {
  123670. SUBSURFACE: boolean;
  123671. SS_REFRACTION: boolean;
  123672. SS_TRANSLUCENCY: boolean;
  123673. SS_SCATERRING: boolean;
  123674. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123675. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123676. SS_REFRACTIONMAP_3D: boolean;
  123677. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123678. SS_LODINREFRACTIONALPHA: boolean;
  123679. SS_GAMMAREFRACTION: boolean;
  123680. SS_RGBDREFRACTION: boolean;
  123681. SS_LINEARSPECULARREFRACTION: boolean;
  123682. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123683. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123684. /** @hidden */
  123685. _areTexturesDirty: boolean;
  123686. }
  123687. /**
  123688. * Define the code related to the sub surface parameters of the pbr material.
  123689. */
  123690. export class PBRSubSurfaceConfiguration {
  123691. private _isRefractionEnabled;
  123692. /**
  123693. * Defines if the refraction is enabled in the material.
  123694. */
  123695. isRefractionEnabled: boolean;
  123696. private _isTranslucencyEnabled;
  123697. /**
  123698. * Defines if the translucency is enabled in the material.
  123699. */
  123700. isTranslucencyEnabled: boolean;
  123701. private _isScatteringEnabled;
  123702. /**
  123703. * Defines the refraction intensity of the material.
  123704. * The refraction when enabled replaces the Diffuse part of the material.
  123705. * The intensity helps transitionning between diffuse and refraction.
  123706. */
  123707. refractionIntensity: number;
  123708. /**
  123709. * Defines the translucency intensity of the material.
  123710. * When translucency has been enabled, this defines how much of the "translucency"
  123711. * is addded to the diffuse part of the material.
  123712. */
  123713. translucencyIntensity: number;
  123714. /**
  123715. * Defines the scattering intensity of the material.
  123716. * When scattering has been enabled, this defines how much of the "scattered light"
  123717. * is addded to the diffuse part of the material.
  123718. */
  123719. scatteringIntensity: number;
  123720. private _thicknessTexture;
  123721. /**
  123722. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123723. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123724. * 0 would mean minimumThickness
  123725. * 1 would mean maximumThickness
  123726. * The other channels might be use as a mask to vary the different effects intensity.
  123727. */
  123728. thicknessTexture: Nullable<BaseTexture>;
  123729. private _refractionTexture;
  123730. /**
  123731. * Defines the texture to use for refraction.
  123732. */
  123733. refractionTexture: Nullable<BaseTexture>;
  123734. private _indexOfRefraction;
  123735. /**
  123736. * Defines the index of refraction used in the material.
  123737. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123738. */
  123739. indexOfRefraction: number;
  123740. private _invertRefractionY;
  123741. /**
  123742. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123743. */
  123744. invertRefractionY: boolean;
  123745. private _linkRefractionWithTransparency;
  123746. /**
  123747. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123748. * Materials half opaque for instance using refraction could benefit from this control.
  123749. */
  123750. linkRefractionWithTransparency: boolean;
  123751. /**
  123752. * Defines the minimum thickness stored in the thickness map.
  123753. * If no thickness map is defined, this value will be used to simulate thickness.
  123754. */
  123755. minimumThickness: number;
  123756. /**
  123757. * Defines the maximum thickness stored in the thickness map.
  123758. */
  123759. maximumThickness: number;
  123760. /**
  123761. * Defines the volume tint of the material.
  123762. * This is used for both translucency and scattering.
  123763. */
  123764. tintColor: Color3;
  123765. /**
  123766. * Defines the distance at which the tint color should be found in the media.
  123767. * This is used for refraction only.
  123768. */
  123769. tintColorAtDistance: number;
  123770. /**
  123771. * Defines how far each channel transmit through the media.
  123772. * It is defined as a color to simplify it selection.
  123773. */
  123774. diffusionDistance: Color3;
  123775. private _useMaskFromThicknessTexture;
  123776. /**
  123777. * Stores the intensity of the different subsurface effects in the thickness texture.
  123778. * * the green channel is the translucency intensity.
  123779. * * the blue channel is the scattering intensity.
  123780. * * the alpha channel is the refraction intensity.
  123781. */
  123782. useMaskFromThicknessTexture: boolean;
  123783. /** @hidden */
  123784. private _internalMarkAllSubMeshesAsTexturesDirty;
  123785. /** @hidden */
  123786. _markAllSubMeshesAsTexturesDirty(): void;
  123787. /**
  123788. * Instantiate a new istance of sub surface configuration.
  123789. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123790. */
  123791. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123792. /**
  123793. * Gets wehter the submesh is ready to be used or not.
  123794. * @param defines the list of "defines" to update.
  123795. * @param scene defines the scene the material belongs to.
  123796. * @returns - boolean indicating that the submesh is ready or not.
  123797. */
  123798. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123799. /**
  123800. * Checks to see if a texture is used in the material.
  123801. * @param defines the list of "defines" to update.
  123802. * @param scene defines the scene to the material belongs to.
  123803. */
  123804. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123805. /**
  123806. * Binds the material data.
  123807. * @param uniformBuffer defines the Uniform buffer to fill in.
  123808. * @param scene defines the scene the material belongs to.
  123809. * @param engine defines the engine the material belongs to.
  123810. * @param isFrozen defines wether the material is frozen or not.
  123811. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123812. */
  123813. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123814. /**
  123815. * Unbinds the material from the mesh.
  123816. * @param activeEffect defines the effect that should be unbound from.
  123817. * @returns true if unbound, otherwise false
  123818. */
  123819. unbind(activeEffect: Effect): boolean;
  123820. /**
  123821. * Returns the texture used for refraction or null if none is used.
  123822. * @param scene defines the scene the material belongs to.
  123823. * @returns - Refraction texture if present. If no refraction texture and refraction
  123824. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123825. */
  123826. private _getRefractionTexture;
  123827. /**
  123828. * Returns true if alpha blending should be disabled.
  123829. */
  123830. get disableAlphaBlending(): boolean;
  123831. /**
  123832. * Fills the list of render target textures.
  123833. * @param renderTargets the list of render targets to update
  123834. */
  123835. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123836. /**
  123837. * Checks to see if a texture is used in the material.
  123838. * @param texture - Base texture to use.
  123839. * @returns - Boolean specifying if a texture is used in the material.
  123840. */
  123841. hasTexture(texture: BaseTexture): boolean;
  123842. /**
  123843. * Gets a boolean indicating that current material needs to register RTT
  123844. * @returns true if this uses a render target otherwise false.
  123845. */
  123846. hasRenderTargetTextures(): boolean;
  123847. /**
  123848. * Returns an array of the actively used textures.
  123849. * @param activeTextures Array of BaseTextures
  123850. */
  123851. getActiveTextures(activeTextures: BaseTexture[]): void;
  123852. /**
  123853. * Returns the animatable textures.
  123854. * @param animatables Array of animatable textures.
  123855. */
  123856. getAnimatables(animatables: IAnimatable[]): void;
  123857. /**
  123858. * Disposes the resources of the material.
  123859. * @param forceDisposeTextures - Forces the disposal of all textures.
  123860. */
  123861. dispose(forceDisposeTextures?: boolean): void;
  123862. /**
  123863. * Get the current class name of the texture useful for serialization or dynamic coding.
  123864. * @returns "PBRSubSurfaceConfiguration"
  123865. */
  123866. getClassName(): string;
  123867. /**
  123868. * Add fallbacks to the effect fallbacks list.
  123869. * @param defines defines the Base texture to use.
  123870. * @param fallbacks defines the current fallback list.
  123871. * @param currentRank defines the current fallback rank.
  123872. * @returns the new fallback rank.
  123873. */
  123874. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123875. /**
  123876. * Add the required uniforms to the current list.
  123877. * @param uniforms defines the current uniform list.
  123878. */
  123879. static AddUniforms(uniforms: string[]): void;
  123880. /**
  123881. * Add the required samplers to the current list.
  123882. * @param samplers defines the current sampler list.
  123883. */
  123884. static AddSamplers(samplers: string[]): void;
  123885. /**
  123886. * Add the required uniforms to the current buffer.
  123887. * @param uniformBuffer defines the current uniform buffer.
  123888. */
  123889. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123890. /**
  123891. * Makes a duplicate of the current configuration into another one.
  123892. * @param configuration define the config where to copy the info
  123893. */
  123894. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123895. /**
  123896. * Serializes this Sub Surface configuration.
  123897. * @returns - An object with the serialized config.
  123898. */
  123899. serialize(): any;
  123900. /**
  123901. * Parses a anisotropy Configuration from a serialized object.
  123902. * @param source - Serialized object.
  123903. * @param scene Defines the scene we are parsing for
  123904. * @param rootUrl Defines the rootUrl to load from
  123905. */
  123906. parse(source: any, scene: Scene, rootUrl: string): void;
  123907. }
  123908. }
  123909. declare module BABYLON {
  123910. /** @hidden */
  123911. export var pbrFragmentDeclaration: {
  123912. name: string;
  123913. shader: string;
  123914. };
  123915. }
  123916. declare module BABYLON {
  123917. /** @hidden */
  123918. export var pbrUboDeclaration: {
  123919. name: string;
  123920. shader: string;
  123921. };
  123922. }
  123923. declare module BABYLON {
  123924. /** @hidden */
  123925. export var pbrFragmentExtraDeclaration: {
  123926. name: string;
  123927. shader: string;
  123928. };
  123929. }
  123930. declare module BABYLON {
  123931. /** @hidden */
  123932. export var pbrFragmentSamplersDeclaration: {
  123933. name: string;
  123934. shader: string;
  123935. };
  123936. }
  123937. declare module BABYLON {
  123938. /** @hidden */
  123939. export var pbrHelperFunctions: {
  123940. name: string;
  123941. shader: string;
  123942. };
  123943. }
  123944. declare module BABYLON {
  123945. /** @hidden */
  123946. export var harmonicsFunctions: {
  123947. name: string;
  123948. shader: string;
  123949. };
  123950. }
  123951. declare module BABYLON {
  123952. /** @hidden */
  123953. export var pbrDirectLightingSetupFunctions: {
  123954. name: string;
  123955. shader: string;
  123956. };
  123957. }
  123958. declare module BABYLON {
  123959. /** @hidden */
  123960. export var pbrDirectLightingFalloffFunctions: {
  123961. name: string;
  123962. shader: string;
  123963. };
  123964. }
  123965. declare module BABYLON {
  123966. /** @hidden */
  123967. export var pbrBRDFFunctions: {
  123968. name: string;
  123969. shader: string;
  123970. };
  123971. }
  123972. declare module BABYLON {
  123973. /** @hidden */
  123974. export var pbrDirectLightingFunctions: {
  123975. name: string;
  123976. shader: string;
  123977. };
  123978. }
  123979. declare module BABYLON {
  123980. /** @hidden */
  123981. export var pbrIBLFunctions: {
  123982. name: string;
  123983. shader: string;
  123984. };
  123985. }
  123986. declare module BABYLON {
  123987. /** @hidden */
  123988. export var pbrDebug: {
  123989. name: string;
  123990. shader: string;
  123991. };
  123992. }
  123993. declare module BABYLON {
  123994. /** @hidden */
  123995. export var pbrPixelShader: {
  123996. name: string;
  123997. shader: string;
  123998. };
  123999. }
  124000. declare module BABYLON {
  124001. /** @hidden */
  124002. export var pbrVertexDeclaration: {
  124003. name: string;
  124004. shader: string;
  124005. };
  124006. }
  124007. declare module BABYLON {
  124008. /** @hidden */
  124009. export var pbrVertexShader: {
  124010. name: string;
  124011. shader: string;
  124012. };
  124013. }
  124014. declare module BABYLON {
  124015. /**
  124016. * Manages the defines for the PBR Material.
  124017. * @hidden
  124018. */
  124019. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124020. PBR: boolean;
  124021. MAINUV1: boolean;
  124022. MAINUV2: boolean;
  124023. UV1: boolean;
  124024. UV2: boolean;
  124025. ALBEDO: boolean;
  124026. ALBEDODIRECTUV: number;
  124027. VERTEXCOLOR: boolean;
  124028. AMBIENT: boolean;
  124029. AMBIENTDIRECTUV: number;
  124030. AMBIENTINGRAYSCALE: boolean;
  124031. OPACITY: boolean;
  124032. VERTEXALPHA: boolean;
  124033. OPACITYDIRECTUV: number;
  124034. OPACITYRGB: boolean;
  124035. ALPHATEST: boolean;
  124036. DEPTHPREPASS: boolean;
  124037. ALPHABLEND: boolean;
  124038. ALPHAFROMALBEDO: boolean;
  124039. ALPHATESTVALUE: string;
  124040. SPECULAROVERALPHA: boolean;
  124041. RADIANCEOVERALPHA: boolean;
  124042. ALPHAFRESNEL: boolean;
  124043. LINEARALPHAFRESNEL: boolean;
  124044. PREMULTIPLYALPHA: boolean;
  124045. EMISSIVE: boolean;
  124046. EMISSIVEDIRECTUV: number;
  124047. REFLECTIVITY: boolean;
  124048. REFLECTIVITYDIRECTUV: number;
  124049. SPECULARTERM: boolean;
  124050. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124051. MICROSURFACEAUTOMATIC: boolean;
  124052. LODBASEDMICROSFURACE: boolean;
  124053. MICROSURFACEMAP: boolean;
  124054. MICROSURFACEMAPDIRECTUV: number;
  124055. METALLICWORKFLOW: boolean;
  124056. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124057. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124058. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124059. AOSTOREINMETALMAPRED: boolean;
  124060. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124061. ENVIRONMENTBRDF: boolean;
  124062. ENVIRONMENTBRDF_RGBD: boolean;
  124063. NORMAL: boolean;
  124064. TANGENT: boolean;
  124065. BUMP: boolean;
  124066. BUMPDIRECTUV: number;
  124067. OBJECTSPACE_NORMALMAP: boolean;
  124068. PARALLAX: boolean;
  124069. PARALLAXOCCLUSION: boolean;
  124070. NORMALXYSCALE: boolean;
  124071. LIGHTMAP: boolean;
  124072. LIGHTMAPDIRECTUV: number;
  124073. USELIGHTMAPASSHADOWMAP: boolean;
  124074. GAMMALIGHTMAP: boolean;
  124075. RGBDLIGHTMAP: boolean;
  124076. REFLECTION: boolean;
  124077. REFLECTIONMAP_3D: boolean;
  124078. REFLECTIONMAP_SPHERICAL: boolean;
  124079. REFLECTIONMAP_PLANAR: boolean;
  124080. REFLECTIONMAP_CUBIC: boolean;
  124081. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124082. REFLECTIONMAP_PROJECTION: boolean;
  124083. REFLECTIONMAP_SKYBOX: boolean;
  124084. REFLECTIONMAP_EXPLICIT: boolean;
  124085. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124086. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124087. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124088. INVERTCUBICMAP: boolean;
  124089. USESPHERICALFROMREFLECTIONMAP: boolean;
  124090. USEIRRADIANCEMAP: boolean;
  124091. SPHERICAL_HARMONICS: boolean;
  124092. USESPHERICALINVERTEX: boolean;
  124093. REFLECTIONMAP_OPPOSITEZ: boolean;
  124094. LODINREFLECTIONALPHA: boolean;
  124095. GAMMAREFLECTION: boolean;
  124096. RGBDREFLECTION: boolean;
  124097. LINEARSPECULARREFLECTION: boolean;
  124098. RADIANCEOCCLUSION: boolean;
  124099. HORIZONOCCLUSION: boolean;
  124100. INSTANCES: boolean;
  124101. NUM_BONE_INFLUENCERS: number;
  124102. BonesPerMesh: number;
  124103. BONETEXTURE: boolean;
  124104. NONUNIFORMSCALING: boolean;
  124105. MORPHTARGETS: boolean;
  124106. MORPHTARGETS_NORMAL: boolean;
  124107. MORPHTARGETS_TANGENT: boolean;
  124108. MORPHTARGETS_UV: boolean;
  124109. NUM_MORPH_INFLUENCERS: number;
  124110. IMAGEPROCESSING: boolean;
  124111. VIGNETTE: boolean;
  124112. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124113. VIGNETTEBLENDMODEOPAQUE: boolean;
  124114. TONEMAPPING: boolean;
  124115. TONEMAPPING_ACES: boolean;
  124116. CONTRAST: boolean;
  124117. COLORCURVES: boolean;
  124118. COLORGRADING: boolean;
  124119. COLORGRADING3D: boolean;
  124120. SAMPLER3DGREENDEPTH: boolean;
  124121. SAMPLER3DBGRMAP: boolean;
  124122. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124123. EXPOSURE: boolean;
  124124. MULTIVIEW: boolean;
  124125. USEPHYSICALLIGHTFALLOFF: boolean;
  124126. USEGLTFLIGHTFALLOFF: boolean;
  124127. TWOSIDEDLIGHTING: boolean;
  124128. SHADOWFLOAT: boolean;
  124129. CLIPPLANE: boolean;
  124130. CLIPPLANE2: boolean;
  124131. CLIPPLANE3: boolean;
  124132. CLIPPLANE4: boolean;
  124133. CLIPPLANE5: boolean;
  124134. CLIPPLANE6: boolean;
  124135. POINTSIZE: boolean;
  124136. FOG: boolean;
  124137. LOGARITHMICDEPTH: boolean;
  124138. FORCENORMALFORWARD: boolean;
  124139. SPECULARAA: boolean;
  124140. CLEARCOAT: boolean;
  124141. CLEARCOAT_DEFAULTIOR: boolean;
  124142. CLEARCOAT_TEXTURE: boolean;
  124143. CLEARCOAT_TEXTUREDIRECTUV: number;
  124144. CLEARCOAT_BUMP: boolean;
  124145. CLEARCOAT_BUMPDIRECTUV: number;
  124146. CLEARCOAT_TINT: boolean;
  124147. CLEARCOAT_TINT_TEXTURE: boolean;
  124148. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124149. ANISOTROPIC: boolean;
  124150. ANISOTROPIC_TEXTURE: boolean;
  124151. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124152. BRDF_V_HEIGHT_CORRELATED: boolean;
  124153. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124154. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124155. SHEEN: boolean;
  124156. SHEEN_TEXTURE: boolean;
  124157. SHEEN_TEXTUREDIRECTUV: number;
  124158. SHEEN_LINKWITHALBEDO: boolean;
  124159. SUBSURFACE: boolean;
  124160. SS_REFRACTION: boolean;
  124161. SS_TRANSLUCENCY: boolean;
  124162. SS_SCATERRING: boolean;
  124163. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124164. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124165. SS_REFRACTIONMAP_3D: boolean;
  124166. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124167. SS_LODINREFRACTIONALPHA: boolean;
  124168. SS_GAMMAREFRACTION: boolean;
  124169. SS_RGBDREFRACTION: boolean;
  124170. SS_LINEARSPECULARREFRACTION: boolean;
  124171. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124172. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124173. UNLIT: boolean;
  124174. DEBUGMODE: number;
  124175. /**
  124176. * Initializes the PBR Material defines.
  124177. */
  124178. constructor();
  124179. /**
  124180. * Resets the PBR Material defines.
  124181. */
  124182. reset(): void;
  124183. }
  124184. /**
  124185. * The Physically based material base class of BJS.
  124186. *
  124187. * This offers the main features of a standard PBR material.
  124188. * For more information, please refer to the documentation :
  124189. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124190. */
  124191. export abstract class PBRBaseMaterial extends PushMaterial {
  124192. /**
  124193. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124194. */
  124195. static readonly PBRMATERIAL_OPAQUE: number;
  124196. /**
  124197. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124198. */
  124199. static readonly PBRMATERIAL_ALPHATEST: number;
  124200. /**
  124201. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124202. */
  124203. static readonly PBRMATERIAL_ALPHABLEND: number;
  124204. /**
  124205. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124206. * They are also discarded below the alpha cutoff threshold to improve performances.
  124207. */
  124208. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124209. /**
  124210. * Defines the default value of how much AO map is occluding the analytical lights
  124211. * (point spot...).
  124212. */
  124213. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124214. /**
  124215. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124216. */
  124217. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124218. /**
  124219. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124220. * to enhance interoperability with other engines.
  124221. */
  124222. static readonly LIGHTFALLOFF_GLTF: number;
  124223. /**
  124224. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124225. * to enhance interoperability with other materials.
  124226. */
  124227. static readonly LIGHTFALLOFF_STANDARD: number;
  124228. /**
  124229. * Intensity of the direct lights e.g. the four lights available in your scene.
  124230. * This impacts both the direct diffuse and specular highlights.
  124231. */
  124232. protected _directIntensity: number;
  124233. /**
  124234. * Intensity of the emissive part of the material.
  124235. * This helps controlling the emissive effect without modifying the emissive color.
  124236. */
  124237. protected _emissiveIntensity: number;
  124238. /**
  124239. * Intensity of the environment e.g. how much the environment will light the object
  124240. * either through harmonics for rough material or through the refelction for shiny ones.
  124241. */
  124242. protected _environmentIntensity: number;
  124243. /**
  124244. * This is a special control allowing the reduction of the specular highlights coming from the
  124245. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124246. */
  124247. protected _specularIntensity: number;
  124248. /**
  124249. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124250. */
  124251. private _lightingInfos;
  124252. /**
  124253. * Debug Control allowing disabling the bump map on this material.
  124254. */
  124255. protected _disableBumpMap: boolean;
  124256. /**
  124257. * AKA Diffuse Texture in standard nomenclature.
  124258. */
  124259. protected _albedoTexture: Nullable<BaseTexture>;
  124260. /**
  124261. * AKA Occlusion Texture in other nomenclature.
  124262. */
  124263. protected _ambientTexture: Nullable<BaseTexture>;
  124264. /**
  124265. * AKA Occlusion Texture Intensity in other nomenclature.
  124266. */
  124267. protected _ambientTextureStrength: number;
  124268. /**
  124269. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124270. * 1 means it completely occludes it
  124271. * 0 mean it has no impact
  124272. */
  124273. protected _ambientTextureImpactOnAnalyticalLights: number;
  124274. /**
  124275. * Stores the alpha values in a texture.
  124276. */
  124277. protected _opacityTexture: Nullable<BaseTexture>;
  124278. /**
  124279. * Stores the reflection values in a texture.
  124280. */
  124281. protected _reflectionTexture: Nullable<BaseTexture>;
  124282. /**
  124283. * Stores the emissive values in a texture.
  124284. */
  124285. protected _emissiveTexture: Nullable<BaseTexture>;
  124286. /**
  124287. * AKA Specular texture in other nomenclature.
  124288. */
  124289. protected _reflectivityTexture: Nullable<BaseTexture>;
  124290. /**
  124291. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124292. */
  124293. protected _metallicTexture: Nullable<BaseTexture>;
  124294. /**
  124295. * Specifies the metallic scalar of the metallic/roughness workflow.
  124296. * Can also be used to scale the metalness values of the metallic texture.
  124297. */
  124298. protected _metallic: Nullable<number>;
  124299. /**
  124300. * Specifies the roughness scalar of the metallic/roughness workflow.
  124301. * Can also be used to scale the roughness values of the metallic texture.
  124302. */
  124303. protected _roughness: Nullable<number>;
  124304. /**
  124305. * Specifies the an F0 factor to help configuring the material F0.
  124306. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124307. * to 0.5 the previously hard coded value stays the same.
  124308. * Can also be used to scale the F0 values of the metallic texture.
  124309. */
  124310. protected _metallicF0Factor: number;
  124311. /**
  124312. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124313. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124314. * your expectation as it multiplies with the texture data.
  124315. */
  124316. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124317. /**
  124318. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124319. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124320. */
  124321. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124322. /**
  124323. * Stores surface normal data used to displace a mesh in a texture.
  124324. */
  124325. protected _bumpTexture: Nullable<BaseTexture>;
  124326. /**
  124327. * Stores the pre-calculated light information of a mesh in a texture.
  124328. */
  124329. protected _lightmapTexture: Nullable<BaseTexture>;
  124330. /**
  124331. * The color of a material in ambient lighting.
  124332. */
  124333. protected _ambientColor: Color3;
  124334. /**
  124335. * AKA Diffuse Color in other nomenclature.
  124336. */
  124337. protected _albedoColor: Color3;
  124338. /**
  124339. * AKA Specular Color in other nomenclature.
  124340. */
  124341. protected _reflectivityColor: Color3;
  124342. /**
  124343. * The color applied when light is reflected from a material.
  124344. */
  124345. protected _reflectionColor: Color3;
  124346. /**
  124347. * The color applied when light is emitted from a material.
  124348. */
  124349. protected _emissiveColor: Color3;
  124350. /**
  124351. * AKA Glossiness in other nomenclature.
  124352. */
  124353. protected _microSurface: number;
  124354. /**
  124355. * Specifies that the material will use the light map as a show map.
  124356. */
  124357. protected _useLightmapAsShadowmap: boolean;
  124358. /**
  124359. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124360. * makes the reflect vector face the model (under horizon).
  124361. */
  124362. protected _useHorizonOcclusion: boolean;
  124363. /**
  124364. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124365. * too much the area relying on ambient texture to define their ambient occlusion.
  124366. */
  124367. protected _useRadianceOcclusion: boolean;
  124368. /**
  124369. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124370. */
  124371. protected _useAlphaFromAlbedoTexture: boolean;
  124372. /**
  124373. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124374. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124375. */
  124376. protected _useSpecularOverAlpha: boolean;
  124377. /**
  124378. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124379. */
  124380. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124381. /**
  124382. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124383. */
  124384. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124385. /**
  124386. * Specifies if the metallic texture contains the roughness information in its green channel.
  124387. */
  124388. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124389. /**
  124390. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124391. */
  124392. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124393. /**
  124394. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124395. */
  124396. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124397. /**
  124398. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124399. */
  124400. protected _useAmbientInGrayScale: boolean;
  124401. /**
  124402. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124403. * The material will try to infer what glossiness each pixel should be.
  124404. */
  124405. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124406. /**
  124407. * Defines the falloff type used in this material.
  124408. * It by default is Physical.
  124409. */
  124410. protected _lightFalloff: number;
  124411. /**
  124412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124414. */
  124415. protected _useRadianceOverAlpha: boolean;
  124416. /**
  124417. * Allows using an object space normal map (instead of tangent space).
  124418. */
  124419. protected _useObjectSpaceNormalMap: boolean;
  124420. /**
  124421. * Allows using the bump map in parallax mode.
  124422. */
  124423. protected _useParallax: boolean;
  124424. /**
  124425. * Allows using the bump map in parallax occlusion mode.
  124426. */
  124427. protected _useParallaxOcclusion: boolean;
  124428. /**
  124429. * Controls the scale bias of the parallax mode.
  124430. */
  124431. protected _parallaxScaleBias: number;
  124432. /**
  124433. * If sets to true, disables all the lights affecting the material.
  124434. */
  124435. protected _disableLighting: boolean;
  124436. /**
  124437. * Number of Simultaneous lights allowed on the material.
  124438. */
  124439. protected _maxSimultaneousLights: number;
  124440. /**
  124441. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124442. */
  124443. protected _invertNormalMapX: boolean;
  124444. /**
  124445. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124446. */
  124447. protected _invertNormalMapY: boolean;
  124448. /**
  124449. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124450. */
  124451. protected _twoSidedLighting: boolean;
  124452. /**
  124453. * Defines the alpha limits in alpha test mode.
  124454. */
  124455. protected _alphaCutOff: number;
  124456. /**
  124457. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124458. */
  124459. protected _forceAlphaTest: boolean;
  124460. /**
  124461. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124462. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124463. */
  124464. protected _useAlphaFresnel: boolean;
  124465. /**
  124466. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124467. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124468. */
  124469. protected _useLinearAlphaFresnel: boolean;
  124470. /**
  124471. * The transparency mode of the material.
  124472. */
  124473. protected _transparencyMode: Nullable<number>;
  124474. /**
  124475. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124476. * from cos thetav and roughness:
  124477. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124478. */
  124479. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124480. /**
  124481. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124482. */
  124483. protected _forceIrradianceInFragment: boolean;
  124484. /**
  124485. * Force normal to face away from face.
  124486. */
  124487. protected _forceNormalForward: boolean;
  124488. /**
  124489. * Enables specular anti aliasing in the PBR shader.
  124490. * It will both interacts on the Geometry for analytical and IBL lighting.
  124491. * It also prefilter the roughness map based on the bump values.
  124492. */
  124493. protected _enableSpecularAntiAliasing: boolean;
  124494. /**
  124495. * Default configuration related to image processing available in the PBR Material.
  124496. */
  124497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124498. /**
  124499. * Keep track of the image processing observer to allow dispose and replace.
  124500. */
  124501. private _imageProcessingObserver;
  124502. /**
  124503. * Attaches a new image processing configuration to the PBR Material.
  124504. * @param configuration
  124505. */
  124506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124507. /**
  124508. * Stores the available render targets.
  124509. */
  124510. private _renderTargets;
  124511. /**
  124512. * Sets the global ambient color for the material used in lighting calculations.
  124513. */
  124514. private _globalAmbientColor;
  124515. /**
  124516. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124517. */
  124518. private _useLogarithmicDepth;
  124519. /**
  124520. * If set to true, no lighting calculations will be applied.
  124521. */
  124522. private _unlit;
  124523. private _debugMode;
  124524. /**
  124525. * @hidden
  124526. * This is reserved for the inspector.
  124527. * Defines the material debug mode.
  124528. * It helps seeing only some components of the material while troubleshooting.
  124529. */
  124530. debugMode: number;
  124531. /**
  124532. * @hidden
  124533. * This is reserved for the inspector.
  124534. * Specify from where on screen the debug mode should start.
  124535. * The value goes from -1 (full screen) to 1 (not visible)
  124536. * It helps with side by side comparison against the final render
  124537. * This defaults to -1
  124538. */
  124539. private debugLimit;
  124540. /**
  124541. * @hidden
  124542. * This is reserved for the inspector.
  124543. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124544. * You can use the factor to better multiply the final value.
  124545. */
  124546. private debugFactor;
  124547. /**
  124548. * Defines the clear coat layer parameters for the material.
  124549. */
  124550. readonly clearCoat: PBRClearCoatConfiguration;
  124551. /**
  124552. * Defines the anisotropic parameters for the material.
  124553. */
  124554. readonly anisotropy: PBRAnisotropicConfiguration;
  124555. /**
  124556. * Defines the BRDF parameters for the material.
  124557. */
  124558. readonly brdf: PBRBRDFConfiguration;
  124559. /**
  124560. * Defines the Sheen parameters for the material.
  124561. */
  124562. readonly sheen: PBRSheenConfiguration;
  124563. /**
  124564. * Defines the SubSurface parameters for the material.
  124565. */
  124566. readonly subSurface: PBRSubSurfaceConfiguration;
  124567. /**
  124568. * Custom callback helping to override the default shader used in the material.
  124569. */
  124570. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124571. protected _rebuildInParallel: boolean;
  124572. /**
  124573. * Instantiates a new PBRMaterial instance.
  124574. *
  124575. * @param name The material name
  124576. * @param scene The scene the material will be use in.
  124577. */
  124578. constructor(name: string, scene: Scene);
  124579. /**
  124580. * Gets a boolean indicating that current material needs to register RTT
  124581. */
  124582. get hasRenderTargetTextures(): boolean;
  124583. /**
  124584. * Gets the name of the material class.
  124585. */
  124586. getClassName(): string;
  124587. /**
  124588. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124589. */
  124590. get useLogarithmicDepth(): boolean;
  124591. /**
  124592. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124593. */
  124594. set useLogarithmicDepth(value: boolean);
  124595. /**
  124596. * Gets the current transparency mode.
  124597. */
  124598. get transparencyMode(): Nullable<number>;
  124599. /**
  124600. * Sets the transparency mode of the material.
  124601. *
  124602. * | Value | Type | Description |
  124603. * | ----- | ----------------------------------- | ----------- |
  124604. * | 0 | OPAQUE | |
  124605. * | 1 | ALPHATEST | |
  124606. * | 2 | ALPHABLEND | |
  124607. * | 3 | ALPHATESTANDBLEND | |
  124608. *
  124609. */
  124610. set transparencyMode(value: Nullable<number>);
  124611. /**
  124612. * Returns true if alpha blending should be disabled.
  124613. */
  124614. private get _disableAlphaBlending();
  124615. /**
  124616. * Specifies whether or not this material should be rendered in alpha blend mode.
  124617. */
  124618. needAlphaBlending(): boolean;
  124619. /**
  124620. * Specifies if the mesh will require alpha blending.
  124621. * @param mesh - BJS mesh.
  124622. */
  124623. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124624. /**
  124625. * Specifies whether or not this material should be rendered in alpha test mode.
  124626. */
  124627. needAlphaTesting(): boolean;
  124628. /**
  124629. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124630. */
  124631. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124632. /**
  124633. * Gets the texture used for the alpha test.
  124634. */
  124635. getAlphaTestTexture(): Nullable<BaseTexture>;
  124636. /**
  124637. * Specifies that the submesh is ready to be used.
  124638. * @param mesh - BJS mesh.
  124639. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124640. * @param useInstances - Specifies that instances should be used.
  124641. * @returns - boolean indicating that the submesh is ready or not.
  124642. */
  124643. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124644. /**
  124645. * Specifies if the material uses metallic roughness workflow.
  124646. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124647. */
  124648. isMetallicWorkflow(): boolean;
  124649. private _prepareEffect;
  124650. private _prepareDefines;
  124651. /**
  124652. * Force shader compilation
  124653. */
  124654. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124655. /**
  124656. * Initializes the uniform buffer layout for the shader.
  124657. */
  124658. buildUniformLayout(): void;
  124659. /**
  124660. * Unbinds the material from the mesh
  124661. */
  124662. unbind(): void;
  124663. /**
  124664. * Binds the submesh data.
  124665. * @param world - The world matrix.
  124666. * @param mesh - The BJS mesh.
  124667. * @param subMesh - A submesh of the BJS mesh.
  124668. */
  124669. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124670. /**
  124671. * Returns the animatable textures.
  124672. * @returns - Array of animatable textures.
  124673. */
  124674. getAnimatables(): IAnimatable[];
  124675. /**
  124676. * Returns the texture used for reflections.
  124677. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124678. */
  124679. private _getReflectionTexture;
  124680. /**
  124681. * Returns an array of the actively used textures.
  124682. * @returns - Array of BaseTextures
  124683. */
  124684. getActiveTextures(): BaseTexture[];
  124685. /**
  124686. * Checks to see if a texture is used in the material.
  124687. * @param texture - Base texture to use.
  124688. * @returns - Boolean specifying if a texture is used in the material.
  124689. */
  124690. hasTexture(texture: BaseTexture): boolean;
  124691. /**
  124692. * Disposes the resources of the material.
  124693. * @param forceDisposeEffect - Forces the disposal of effects.
  124694. * @param forceDisposeTextures - Forces the disposal of all textures.
  124695. */
  124696. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124697. }
  124698. }
  124699. declare module BABYLON {
  124700. /**
  124701. * The Physically based material of BJS.
  124702. *
  124703. * This offers the main features of a standard PBR material.
  124704. * For more information, please refer to the documentation :
  124705. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124706. */
  124707. export class PBRMaterial extends PBRBaseMaterial {
  124708. /**
  124709. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124710. */
  124711. static readonly PBRMATERIAL_OPAQUE: number;
  124712. /**
  124713. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124714. */
  124715. static readonly PBRMATERIAL_ALPHATEST: number;
  124716. /**
  124717. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124718. */
  124719. static readonly PBRMATERIAL_ALPHABLEND: number;
  124720. /**
  124721. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124722. * They are also discarded below the alpha cutoff threshold to improve performances.
  124723. */
  124724. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124725. /**
  124726. * Defines the default value of how much AO map is occluding the analytical lights
  124727. * (point spot...).
  124728. */
  124729. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124730. /**
  124731. * Intensity of the direct lights e.g. the four lights available in your scene.
  124732. * This impacts both the direct diffuse and specular highlights.
  124733. */
  124734. directIntensity: number;
  124735. /**
  124736. * Intensity of the emissive part of the material.
  124737. * This helps controlling the emissive effect without modifying the emissive color.
  124738. */
  124739. emissiveIntensity: number;
  124740. /**
  124741. * Intensity of the environment e.g. how much the environment will light the object
  124742. * either through harmonics for rough material or through the refelction for shiny ones.
  124743. */
  124744. environmentIntensity: number;
  124745. /**
  124746. * This is a special control allowing the reduction of the specular highlights coming from the
  124747. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124748. */
  124749. specularIntensity: number;
  124750. /**
  124751. * Debug Control allowing disabling the bump map on this material.
  124752. */
  124753. disableBumpMap: boolean;
  124754. /**
  124755. * AKA Diffuse Texture in standard nomenclature.
  124756. */
  124757. albedoTexture: BaseTexture;
  124758. /**
  124759. * AKA Occlusion Texture in other nomenclature.
  124760. */
  124761. ambientTexture: BaseTexture;
  124762. /**
  124763. * AKA Occlusion Texture Intensity in other nomenclature.
  124764. */
  124765. ambientTextureStrength: number;
  124766. /**
  124767. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124768. * 1 means it completely occludes it
  124769. * 0 mean it has no impact
  124770. */
  124771. ambientTextureImpactOnAnalyticalLights: number;
  124772. /**
  124773. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124774. */
  124775. opacityTexture: BaseTexture;
  124776. /**
  124777. * Stores the reflection values in a texture.
  124778. */
  124779. reflectionTexture: Nullable<BaseTexture>;
  124780. /**
  124781. * Stores the emissive values in a texture.
  124782. */
  124783. emissiveTexture: BaseTexture;
  124784. /**
  124785. * AKA Specular texture in other nomenclature.
  124786. */
  124787. reflectivityTexture: BaseTexture;
  124788. /**
  124789. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124790. */
  124791. metallicTexture: BaseTexture;
  124792. /**
  124793. * Specifies the metallic scalar of the metallic/roughness workflow.
  124794. * Can also be used to scale the metalness values of the metallic texture.
  124795. */
  124796. metallic: Nullable<number>;
  124797. /**
  124798. * Specifies the roughness scalar of the metallic/roughness workflow.
  124799. * Can also be used to scale the roughness values of the metallic texture.
  124800. */
  124801. roughness: Nullable<number>;
  124802. /**
  124803. * Specifies the an F0 factor to help configuring the material F0.
  124804. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124805. * to 0.5 the previously hard coded value stays the same.
  124806. * Can also be used to scale the F0 values of the metallic texture.
  124807. */
  124808. metallicF0Factor: number;
  124809. /**
  124810. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124811. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124812. * your expectation as it multiplies with the texture data.
  124813. */
  124814. useMetallicF0FactorFromMetallicTexture: boolean;
  124815. /**
  124816. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124817. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124818. */
  124819. microSurfaceTexture: BaseTexture;
  124820. /**
  124821. * Stores surface normal data used to displace a mesh in a texture.
  124822. */
  124823. bumpTexture: BaseTexture;
  124824. /**
  124825. * Stores the pre-calculated light information of a mesh in a texture.
  124826. */
  124827. lightmapTexture: BaseTexture;
  124828. /**
  124829. * Stores the refracted light information in a texture.
  124830. */
  124831. get refractionTexture(): Nullable<BaseTexture>;
  124832. set refractionTexture(value: Nullable<BaseTexture>);
  124833. /**
  124834. * The color of a material in ambient lighting.
  124835. */
  124836. ambientColor: Color3;
  124837. /**
  124838. * AKA Diffuse Color in other nomenclature.
  124839. */
  124840. albedoColor: Color3;
  124841. /**
  124842. * AKA Specular Color in other nomenclature.
  124843. */
  124844. reflectivityColor: Color3;
  124845. /**
  124846. * The color reflected from the material.
  124847. */
  124848. reflectionColor: Color3;
  124849. /**
  124850. * The color emitted from the material.
  124851. */
  124852. emissiveColor: Color3;
  124853. /**
  124854. * AKA Glossiness in other nomenclature.
  124855. */
  124856. microSurface: number;
  124857. /**
  124858. * source material index of refraction (IOR)' / 'destination material IOR.
  124859. */
  124860. get indexOfRefraction(): number;
  124861. set indexOfRefraction(value: number);
  124862. /**
  124863. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124864. */
  124865. get invertRefractionY(): boolean;
  124866. set invertRefractionY(value: boolean);
  124867. /**
  124868. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124869. * Materials half opaque for instance using refraction could benefit from this control.
  124870. */
  124871. get linkRefractionWithTransparency(): boolean;
  124872. set linkRefractionWithTransparency(value: boolean);
  124873. /**
  124874. * If true, the light map contains occlusion information instead of lighting info.
  124875. */
  124876. useLightmapAsShadowmap: boolean;
  124877. /**
  124878. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124879. */
  124880. useAlphaFromAlbedoTexture: boolean;
  124881. /**
  124882. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124883. */
  124884. forceAlphaTest: boolean;
  124885. /**
  124886. * Defines the alpha limits in alpha test mode.
  124887. */
  124888. alphaCutOff: number;
  124889. /**
  124890. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124891. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124892. */
  124893. useSpecularOverAlpha: boolean;
  124894. /**
  124895. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124896. */
  124897. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124898. /**
  124899. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124900. */
  124901. useRoughnessFromMetallicTextureAlpha: boolean;
  124902. /**
  124903. * Specifies if the metallic texture contains the roughness information in its green channel.
  124904. */
  124905. useRoughnessFromMetallicTextureGreen: boolean;
  124906. /**
  124907. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124908. */
  124909. useMetallnessFromMetallicTextureBlue: boolean;
  124910. /**
  124911. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124912. */
  124913. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124914. /**
  124915. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124916. */
  124917. useAmbientInGrayScale: boolean;
  124918. /**
  124919. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124920. * The material will try to infer what glossiness each pixel should be.
  124921. */
  124922. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124923. /**
  124924. * BJS is using an harcoded light falloff based on a manually sets up range.
  124925. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124926. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124927. */
  124928. get usePhysicalLightFalloff(): boolean;
  124929. /**
  124930. * BJS is using an harcoded light falloff based on a manually sets up range.
  124931. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124932. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124933. */
  124934. set usePhysicalLightFalloff(value: boolean);
  124935. /**
  124936. * In order to support the falloff compatibility with gltf, a special mode has been added
  124937. * to reproduce the gltf light falloff.
  124938. */
  124939. get useGLTFLightFalloff(): boolean;
  124940. /**
  124941. * In order to support the falloff compatibility with gltf, a special mode has been added
  124942. * to reproduce the gltf light falloff.
  124943. */
  124944. set useGLTFLightFalloff(value: boolean);
  124945. /**
  124946. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124947. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124948. */
  124949. useRadianceOverAlpha: boolean;
  124950. /**
  124951. * Allows using an object space normal map (instead of tangent space).
  124952. */
  124953. useObjectSpaceNormalMap: boolean;
  124954. /**
  124955. * Allows using the bump map in parallax mode.
  124956. */
  124957. useParallax: boolean;
  124958. /**
  124959. * Allows using the bump map in parallax occlusion mode.
  124960. */
  124961. useParallaxOcclusion: boolean;
  124962. /**
  124963. * Controls the scale bias of the parallax mode.
  124964. */
  124965. parallaxScaleBias: number;
  124966. /**
  124967. * If sets to true, disables all the lights affecting the material.
  124968. */
  124969. disableLighting: boolean;
  124970. /**
  124971. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124972. */
  124973. forceIrradianceInFragment: boolean;
  124974. /**
  124975. * Number of Simultaneous lights allowed on the material.
  124976. */
  124977. maxSimultaneousLights: number;
  124978. /**
  124979. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124980. */
  124981. invertNormalMapX: boolean;
  124982. /**
  124983. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124984. */
  124985. invertNormalMapY: boolean;
  124986. /**
  124987. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124988. */
  124989. twoSidedLighting: boolean;
  124990. /**
  124991. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124992. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124993. */
  124994. useAlphaFresnel: boolean;
  124995. /**
  124996. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124997. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124998. */
  124999. useLinearAlphaFresnel: boolean;
  125000. /**
  125001. * Let user defines the brdf lookup texture used for IBL.
  125002. * A default 8bit version is embedded but you could point at :
  125003. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125004. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125005. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125006. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125007. */
  125008. environmentBRDFTexture: Nullable<BaseTexture>;
  125009. /**
  125010. * Force normal to face away from face.
  125011. */
  125012. forceNormalForward: boolean;
  125013. /**
  125014. * Enables specular anti aliasing in the PBR shader.
  125015. * It will both interacts on the Geometry for analytical and IBL lighting.
  125016. * It also prefilter the roughness map based on the bump values.
  125017. */
  125018. enableSpecularAntiAliasing: boolean;
  125019. /**
  125020. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125021. * makes the reflect vector face the model (under horizon).
  125022. */
  125023. useHorizonOcclusion: boolean;
  125024. /**
  125025. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125026. * too much the area relying on ambient texture to define their ambient occlusion.
  125027. */
  125028. useRadianceOcclusion: boolean;
  125029. /**
  125030. * If set to true, no lighting calculations will be applied.
  125031. */
  125032. unlit: boolean;
  125033. /**
  125034. * Gets the image processing configuration used either in this material.
  125035. */
  125036. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125037. /**
  125038. * Sets the Default image processing configuration used either in the this material.
  125039. *
  125040. * If sets to null, the scene one is in use.
  125041. */
  125042. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125043. /**
  125044. * Gets wether the color curves effect is enabled.
  125045. */
  125046. get cameraColorCurvesEnabled(): boolean;
  125047. /**
  125048. * Sets wether the color curves effect is enabled.
  125049. */
  125050. set cameraColorCurvesEnabled(value: boolean);
  125051. /**
  125052. * Gets wether the color grading effect is enabled.
  125053. */
  125054. get cameraColorGradingEnabled(): boolean;
  125055. /**
  125056. * Gets wether the color grading effect is enabled.
  125057. */
  125058. set cameraColorGradingEnabled(value: boolean);
  125059. /**
  125060. * Gets wether tonemapping is enabled or not.
  125061. */
  125062. get cameraToneMappingEnabled(): boolean;
  125063. /**
  125064. * Sets wether tonemapping is enabled or not
  125065. */
  125066. set cameraToneMappingEnabled(value: boolean);
  125067. /**
  125068. * The camera exposure used on this material.
  125069. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125070. * This corresponds to a photographic exposure.
  125071. */
  125072. get cameraExposure(): number;
  125073. /**
  125074. * The camera exposure used on this material.
  125075. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125076. * This corresponds to a photographic exposure.
  125077. */
  125078. set cameraExposure(value: number);
  125079. /**
  125080. * Gets The camera contrast used on this material.
  125081. */
  125082. get cameraContrast(): number;
  125083. /**
  125084. * Sets The camera contrast used on this material.
  125085. */
  125086. set cameraContrast(value: number);
  125087. /**
  125088. * Gets the Color Grading 2D Lookup Texture.
  125089. */
  125090. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125091. /**
  125092. * Sets the Color Grading 2D Lookup Texture.
  125093. */
  125094. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125095. /**
  125096. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125097. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125098. * 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;
  125099. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125100. */
  125101. get cameraColorCurves(): Nullable<ColorCurves>;
  125102. /**
  125103. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125104. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125105. * 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;
  125106. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125107. */
  125108. set cameraColorCurves(value: Nullable<ColorCurves>);
  125109. /**
  125110. * Instantiates a new PBRMaterial instance.
  125111. *
  125112. * @param name The material name
  125113. * @param scene The scene the material will be use in.
  125114. */
  125115. constructor(name: string, scene: Scene);
  125116. /**
  125117. * Returns the name of this material class.
  125118. */
  125119. getClassName(): string;
  125120. /**
  125121. * Makes a duplicate of the current material.
  125122. * @param name - name to use for the new material.
  125123. */
  125124. clone(name: string): PBRMaterial;
  125125. /**
  125126. * Serializes this PBR Material.
  125127. * @returns - An object with the serialized material.
  125128. */
  125129. serialize(): any;
  125130. /**
  125131. * Parses a PBR Material from a serialized object.
  125132. * @param source - Serialized object.
  125133. * @param scene - BJS scene instance.
  125134. * @param rootUrl - url for the scene object
  125135. * @returns - PBRMaterial
  125136. */
  125137. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125138. }
  125139. }
  125140. declare module BABYLON {
  125141. /**
  125142. * Direct draw surface info
  125143. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125144. */
  125145. export interface DDSInfo {
  125146. /**
  125147. * Width of the texture
  125148. */
  125149. width: number;
  125150. /**
  125151. * Width of the texture
  125152. */
  125153. height: number;
  125154. /**
  125155. * Number of Mipmaps for the texture
  125156. * @see https://en.wikipedia.org/wiki/Mipmap
  125157. */
  125158. mipmapCount: number;
  125159. /**
  125160. * If the textures format is a known fourCC format
  125161. * @see https://www.fourcc.org/
  125162. */
  125163. isFourCC: boolean;
  125164. /**
  125165. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125166. */
  125167. isRGB: boolean;
  125168. /**
  125169. * If the texture is a lumincance format
  125170. */
  125171. isLuminance: boolean;
  125172. /**
  125173. * If this is a cube texture
  125174. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125175. */
  125176. isCube: boolean;
  125177. /**
  125178. * If the texture is a compressed format eg. FOURCC_DXT1
  125179. */
  125180. isCompressed: boolean;
  125181. /**
  125182. * The dxgiFormat of the texture
  125183. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125184. */
  125185. dxgiFormat: number;
  125186. /**
  125187. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125188. */
  125189. textureType: number;
  125190. /**
  125191. * Sphericle polynomial created for the dds texture
  125192. */
  125193. sphericalPolynomial?: SphericalPolynomial;
  125194. }
  125195. /**
  125196. * Class used to provide DDS decompression tools
  125197. */
  125198. export class DDSTools {
  125199. /**
  125200. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125201. */
  125202. static StoreLODInAlphaChannel: boolean;
  125203. /**
  125204. * Gets DDS information from an array buffer
  125205. * @param data defines the array buffer view to read data from
  125206. * @returns the DDS information
  125207. */
  125208. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125209. private static _FloatView;
  125210. private static _Int32View;
  125211. private static _ToHalfFloat;
  125212. private static _FromHalfFloat;
  125213. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125214. private static _GetHalfFloatRGBAArrayBuffer;
  125215. private static _GetFloatRGBAArrayBuffer;
  125216. private static _GetFloatAsUIntRGBAArrayBuffer;
  125217. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125218. private static _GetRGBAArrayBuffer;
  125219. private static _ExtractLongWordOrder;
  125220. private static _GetRGBArrayBuffer;
  125221. private static _GetLuminanceArrayBuffer;
  125222. /**
  125223. * Uploads DDS Levels to a Babylon Texture
  125224. * @hidden
  125225. */
  125226. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125227. }
  125228. interface ThinEngine {
  125229. /**
  125230. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125231. * @param rootUrl defines the url where the file to load is located
  125232. * @param scene defines the current scene
  125233. * @param lodScale defines scale to apply to the mip map selection
  125234. * @param lodOffset defines offset to apply to the mip map selection
  125235. * @param onLoad defines an optional callback raised when the texture is loaded
  125236. * @param onError defines an optional callback raised if there is an issue to load the texture
  125237. * @param format defines the format of the data
  125238. * @param forcedExtension defines the extension to use to pick the right loader
  125239. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125240. * @returns the cube texture as an InternalTexture
  125241. */
  125242. 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;
  125243. }
  125244. }
  125245. declare module BABYLON {
  125246. /**
  125247. * Implementation of the DDS Texture Loader.
  125248. * @hidden
  125249. */
  125250. export class _DDSTextureLoader implements IInternalTextureLoader {
  125251. /**
  125252. * Defines wether the loader supports cascade loading the different faces.
  125253. */
  125254. readonly supportCascades: boolean;
  125255. /**
  125256. * This returns if the loader support the current file information.
  125257. * @param extension defines the file extension of the file being loaded
  125258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125259. * @param fallback defines the fallback internal texture if any
  125260. * @param isBase64 defines whether the texture is encoded as a base64
  125261. * @param isBuffer defines whether the texture data are stored as a buffer
  125262. * @returns true if the loader can load the specified file
  125263. */
  125264. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125265. /**
  125266. * Transform the url before loading if required.
  125267. * @param rootUrl the url of the texture
  125268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125269. * @returns the transformed texture
  125270. */
  125271. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125272. /**
  125273. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125274. * @param rootUrl the url of the texture
  125275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125276. * @returns the fallback texture
  125277. */
  125278. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125279. /**
  125280. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125281. * @param data contains the texture data
  125282. * @param texture defines the BabylonJS internal texture
  125283. * @param createPolynomials will be true if polynomials have been requested
  125284. * @param onLoad defines the callback to trigger once the texture is ready
  125285. * @param onError defines the callback to trigger in case of error
  125286. */
  125287. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125288. /**
  125289. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125290. * @param data contains the texture data
  125291. * @param texture defines the BabylonJS internal texture
  125292. * @param callback defines the method to call once ready to upload
  125293. */
  125294. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125295. }
  125296. }
  125297. declare module BABYLON {
  125298. /**
  125299. * Implementation of the ENV Texture Loader.
  125300. * @hidden
  125301. */
  125302. export class _ENVTextureLoader implements IInternalTextureLoader {
  125303. /**
  125304. * Defines wether the loader supports cascade loading the different faces.
  125305. */
  125306. readonly supportCascades: boolean;
  125307. /**
  125308. * This returns if the loader support the current file information.
  125309. * @param extension defines the file extension of the file being loaded
  125310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125311. * @param fallback defines the fallback internal texture if any
  125312. * @param isBase64 defines whether the texture is encoded as a base64
  125313. * @param isBuffer defines whether the texture data are stored as a buffer
  125314. * @returns true if the loader can load the specified file
  125315. */
  125316. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125317. /**
  125318. * Transform the url before loading if required.
  125319. * @param rootUrl the url of the texture
  125320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125321. * @returns the transformed texture
  125322. */
  125323. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125324. /**
  125325. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125326. * @param rootUrl the url of the texture
  125327. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125328. * @returns the fallback texture
  125329. */
  125330. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125331. /**
  125332. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125333. * @param data contains the texture data
  125334. * @param texture defines the BabylonJS internal texture
  125335. * @param createPolynomials will be true if polynomials have been requested
  125336. * @param onLoad defines the callback to trigger once the texture is ready
  125337. * @param onError defines the callback to trigger in case of error
  125338. */
  125339. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125340. /**
  125341. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125342. * @param data contains the texture data
  125343. * @param texture defines the BabylonJS internal texture
  125344. * @param callback defines the method to call once ready to upload
  125345. */
  125346. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125347. }
  125348. }
  125349. declare module BABYLON {
  125350. /**
  125351. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125352. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125353. */
  125354. export class KhronosTextureContainer {
  125355. /** contents of the KTX container file */
  125356. data: ArrayBufferView;
  125357. private static HEADER_LEN;
  125358. private static COMPRESSED_2D;
  125359. private static COMPRESSED_3D;
  125360. private static TEX_2D;
  125361. private static TEX_3D;
  125362. /**
  125363. * Gets the openGL type
  125364. */
  125365. glType: number;
  125366. /**
  125367. * Gets the openGL type size
  125368. */
  125369. glTypeSize: number;
  125370. /**
  125371. * Gets the openGL format
  125372. */
  125373. glFormat: number;
  125374. /**
  125375. * Gets the openGL internal format
  125376. */
  125377. glInternalFormat: number;
  125378. /**
  125379. * Gets the base internal format
  125380. */
  125381. glBaseInternalFormat: number;
  125382. /**
  125383. * Gets image width in pixel
  125384. */
  125385. pixelWidth: number;
  125386. /**
  125387. * Gets image height in pixel
  125388. */
  125389. pixelHeight: number;
  125390. /**
  125391. * Gets image depth in pixels
  125392. */
  125393. pixelDepth: number;
  125394. /**
  125395. * Gets the number of array elements
  125396. */
  125397. numberOfArrayElements: number;
  125398. /**
  125399. * Gets the number of faces
  125400. */
  125401. numberOfFaces: number;
  125402. /**
  125403. * Gets the number of mipmap levels
  125404. */
  125405. numberOfMipmapLevels: number;
  125406. /**
  125407. * Gets the bytes of key value data
  125408. */
  125409. bytesOfKeyValueData: number;
  125410. /**
  125411. * Gets the load type
  125412. */
  125413. loadType: number;
  125414. /**
  125415. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125416. */
  125417. isInvalid: boolean;
  125418. /**
  125419. * Creates a new KhronosTextureContainer
  125420. * @param data contents of the KTX container file
  125421. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125422. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125423. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125424. */
  125425. constructor(
  125426. /** contents of the KTX container file */
  125427. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125428. /**
  125429. * Uploads KTX content to a Babylon Texture.
  125430. * It is assumed that the texture has already been created & is currently bound
  125431. * @hidden
  125432. */
  125433. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125434. private _upload2DCompressedLevels;
  125435. }
  125436. }
  125437. declare module BABYLON {
  125438. /**
  125439. * Implementation of the KTX Texture Loader.
  125440. * @hidden
  125441. */
  125442. export class _KTXTextureLoader implements IInternalTextureLoader {
  125443. /**
  125444. * Defines wether the loader supports cascade loading the different faces.
  125445. */
  125446. readonly supportCascades: boolean;
  125447. /**
  125448. * This returns if the loader support the current file information.
  125449. * @param extension defines the file extension of the file being loaded
  125450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125451. * @param fallback defines the fallback internal texture if any
  125452. * @param isBase64 defines whether the texture is encoded as a base64
  125453. * @param isBuffer defines whether the texture data are stored as a buffer
  125454. * @returns true if the loader can load the specified file
  125455. */
  125456. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125457. /**
  125458. * Transform the url before loading if required.
  125459. * @param rootUrl the url of the texture
  125460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125461. * @returns the transformed texture
  125462. */
  125463. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125464. /**
  125465. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125466. * @param rootUrl the url of the texture
  125467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125468. * @returns the fallback texture
  125469. */
  125470. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125471. /**
  125472. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125473. * @param data contains the texture data
  125474. * @param texture defines the BabylonJS internal texture
  125475. * @param createPolynomials will be true if polynomials have been requested
  125476. * @param onLoad defines the callback to trigger once the texture is ready
  125477. * @param onError defines the callback to trigger in case of error
  125478. */
  125479. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125480. /**
  125481. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125482. * @param data contains the texture data
  125483. * @param texture defines the BabylonJS internal texture
  125484. * @param callback defines the method to call once ready to upload
  125485. */
  125486. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125487. }
  125488. }
  125489. declare module BABYLON {
  125490. /** @hidden */
  125491. export var _forceSceneHelpersToBundle: boolean;
  125492. interface Scene {
  125493. /**
  125494. * Creates a default light for the scene.
  125495. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125496. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125497. */
  125498. createDefaultLight(replace?: boolean): void;
  125499. /**
  125500. * Creates a default camera for the scene.
  125501. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125502. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125503. * @param replace has default false, when true replaces the active camera in the scene
  125504. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125505. */
  125506. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125507. /**
  125508. * Creates a default camera and a default light.
  125509. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125510. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125511. * @param replace has the default false, when true replaces the active camera/light in the scene
  125512. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125513. */
  125514. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125515. /**
  125516. * Creates a new sky box
  125517. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125518. * @param environmentTexture defines the texture to use as environment texture
  125519. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125520. * @param scale defines the overall scale of the skybox
  125521. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125522. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125523. * @returns a new mesh holding the sky box
  125524. */
  125525. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125526. /**
  125527. * Creates a new environment
  125528. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125529. * @param options defines the options you can use to configure the environment
  125530. * @returns the new EnvironmentHelper
  125531. */
  125532. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125533. /**
  125534. * Creates a new VREXperienceHelper
  125535. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125536. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125537. * @returns a new VREXperienceHelper
  125538. */
  125539. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125540. /**
  125541. * Creates a new WebXRDefaultExperience
  125542. * @see http://doc.babylonjs.com/how_to/webxr
  125543. * @param options experience options
  125544. * @returns a promise for a new WebXRDefaultExperience
  125545. */
  125546. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125547. }
  125548. }
  125549. declare module BABYLON {
  125550. /**
  125551. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125552. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125553. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125554. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125555. */
  125556. export class VideoDome extends TransformNode {
  125557. /**
  125558. * Define the video source as a Monoscopic panoramic 360 video.
  125559. */
  125560. static readonly MODE_MONOSCOPIC: number;
  125561. /**
  125562. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125563. */
  125564. static readonly MODE_TOPBOTTOM: number;
  125565. /**
  125566. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125567. */
  125568. static readonly MODE_SIDEBYSIDE: number;
  125569. private _halfDome;
  125570. private _useDirectMapping;
  125571. /**
  125572. * The video texture being displayed on the sphere
  125573. */
  125574. protected _videoTexture: VideoTexture;
  125575. /**
  125576. * Gets the video texture being displayed on the sphere
  125577. */
  125578. get videoTexture(): VideoTexture;
  125579. /**
  125580. * The skybox material
  125581. */
  125582. protected _material: BackgroundMaterial;
  125583. /**
  125584. * The surface used for the skybox
  125585. */
  125586. protected _mesh: Mesh;
  125587. /**
  125588. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125589. */
  125590. private _halfDomeMask;
  125591. /**
  125592. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125593. * Also see the options.resolution property.
  125594. */
  125595. get fovMultiplier(): number;
  125596. set fovMultiplier(value: number);
  125597. private _videoMode;
  125598. /**
  125599. * Gets or set the current video mode for the video. It can be:
  125600. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125601. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125602. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125603. */
  125604. get videoMode(): number;
  125605. set videoMode(value: number);
  125606. /**
  125607. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125608. *
  125609. */
  125610. get halfDome(): boolean;
  125611. /**
  125612. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125613. */
  125614. set halfDome(enabled: boolean);
  125615. /**
  125616. * Oberserver used in Stereoscopic VR Mode.
  125617. */
  125618. private _onBeforeCameraRenderObserver;
  125619. /**
  125620. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125621. * @param name Element's name, child elements will append suffixes for their own names.
  125622. * @param urlsOrVideo defines the url(s) or the video element to use
  125623. * @param options An object containing optional or exposed sub element properties
  125624. */
  125625. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125626. resolution?: number;
  125627. clickToPlay?: boolean;
  125628. autoPlay?: boolean;
  125629. loop?: boolean;
  125630. size?: number;
  125631. poster?: string;
  125632. faceForward?: boolean;
  125633. useDirectMapping?: boolean;
  125634. halfDomeMode?: boolean;
  125635. }, scene: Scene);
  125636. private _changeVideoMode;
  125637. /**
  125638. * Releases resources associated with this node.
  125639. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125640. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125641. */
  125642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * This class can be used to get instrumentation data from a Babylon engine
  125648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125649. */
  125650. export class EngineInstrumentation implements IDisposable {
  125651. /**
  125652. * Define the instrumented engine.
  125653. */
  125654. engine: Engine;
  125655. private _captureGPUFrameTime;
  125656. private _gpuFrameTimeToken;
  125657. private _gpuFrameTime;
  125658. private _captureShaderCompilationTime;
  125659. private _shaderCompilationTime;
  125660. private _onBeginFrameObserver;
  125661. private _onEndFrameObserver;
  125662. private _onBeforeShaderCompilationObserver;
  125663. private _onAfterShaderCompilationObserver;
  125664. /**
  125665. * Gets the perf counter used for GPU frame time
  125666. */
  125667. get gpuFrameTimeCounter(): PerfCounter;
  125668. /**
  125669. * Gets the GPU frame time capture status
  125670. */
  125671. get captureGPUFrameTime(): boolean;
  125672. /**
  125673. * Enable or disable the GPU frame time capture
  125674. */
  125675. set captureGPUFrameTime(value: boolean);
  125676. /**
  125677. * Gets the perf counter used for shader compilation time
  125678. */
  125679. get shaderCompilationTimeCounter(): PerfCounter;
  125680. /**
  125681. * Gets the shader compilation time capture status
  125682. */
  125683. get captureShaderCompilationTime(): boolean;
  125684. /**
  125685. * Enable or disable the shader compilation time capture
  125686. */
  125687. set captureShaderCompilationTime(value: boolean);
  125688. /**
  125689. * Instantiates a new engine instrumentation.
  125690. * This class can be used to get instrumentation data from a Babylon engine
  125691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125692. * @param engine Defines the engine to instrument
  125693. */
  125694. constructor(
  125695. /**
  125696. * Define the instrumented engine.
  125697. */
  125698. engine: Engine);
  125699. /**
  125700. * Dispose and release associated resources.
  125701. */
  125702. dispose(): void;
  125703. }
  125704. }
  125705. declare module BABYLON {
  125706. /**
  125707. * This class can be used to get instrumentation data from a Babylon engine
  125708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125709. */
  125710. export class SceneInstrumentation implements IDisposable {
  125711. /**
  125712. * Defines the scene to instrument
  125713. */
  125714. scene: Scene;
  125715. private _captureActiveMeshesEvaluationTime;
  125716. private _activeMeshesEvaluationTime;
  125717. private _captureRenderTargetsRenderTime;
  125718. private _renderTargetsRenderTime;
  125719. private _captureFrameTime;
  125720. private _frameTime;
  125721. private _captureRenderTime;
  125722. private _renderTime;
  125723. private _captureInterFrameTime;
  125724. private _interFrameTime;
  125725. private _captureParticlesRenderTime;
  125726. private _particlesRenderTime;
  125727. private _captureSpritesRenderTime;
  125728. private _spritesRenderTime;
  125729. private _capturePhysicsTime;
  125730. private _physicsTime;
  125731. private _captureAnimationsTime;
  125732. private _animationsTime;
  125733. private _captureCameraRenderTime;
  125734. private _cameraRenderTime;
  125735. private _onBeforeActiveMeshesEvaluationObserver;
  125736. private _onAfterActiveMeshesEvaluationObserver;
  125737. private _onBeforeRenderTargetsRenderObserver;
  125738. private _onAfterRenderTargetsRenderObserver;
  125739. private _onAfterRenderObserver;
  125740. private _onBeforeDrawPhaseObserver;
  125741. private _onAfterDrawPhaseObserver;
  125742. private _onBeforeAnimationsObserver;
  125743. private _onBeforeParticlesRenderingObserver;
  125744. private _onAfterParticlesRenderingObserver;
  125745. private _onBeforeSpritesRenderingObserver;
  125746. private _onAfterSpritesRenderingObserver;
  125747. private _onBeforePhysicsObserver;
  125748. private _onAfterPhysicsObserver;
  125749. private _onAfterAnimationsObserver;
  125750. private _onBeforeCameraRenderObserver;
  125751. private _onAfterCameraRenderObserver;
  125752. /**
  125753. * Gets the perf counter used for active meshes evaluation time
  125754. */
  125755. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125756. /**
  125757. * Gets the active meshes evaluation time capture status
  125758. */
  125759. get captureActiveMeshesEvaluationTime(): boolean;
  125760. /**
  125761. * Enable or disable the active meshes evaluation time capture
  125762. */
  125763. set captureActiveMeshesEvaluationTime(value: boolean);
  125764. /**
  125765. * Gets the perf counter used for render targets render time
  125766. */
  125767. get renderTargetsRenderTimeCounter(): PerfCounter;
  125768. /**
  125769. * Gets the render targets render time capture status
  125770. */
  125771. get captureRenderTargetsRenderTime(): boolean;
  125772. /**
  125773. * Enable or disable the render targets render time capture
  125774. */
  125775. set captureRenderTargetsRenderTime(value: boolean);
  125776. /**
  125777. * Gets the perf counter used for particles render time
  125778. */
  125779. get particlesRenderTimeCounter(): PerfCounter;
  125780. /**
  125781. * Gets the particles render time capture status
  125782. */
  125783. get captureParticlesRenderTime(): boolean;
  125784. /**
  125785. * Enable or disable the particles render time capture
  125786. */
  125787. set captureParticlesRenderTime(value: boolean);
  125788. /**
  125789. * Gets the perf counter used for sprites render time
  125790. */
  125791. get spritesRenderTimeCounter(): PerfCounter;
  125792. /**
  125793. * Gets the sprites render time capture status
  125794. */
  125795. get captureSpritesRenderTime(): boolean;
  125796. /**
  125797. * Enable or disable the sprites render time capture
  125798. */
  125799. set captureSpritesRenderTime(value: boolean);
  125800. /**
  125801. * Gets the perf counter used for physics time
  125802. */
  125803. get physicsTimeCounter(): PerfCounter;
  125804. /**
  125805. * Gets the physics time capture status
  125806. */
  125807. get capturePhysicsTime(): boolean;
  125808. /**
  125809. * Enable or disable the physics time capture
  125810. */
  125811. set capturePhysicsTime(value: boolean);
  125812. /**
  125813. * Gets the perf counter used for animations time
  125814. */
  125815. get animationsTimeCounter(): PerfCounter;
  125816. /**
  125817. * Gets the animations time capture status
  125818. */
  125819. get captureAnimationsTime(): boolean;
  125820. /**
  125821. * Enable or disable the animations time capture
  125822. */
  125823. set captureAnimationsTime(value: boolean);
  125824. /**
  125825. * Gets the perf counter used for frame time capture
  125826. */
  125827. get frameTimeCounter(): PerfCounter;
  125828. /**
  125829. * Gets the frame time capture status
  125830. */
  125831. get captureFrameTime(): boolean;
  125832. /**
  125833. * Enable or disable the frame time capture
  125834. */
  125835. set captureFrameTime(value: boolean);
  125836. /**
  125837. * Gets the perf counter used for inter-frames time capture
  125838. */
  125839. get interFrameTimeCounter(): PerfCounter;
  125840. /**
  125841. * Gets the inter-frames time capture status
  125842. */
  125843. get captureInterFrameTime(): boolean;
  125844. /**
  125845. * Enable or disable the inter-frames time capture
  125846. */
  125847. set captureInterFrameTime(value: boolean);
  125848. /**
  125849. * Gets the perf counter used for render time capture
  125850. */
  125851. get renderTimeCounter(): PerfCounter;
  125852. /**
  125853. * Gets the render time capture status
  125854. */
  125855. get captureRenderTime(): boolean;
  125856. /**
  125857. * Enable or disable the render time capture
  125858. */
  125859. set captureRenderTime(value: boolean);
  125860. /**
  125861. * Gets the perf counter used for camera render time capture
  125862. */
  125863. get cameraRenderTimeCounter(): PerfCounter;
  125864. /**
  125865. * Gets the camera render time capture status
  125866. */
  125867. get captureCameraRenderTime(): boolean;
  125868. /**
  125869. * Enable or disable the camera render time capture
  125870. */
  125871. set captureCameraRenderTime(value: boolean);
  125872. /**
  125873. * Gets the perf counter used for draw calls
  125874. */
  125875. get drawCallsCounter(): PerfCounter;
  125876. /**
  125877. * Instantiates a new scene instrumentation.
  125878. * This class can be used to get instrumentation data from a Babylon engine
  125879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125880. * @param scene Defines the scene to instrument
  125881. */
  125882. constructor(
  125883. /**
  125884. * Defines the scene to instrument
  125885. */
  125886. scene: Scene);
  125887. /**
  125888. * Dispose and release associated resources.
  125889. */
  125890. dispose(): void;
  125891. }
  125892. }
  125893. declare module BABYLON {
  125894. /** @hidden */
  125895. export var glowMapGenerationPixelShader: {
  125896. name: string;
  125897. shader: string;
  125898. };
  125899. }
  125900. declare module BABYLON {
  125901. /** @hidden */
  125902. export var glowMapGenerationVertexShader: {
  125903. name: string;
  125904. shader: string;
  125905. };
  125906. }
  125907. declare module BABYLON {
  125908. /**
  125909. * Effect layer options. This helps customizing the behaviour
  125910. * of the effect layer.
  125911. */
  125912. export interface IEffectLayerOptions {
  125913. /**
  125914. * Multiplication factor apply to the canvas size to compute the render target size
  125915. * used to generated the objects (the smaller the faster).
  125916. */
  125917. mainTextureRatio: number;
  125918. /**
  125919. * Enforces a fixed size texture to ensure effect stability across devices.
  125920. */
  125921. mainTextureFixedSize?: number;
  125922. /**
  125923. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125924. */
  125925. alphaBlendingMode: number;
  125926. /**
  125927. * The camera attached to the layer.
  125928. */
  125929. camera: Nullable<Camera>;
  125930. /**
  125931. * The rendering group to draw the layer in.
  125932. */
  125933. renderingGroupId: number;
  125934. }
  125935. /**
  125936. * The effect layer Helps adding post process effect blended with the main pass.
  125937. *
  125938. * This can be for instance use to generate glow or higlight effects on the scene.
  125939. *
  125940. * The effect layer class can not be used directly and is intented to inherited from to be
  125941. * customized per effects.
  125942. */
  125943. export abstract class EffectLayer {
  125944. private _vertexBuffers;
  125945. private _indexBuffer;
  125946. private _cachedDefines;
  125947. private _effectLayerMapGenerationEffect;
  125948. private _effectLayerOptions;
  125949. private _mergeEffect;
  125950. protected _scene: Scene;
  125951. protected _engine: Engine;
  125952. protected _maxSize: number;
  125953. protected _mainTextureDesiredSize: ISize;
  125954. protected _mainTexture: RenderTargetTexture;
  125955. protected _shouldRender: boolean;
  125956. protected _postProcesses: PostProcess[];
  125957. protected _textures: BaseTexture[];
  125958. protected _emissiveTextureAndColor: {
  125959. texture: Nullable<BaseTexture>;
  125960. color: Color4;
  125961. };
  125962. /**
  125963. * The name of the layer
  125964. */
  125965. name: string;
  125966. /**
  125967. * The clear color of the texture used to generate the glow map.
  125968. */
  125969. neutralColor: Color4;
  125970. /**
  125971. * Specifies whether the highlight layer is enabled or not.
  125972. */
  125973. isEnabled: boolean;
  125974. /**
  125975. * Gets the camera attached to the layer.
  125976. */
  125977. get camera(): Nullable<Camera>;
  125978. /**
  125979. * Gets the rendering group id the layer should render in.
  125980. */
  125981. get renderingGroupId(): number;
  125982. set renderingGroupId(renderingGroupId: number);
  125983. /**
  125984. * An event triggered when the effect layer has been disposed.
  125985. */
  125986. onDisposeObservable: Observable<EffectLayer>;
  125987. /**
  125988. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125989. */
  125990. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125991. /**
  125992. * An event triggered when the generated texture is being merged in the scene.
  125993. */
  125994. onBeforeComposeObservable: Observable<EffectLayer>;
  125995. /**
  125996. * An event triggered when the mesh is rendered into the effect render target.
  125997. */
  125998. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125999. /**
  126000. * An event triggered after the mesh has been rendered into the effect render target.
  126001. */
  126002. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126003. /**
  126004. * An event triggered when the generated texture has been merged in the scene.
  126005. */
  126006. onAfterComposeObservable: Observable<EffectLayer>;
  126007. /**
  126008. * An event triggered when the efffect layer changes its size.
  126009. */
  126010. onSizeChangedObservable: Observable<EffectLayer>;
  126011. /** @hidden */
  126012. static _SceneComponentInitialization: (scene: Scene) => void;
  126013. /**
  126014. * Instantiates a new effect Layer and references it in the scene.
  126015. * @param name The name of the layer
  126016. * @param scene The scene to use the layer in
  126017. */
  126018. constructor(
  126019. /** The Friendly of the effect in the scene */
  126020. name: string, scene: Scene);
  126021. /**
  126022. * Get the effect name of the layer.
  126023. * @return The effect name
  126024. */
  126025. abstract getEffectName(): string;
  126026. /**
  126027. * Checks for the readiness of the element composing the layer.
  126028. * @param subMesh the mesh to check for
  126029. * @param useInstances specify whether or not to use instances to render the mesh
  126030. * @return true if ready otherwise, false
  126031. */
  126032. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126033. /**
  126034. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126035. * @returns true if the effect requires stencil during the main canvas render pass.
  126036. */
  126037. abstract needStencil(): boolean;
  126038. /**
  126039. * Create the merge effect. This is the shader use to blit the information back
  126040. * to the main canvas at the end of the scene rendering.
  126041. * @returns The effect containing the shader used to merge the effect on the main canvas
  126042. */
  126043. protected abstract _createMergeEffect(): Effect;
  126044. /**
  126045. * Creates the render target textures and post processes used in the effect layer.
  126046. */
  126047. protected abstract _createTextureAndPostProcesses(): void;
  126048. /**
  126049. * Implementation specific of rendering the generating effect on the main canvas.
  126050. * @param effect The effect used to render through
  126051. */
  126052. protected abstract _internalRender(effect: Effect): void;
  126053. /**
  126054. * Sets the required values for both the emissive texture and and the main color.
  126055. */
  126056. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126057. /**
  126058. * Free any resources and references associated to a mesh.
  126059. * Internal use
  126060. * @param mesh The mesh to free.
  126061. */
  126062. abstract _disposeMesh(mesh: Mesh): void;
  126063. /**
  126064. * Serializes this layer (Glow or Highlight for example)
  126065. * @returns a serialized layer object
  126066. */
  126067. abstract serialize?(): any;
  126068. /**
  126069. * Initializes the effect layer with the required options.
  126070. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126071. */
  126072. protected _init(options: Partial<IEffectLayerOptions>): void;
  126073. /**
  126074. * Generates the index buffer of the full screen quad blending to the main canvas.
  126075. */
  126076. private _generateIndexBuffer;
  126077. /**
  126078. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126079. */
  126080. private _generateVertexBuffer;
  126081. /**
  126082. * Sets the main texture desired size which is the closest power of two
  126083. * of the engine canvas size.
  126084. */
  126085. private _setMainTextureSize;
  126086. /**
  126087. * Creates the main texture for the effect layer.
  126088. */
  126089. protected _createMainTexture(): void;
  126090. /**
  126091. * Adds specific effects defines.
  126092. * @param defines The defines to add specifics to.
  126093. */
  126094. protected _addCustomEffectDefines(defines: string[]): void;
  126095. /**
  126096. * Checks for the readiness of the element composing the layer.
  126097. * @param subMesh the mesh to check for
  126098. * @param useInstances specify whether or not to use instances to render the mesh
  126099. * @param emissiveTexture the associated emissive texture used to generate the glow
  126100. * @return true if ready otherwise, false
  126101. */
  126102. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126103. /**
  126104. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126105. */
  126106. render(): void;
  126107. /**
  126108. * Determine if a given mesh will be used in the current effect.
  126109. * @param mesh mesh to test
  126110. * @returns true if the mesh will be used
  126111. */
  126112. hasMesh(mesh: AbstractMesh): boolean;
  126113. /**
  126114. * Returns true if the layer contains information to display, otherwise false.
  126115. * @returns true if the glow layer should be rendered
  126116. */
  126117. shouldRender(): boolean;
  126118. /**
  126119. * Returns true if the mesh should render, otherwise false.
  126120. * @param mesh The mesh to render
  126121. * @returns true if it should render otherwise false
  126122. */
  126123. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126124. /**
  126125. * Returns true if the mesh can be rendered, otherwise false.
  126126. * @param mesh The mesh to render
  126127. * @param material The material used on the mesh
  126128. * @returns true if it can be rendered otherwise false
  126129. */
  126130. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126131. /**
  126132. * Returns true if the mesh should render, otherwise false.
  126133. * @param mesh The mesh to render
  126134. * @returns true if it should render otherwise false
  126135. */
  126136. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126137. /**
  126138. * Renders the submesh passed in parameter to the generation map.
  126139. */
  126140. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126141. /**
  126142. * Defines whether the current material of the mesh should be use to render the effect.
  126143. * @param mesh defines the current mesh to render
  126144. */
  126145. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126146. /**
  126147. * Rebuild the required buffers.
  126148. * @hidden Internal use only.
  126149. */
  126150. _rebuild(): void;
  126151. /**
  126152. * Dispose only the render target textures and post process.
  126153. */
  126154. private _disposeTextureAndPostProcesses;
  126155. /**
  126156. * Dispose the highlight layer and free resources.
  126157. */
  126158. dispose(): void;
  126159. /**
  126160. * Gets the class name of the effect layer
  126161. * @returns the string with the class name of the effect layer
  126162. */
  126163. getClassName(): string;
  126164. /**
  126165. * Creates an effect layer from parsed effect layer data
  126166. * @param parsedEffectLayer defines effect layer data
  126167. * @param scene defines the current scene
  126168. * @param rootUrl defines the root URL containing the effect layer information
  126169. * @returns a parsed effect Layer
  126170. */
  126171. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126172. }
  126173. }
  126174. declare module BABYLON {
  126175. interface AbstractScene {
  126176. /**
  126177. * The list of effect layers (highlights/glow) added to the scene
  126178. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126179. * @see http://doc.babylonjs.com/how_to/glow_layer
  126180. */
  126181. effectLayers: Array<EffectLayer>;
  126182. /**
  126183. * Removes the given effect layer from this scene.
  126184. * @param toRemove defines the effect layer to remove
  126185. * @returns the index of the removed effect layer
  126186. */
  126187. removeEffectLayer(toRemove: EffectLayer): number;
  126188. /**
  126189. * Adds the given effect layer to this scene
  126190. * @param newEffectLayer defines the effect layer to add
  126191. */
  126192. addEffectLayer(newEffectLayer: EffectLayer): void;
  126193. }
  126194. /**
  126195. * Defines the layer scene component responsible to manage any effect layers
  126196. * in a given scene.
  126197. */
  126198. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126199. /**
  126200. * The component name helpfull to identify the component in the list of scene components.
  126201. */
  126202. readonly name: string;
  126203. /**
  126204. * The scene the component belongs to.
  126205. */
  126206. scene: Scene;
  126207. private _engine;
  126208. private _renderEffects;
  126209. private _needStencil;
  126210. private _previousStencilState;
  126211. /**
  126212. * Creates a new instance of the component for the given scene
  126213. * @param scene Defines the scene to register the component in
  126214. */
  126215. constructor(scene: Scene);
  126216. /**
  126217. * Registers the component in a given scene
  126218. */
  126219. register(): void;
  126220. /**
  126221. * Rebuilds the elements related to this component in case of
  126222. * context lost for instance.
  126223. */
  126224. rebuild(): void;
  126225. /**
  126226. * Serializes the component data to the specified json object
  126227. * @param serializationObject The object to serialize to
  126228. */
  126229. serialize(serializationObject: any): void;
  126230. /**
  126231. * Adds all the elements from the container to the scene
  126232. * @param container the container holding the elements
  126233. */
  126234. addFromContainer(container: AbstractScene): void;
  126235. /**
  126236. * Removes all the elements in the container from the scene
  126237. * @param container contains the elements to remove
  126238. * @param dispose if the removed element should be disposed (default: false)
  126239. */
  126240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126241. /**
  126242. * Disposes the component and the associated ressources.
  126243. */
  126244. dispose(): void;
  126245. private _isReadyForMesh;
  126246. private _renderMainTexture;
  126247. private _setStencil;
  126248. private _setStencilBack;
  126249. private _draw;
  126250. private _drawCamera;
  126251. private _drawRenderingGroup;
  126252. }
  126253. }
  126254. declare module BABYLON {
  126255. /** @hidden */
  126256. export var glowMapMergePixelShader: {
  126257. name: string;
  126258. shader: string;
  126259. };
  126260. }
  126261. declare module BABYLON {
  126262. /** @hidden */
  126263. export var glowMapMergeVertexShader: {
  126264. name: string;
  126265. shader: string;
  126266. };
  126267. }
  126268. declare module BABYLON {
  126269. interface AbstractScene {
  126270. /**
  126271. * Return a the first highlight layer of the scene with a given name.
  126272. * @param name The name of the highlight layer to look for.
  126273. * @return The highlight layer if found otherwise null.
  126274. */
  126275. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126276. }
  126277. /**
  126278. * Glow layer options. This helps customizing the behaviour
  126279. * of the glow layer.
  126280. */
  126281. export interface IGlowLayerOptions {
  126282. /**
  126283. * Multiplication factor apply to the canvas size to compute the render target size
  126284. * used to generated the glowing objects (the smaller the faster).
  126285. */
  126286. mainTextureRatio: number;
  126287. /**
  126288. * Enforces a fixed size texture to ensure resize independant blur.
  126289. */
  126290. mainTextureFixedSize?: number;
  126291. /**
  126292. * How big is the kernel of the blur texture.
  126293. */
  126294. blurKernelSize: number;
  126295. /**
  126296. * The camera attached to the layer.
  126297. */
  126298. camera: Nullable<Camera>;
  126299. /**
  126300. * Enable MSAA by chosing the number of samples.
  126301. */
  126302. mainTextureSamples?: number;
  126303. /**
  126304. * The rendering group to draw the layer in.
  126305. */
  126306. renderingGroupId: number;
  126307. }
  126308. /**
  126309. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126310. *
  126311. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126312. *
  126313. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126314. */
  126315. export class GlowLayer extends EffectLayer {
  126316. /**
  126317. * Effect Name of the layer.
  126318. */
  126319. static readonly EffectName: string;
  126320. /**
  126321. * The default blur kernel size used for the glow.
  126322. */
  126323. static DefaultBlurKernelSize: number;
  126324. /**
  126325. * The default texture size ratio used for the glow.
  126326. */
  126327. static DefaultTextureRatio: number;
  126328. /**
  126329. * Sets the kernel size of the blur.
  126330. */
  126331. set blurKernelSize(value: number);
  126332. /**
  126333. * Gets the kernel size of the blur.
  126334. */
  126335. get blurKernelSize(): number;
  126336. /**
  126337. * Sets the glow intensity.
  126338. */
  126339. set intensity(value: number);
  126340. /**
  126341. * Gets the glow intensity.
  126342. */
  126343. get intensity(): number;
  126344. private _options;
  126345. private _intensity;
  126346. private _horizontalBlurPostprocess1;
  126347. private _verticalBlurPostprocess1;
  126348. private _horizontalBlurPostprocess2;
  126349. private _verticalBlurPostprocess2;
  126350. private _blurTexture1;
  126351. private _blurTexture2;
  126352. private _postProcesses1;
  126353. private _postProcesses2;
  126354. private _includedOnlyMeshes;
  126355. private _excludedMeshes;
  126356. private _meshesUsingTheirOwnMaterials;
  126357. /**
  126358. * Callback used to let the user override the color selection on a per mesh basis
  126359. */
  126360. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126361. /**
  126362. * Callback used to let the user override the texture selection on a per mesh basis
  126363. */
  126364. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126365. /**
  126366. * Instantiates a new glow Layer and references it to the scene.
  126367. * @param name The name of the layer
  126368. * @param scene The scene to use the layer in
  126369. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126370. */
  126371. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126372. /**
  126373. * Get the effect name of the layer.
  126374. * @return The effect name
  126375. */
  126376. getEffectName(): string;
  126377. /**
  126378. * Create the merge effect. This is the shader use to blit the information back
  126379. * to the main canvas at the end of the scene rendering.
  126380. */
  126381. protected _createMergeEffect(): Effect;
  126382. /**
  126383. * Creates the render target textures and post processes used in the glow layer.
  126384. */
  126385. protected _createTextureAndPostProcesses(): void;
  126386. /**
  126387. * Checks for the readiness of the element composing the layer.
  126388. * @param subMesh the mesh to check for
  126389. * @param useInstances specify wether or not to use instances to render the mesh
  126390. * @param emissiveTexture the associated emissive texture used to generate the glow
  126391. * @return true if ready otherwise, false
  126392. */
  126393. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126394. /**
  126395. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126396. */
  126397. needStencil(): boolean;
  126398. /**
  126399. * Returns true if the mesh can be rendered, otherwise false.
  126400. * @param mesh The mesh to render
  126401. * @param material The material used on the mesh
  126402. * @returns true if it can be rendered otherwise false
  126403. */
  126404. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126405. /**
  126406. * Implementation specific of rendering the generating effect on the main canvas.
  126407. * @param effect The effect used to render through
  126408. */
  126409. protected _internalRender(effect: Effect): void;
  126410. /**
  126411. * Sets the required values for both the emissive texture and and the main color.
  126412. */
  126413. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126414. /**
  126415. * Returns true if the mesh should render, otherwise false.
  126416. * @param mesh The mesh to render
  126417. * @returns true if it should render otherwise false
  126418. */
  126419. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126420. /**
  126421. * Adds specific effects defines.
  126422. * @param defines The defines to add specifics to.
  126423. */
  126424. protected _addCustomEffectDefines(defines: string[]): void;
  126425. /**
  126426. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126427. * @param mesh The mesh to exclude from the glow layer
  126428. */
  126429. addExcludedMesh(mesh: Mesh): void;
  126430. /**
  126431. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126432. * @param mesh The mesh to remove
  126433. */
  126434. removeExcludedMesh(mesh: Mesh): void;
  126435. /**
  126436. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126437. * @param mesh The mesh to include in the glow layer
  126438. */
  126439. addIncludedOnlyMesh(mesh: Mesh): void;
  126440. /**
  126441. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126442. * @param mesh The mesh to remove
  126443. */
  126444. removeIncludedOnlyMesh(mesh: Mesh): void;
  126445. /**
  126446. * Determine if a given mesh will be used in the glow layer
  126447. * @param mesh The mesh to test
  126448. * @returns true if the mesh will be highlighted by the current glow layer
  126449. */
  126450. hasMesh(mesh: AbstractMesh): boolean;
  126451. /**
  126452. * Defines whether the current material of the mesh should be use to render the effect.
  126453. * @param mesh defines the current mesh to render
  126454. */
  126455. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126456. /**
  126457. * Add a mesh to be rendered through its own material and not with emissive only.
  126458. * @param mesh The mesh for which we need to use its material
  126459. */
  126460. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126461. /**
  126462. * Remove a mesh from being rendered through its own material and not with emissive only.
  126463. * @param mesh The mesh for which we need to not use its material
  126464. */
  126465. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126466. /**
  126467. * Free any resources and references associated to a mesh.
  126468. * Internal use
  126469. * @param mesh The mesh to free.
  126470. * @hidden
  126471. */
  126472. _disposeMesh(mesh: Mesh): void;
  126473. /**
  126474. * Gets the class name of the effect layer
  126475. * @returns the string with the class name of the effect layer
  126476. */
  126477. getClassName(): string;
  126478. /**
  126479. * Serializes this glow layer
  126480. * @returns a serialized glow layer object
  126481. */
  126482. serialize(): any;
  126483. /**
  126484. * Creates a Glow Layer from parsed glow layer data
  126485. * @param parsedGlowLayer defines glow layer data
  126486. * @param scene defines the current scene
  126487. * @param rootUrl defines the root URL containing the glow layer information
  126488. * @returns a parsed Glow Layer
  126489. */
  126490. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126491. }
  126492. }
  126493. declare module BABYLON {
  126494. /** @hidden */
  126495. export var glowBlurPostProcessPixelShader: {
  126496. name: string;
  126497. shader: string;
  126498. };
  126499. }
  126500. declare module BABYLON {
  126501. interface AbstractScene {
  126502. /**
  126503. * Return a the first highlight layer of the scene with a given name.
  126504. * @param name The name of the highlight layer to look for.
  126505. * @return The highlight layer if found otherwise null.
  126506. */
  126507. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126508. }
  126509. /**
  126510. * Highlight layer options. This helps customizing the behaviour
  126511. * of the highlight layer.
  126512. */
  126513. export interface IHighlightLayerOptions {
  126514. /**
  126515. * Multiplication factor apply to the canvas size to compute the render target size
  126516. * used to generated the glowing objects (the smaller the faster).
  126517. */
  126518. mainTextureRatio: number;
  126519. /**
  126520. * Enforces a fixed size texture to ensure resize independant blur.
  126521. */
  126522. mainTextureFixedSize?: number;
  126523. /**
  126524. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126525. * of the picture to blur (the smaller the faster).
  126526. */
  126527. blurTextureSizeRatio: number;
  126528. /**
  126529. * How big in texel of the blur texture is the vertical blur.
  126530. */
  126531. blurVerticalSize: number;
  126532. /**
  126533. * How big in texel of the blur texture is the horizontal blur.
  126534. */
  126535. blurHorizontalSize: number;
  126536. /**
  126537. * Alpha blending mode used to apply the blur. Default is combine.
  126538. */
  126539. alphaBlendingMode: number;
  126540. /**
  126541. * The camera attached to the layer.
  126542. */
  126543. camera: Nullable<Camera>;
  126544. /**
  126545. * Should we display highlight as a solid stroke?
  126546. */
  126547. isStroke?: boolean;
  126548. /**
  126549. * The rendering group to draw the layer in.
  126550. */
  126551. renderingGroupId: number;
  126552. }
  126553. /**
  126554. * The highlight layer Helps adding a glow effect around a mesh.
  126555. *
  126556. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126557. * glowy meshes to your scene.
  126558. *
  126559. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126560. */
  126561. export class HighlightLayer extends EffectLayer {
  126562. name: string;
  126563. /**
  126564. * Effect Name of the highlight layer.
  126565. */
  126566. static readonly EffectName: string;
  126567. /**
  126568. * The neutral color used during the preparation of the glow effect.
  126569. * This is black by default as the blend operation is a blend operation.
  126570. */
  126571. static NeutralColor: Color4;
  126572. /**
  126573. * Stencil value used for glowing meshes.
  126574. */
  126575. static GlowingMeshStencilReference: number;
  126576. /**
  126577. * Stencil value used for the other meshes in the scene.
  126578. */
  126579. static NormalMeshStencilReference: number;
  126580. /**
  126581. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126582. */
  126583. innerGlow: boolean;
  126584. /**
  126585. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126586. */
  126587. outerGlow: boolean;
  126588. /**
  126589. * Specifies the horizontal size of the blur.
  126590. */
  126591. set blurHorizontalSize(value: number);
  126592. /**
  126593. * Specifies the vertical size of the blur.
  126594. */
  126595. set blurVerticalSize(value: number);
  126596. /**
  126597. * Gets the horizontal size of the blur.
  126598. */
  126599. get blurHorizontalSize(): number;
  126600. /**
  126601. * Gets the vertical size of the blur.
  126602. */
  126603. get blurVerticalSize(): number;
  126604. /**
  126605. * An event triggered when the highlight layer is being blurred.
  126606. */
  126607. onBeforeBlurObservable: Observable<HighlightLayer>;
  126608. /**
  126609. * An event triggered when the highlight layer has been blurred.
  126610. */
  126611. onAfterBlurObservable: Observable<HighlightLayer>;
  126612. private _instanceGlowingMeshStencilReference;
  126613. private _options;
  126614. private _downSamplePostprocess;
  126615. private _horizontalBlurPostprocess;
  126616. private _verticalBlurPostprocess;
  126617. private _blurTexture;
  126618. private _meshes;
  126619. private _excludedMeshes;
  126620. /**
  126621. * Instantiates a new highlight Layer and references it to the scene..
  126622. * @param name The name of the layer
  126623. * @param scene The scene to use the layer in
  126624. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126625. */
  126626. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126627. /**
  126628. * Get the effect name of the layer.
  126629. * @return The effect name
  126630. */
  126631. getEffectName(): string;
  126632. /**
  126633. * Create the merge effect. This is the shader use to blit the information back
  126634. * to the main canvas at the end of the scene rendering.
  126635. */
  126636. protected _createMergeEffect(): Effect;
  126637. /**
  126638. * Creates the render target textures and post processes used in the highlight layer.
  126639. */
  126640. protected _createTextureAndPostProcesses(): void;
  126641. /**
  126642. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126643. */
  126644. needStencil(): boolean;
  126645. /**
  126646. * Checks for the readiness of the element composing the layer.
  126647. * @param subMesh the mesh to check for
  126648. * @param useInstances specify wether or not to use instances to render the mesh
  126649. * @param emissiveTexture the associated emissive texture used to generate the glow
  126650. * @return true if ready otherwise, false
  126651. */
  126652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126653. /**
  126654. * Implementation specific of rendering the generating effect on the main canvas.
  126655. * @param effect The effect used to render through
  126656. */
  126657. protected _internalRender(effect: Effect): void;
  126658. /**
  126659. * Returns true if the layer contains information to display, otherwise false.
  126660. */
  126661. shouldRender(): boolean;
  126662. /**
  126663. * Returns true if the mesh should render, otherwise false.
  126664. * @param mesh The mesh to render
  126665. * @returns true if it should render otherwise false
  126666. */
  126667. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126668. /**
  126669. * Sets the required values for both the emissive texture and and the main color.
  126670. */
  126671. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126672. /**
  126673. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126674. * @param mesh The mesh to exclude from the highlight layer
  126675. */
  126676. addExcludedMesh(mesh: Mesh): void;
  126677. /**
  126678. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126679. * @param mesh The mesh to highlight
  126680. */
  126681. removeExcludedMesh(mesh: Mesh): void;
  126682. /**
  126683. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126684. * @param mesh mesh to test
  126685. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126686. */
  126687. hasMesh(mesh: AbstractMesh): boolean;
  126688. /**
  126689. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126690. * @param mesh The mesh to highlight
  126691. * @param color The color of the highlight
  126692. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126693. */
  126694. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126695. /**
  126696. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126697. * @param mesh The mesh to highlight
  126698. */
  126699. removeMesh(mesh: Mesh): void;
  126700. /**
  126701. * Force the stencil to the normal expected value for none glowing parts
  126702. */
  126703. private _defaultStencilReference;
  126704. /**
  126705. * Free any resources and references associated to a mesh.
  126706. * Internal use
  126707. * @param mesh The mesh to free.
  126708. * @hidden
  126709. */
  126710. _disposeMesh(mesh: Mesh): void;
  126711. /**
  126712. * Dispose the highlight layer and free resources.
  126713. */
  126714. dispose(): void;
  126715. /**
  126716. * Gets the class name of the effect layer
  126717. * @returns the string with the class name of the effect layer
  126718. */
  126719. getClassName(): string;
  126720. /**
  126721. * Serializes this Highlight layer
  126722. * @returns a serialized Highlight layer object
  126723. */
  126724. serialize(): any;
  126725. /**
  126726. * Creates a Highlight layer from parsed Highlight layer data
  126727. * @param parsedHightlightLayer defines the Highlight layer data
  126728. * @param scene defines the current scene
  126729. * @param rootUrl defines the root URL containing the Highlight layer information
  126730. * @returns a parsed Highlight layer
  126731. */
  126732. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126733. }
  126734. }
  126735. declare module BABYLON {
  126736. interface AbstractScene {
  126737. /**
  126738. * The list of layers (background and foreground) of the scene
  126739. */
  126740. layers: Array<Layer>;
  126741. }
  126742. /**
  126743. * Defines the layer scene component responsible to manage any layers
  126744. * in a given scene.
  126745. */
  126746. export class LayerSceneComponent implements ISceneComponent {
  126747. /**
  126748. * The component name helpfull to identify the component in the list of scene components.
  126749. */
  126750. readonly name: string;
  126751. /**
  126752. * The scene the component belongs to.
  126753. */
  126754. scene: Scene;
  126755. private _engine;
  126756. /**
  126757. * Creates a new instance of the component for the given scene
  126758. * @param scene Defines the scene to register the component in
  126759. */
  126760. constructor(scene: Scene);
  126761. /**
  126762. * Registers the component in a given scene
  126763. */
  126764. register(): void;
  126765. /**
  126766. * Rebuilds the elements related to this component in case of
  126767. * context lost for instance.
  126768. */
  126769. rebuild(): void;
  126770. /**
  126771. * Disposes the component and the associated ressources.
  126772. */
  126773. dispose(): void;
  126774. private _draw;
  126775. private _drawCameraPredicate;
  126776. private _drawCameraBackground;
  126777. private _drawCameraForeground;
  126778. private _drawRenderTargetPredicate;
  126779. private _drawRenderTargetBackground;
  126780. private _drawRenderTargetForeground;
  126781. /**
  126782. * Adds all the elements from the container to the scene
  126783. * @param container the container holding the elements
  126784. */
  126785. addFromContainer(container: AbstractScene): void;
  126786. /**
  126787. * Removes all the elements in the container from the scene
  126788. * @param container contains the elements to remove
  126789. * @param dispose if the removed element should be disposed (default: false)
  126790. */
  126791. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126792. }
  126793. }
  126794. declare module BABYLON {
  126795. /** @hidden */
  126796. export var layerPixelShader: {
  126797. name: string;
  126798. shader: string;
  126799. };
  126800. }
  126801. declare module BABYLON {
  126802. /** @hidden */
  126803. export var layerVertexShader: {
  126804. name: string;
  126805. shader: string;
  126806. };
  126807. }
  126808. declare module BABYLON {
  126809. /**
  126810. * This represents a full screen 2d layer.
  126811. * This can be useful to display a picture in the background of your scene for instance.
  126812. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126813. */
  126814. export class Layer {
  126815. /**
  126816. * Define the name of the layer.
  126817. */
  126818. name: string;
  126819. /**
  126820. * Define the texture the layer should display.
  126821. */
  126822. texture: Nullable<Texture>;
  126823. /**
  126824. * Is the layer in background or foreground.
  126825. */
  126826. isBackground: boolean;
  126827. /**
  126828. * Define the color of the layer (instead of texture).
  126829. */
  126830. color: Color4;
  126831. /**
  126832. * Define the scale of the layer in order to zoom in out of the texture.
  126833. */
  126834. scale: Vector2;
  126835. /**
  126836. * Define an offset for the layer in order to shift the texture.
  126837. */
  126838. offset: Vector2;
  126839. /**
  126840. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126841. */
  126842. alphaBlendingMode: number;
  126843. /**
  126844. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126845. * Alpha test will not mix with the background color in case of transparency.
  126846. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126847. */
  126848. alphaTest: boolean;
  126849. /**
  126850. * Define a mask to restrict the layer to only some of the scene cameras.
  126851. */
  126852. layerMask: number;
  126853. /**
  126854. * Define the list of render target the layer is visible into.
  126855. */
  126856. renderTargetTextures: RenderTargetTexture[];
  126857. /**
  126858. * Define if the layer is only used in renderTarget or if it also
  126859. * renders in the main frame buffer of the canvas.
  126860. */
  126861. renderOnlyInRenderTargetTextures: boolean;
  126862. private _scene;
  126863. private _vertexBuffers;
  126864. private _indexBuffer;
  126865. private _effect;
  126866. private _previousDefines;
  126867. /**
  126868. * An event triggered when the layer is disposed.
  126869. */
  126870. onDisposeObservable: Observable<Layer>;
  126871. private _onDisposeObserver;
  126872. /**
  126873. * Back compatibility with callback before the onDisposeObservable existed.
  126874. * The set callback will be triggered when the layer has been disposed.
  126875. */
  126876. set onDispose(callback: () => void);
  126877. /**
  126878. * An event triggered before rendering the scene
  126879. */
  126880. onBeforeRenderObservable: Observable<Layer>;
  126881. private _onBeforeRenderObserver;
  126882. /**
  126883. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126884. * The set callback will be triggered just before rendering the layer.
  126885. */
  126886. set onBeforeRender(callback: () => void);
  126887. /**
  126888. * An event triggered after rendering the scene
  126889. */
  126890. onAfterRenderObservable: Observable<Layer>;
  126891. private _onAfterRenderObserver;
  126892. /**
  126893. * Back compatibility with callback before the onAfterRenderObservable existed.
  126894. * The set callback will be triggered just after rendering the layer.
  126895. */
  126896. set onAfterRender(callback: () => void);
  126897. /**
  126898. * Instantiates a new layer.
  126899. * This represents a full screen 2d layer.
  126900. * This can be useful to display a picture in the background of your scene for instance.
  126901. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126902. * @param name Define the name of the layer in the scene
  126903. * @param imgUrl Define the url of the texture to display in the layer
  126904. * @param scene Define the scene the layer belongs to
  126905. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126906. * @param color Defines a color for the layer
  126907. */
  126908. constructor(
  126909. /**
  126910. * Define the name of the layer.
  126911. */
  126912. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126913. private _createIndexBuffer;
  126914. /** @hidden */
  126915. _rebuild(): void;
  126916. /**
  126917. * Renders the layer in the scene.
  126918. */
  126919. render(): void;
  126920. /**
  126921. * Disposes and releases the associated ressources.
  126922. */
  126923. dispose(): void;
  126924. }
  126925. }
  126926. declare module BABYLON {
  126927. /** @hidden */
  126928. export var lensFlarePixelShader: {
  126929. name: string;
  126930. shader: string;
  126931. };
  126932. }
  126933. declare module BABYLON {
  126934. /** @hidden */
  126935. export var lensFlareVertexShader: {
  126936. name: string;
  126937. shader: string;
  126938. };
  126939. }
  126940. declare module BABYLON {
  126941. /**
  126942. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126943. * It is usually composed of several `lensFlare`.
  126944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126945. */
  126946. export class LensFlareSystem {
  126947. /**
  126948. * Define the name of the lens flare system
  126949. */
  126950. name: string;
  126951. /**
  126952. * List of lens flares used in this system.
  126953. */
  126954. lensFlares: LensFlare[];
  126955. /**
  126956. * Define a limit from the border the lens flare can be visible.
  126957. */
  126958. borderLimit: number;
  126959. /**
  126960. * Define a viewport border we do not want to see the lens flare in.
  126961. */
  126962. viewportBorder: number;
  126963. /**
  126964. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126965. */
  126966. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126967. /**
  126968. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126969. */
  126970. layerMask: number;
  126971. /**
  126972. * Define the id of the lens flare system in the scene.
  126973. * (equal to name by default)
  126974. */
  126975. id: string;
  126976. private _scene;
  126977. private _emitter;
  126978. private _vertexBuffers;
  126979. private _indexBuffer;
  126980. private _effect;
  126981. private _positionX;
  126982. private _positionY;
  126983. private _isEnabled;
  126984. /** @hidden */
  126985. static _SceneComponentInitialization: (scene: Scene) => void;
  126986. /**
  126987. * Instantiates a lens flare system.
  126988. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126989. * It is usually composed of several `lensFlare`.
  126990. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126991. * @param name Define the name of the lens flare system in the scene
  126992. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126993. * @param scene Define the scene the lens flare system belongs to
  126994. */
  126995. constructor(
  126996. /**
  126997. * Define the name of the lens flare system
  126998. */
  126999. name: string, emitter: any, scene: Scene);
  127000. /**
  127001. * Define if the lens flare system is enabled.
  127002. */
  127003. get isEnabled(): boolean;
  127004. set isEnabled(value: boolean);
  127005. /**
  127006. * Get the scene the effects belongs to.
  127007. * @returns the scene holding the lens flare system
  127008. */
  127009. getScene(): Scene;
  127010. /**
  127011. * Get the emitter of the lens flare system.
  127012. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127013. * @returns the emitter of the lens flare system
  127014. */
  127015. getEmitter(): any;
  127016. /**
  127017. * Set the emitter of the lens flare system.
  127018. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127019. * @param newEmitter Define the new emitter of the system
  127020. */
  127021. setEmitter(newEmitter: any): void;
  127022. /**
  127023. * Get the lens flare system emitter position.
  127024. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127025. * @returns the position
  127026. */
  127027. getEmitterPosition(): Vector3;
  127028. /**
  127029. * @hidden
  127030. */
  127031. computeEffectivePosition(globalViewport: Viewport): boolean;
  127032. /** @hidden */
  127033. _isVisible(): boolean;
  127034. /**
  127035. * @hidden
  127036. */
  127037. render(): boolean;
  127038. /**
  127039. * Dispose and release the lens flare with its associated resources.
  127040. */
  127041. dispose(): void;
  127042. /**
  127043. * Parse a lens flare system from a JSON repressentation
  127044. * @param parsedLensFlareSystem Define the JSON to parse
  127045. * @param scene Define the scene the parsed system should be instantiated in
  127046. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127047. * @returns the parsed system
  127048. */
  127049. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127050. /**
  127051. * Serialize the current Lens Flare System into a JSON representation.
  127052. * @returns the serialized JSON
  127053. */
  127054. serialize(): any;
  127055. }
  127056. }
  127057. declare module BABYLON {
  127058. /**
  127059. * This represents one of the lens effect in a `lensFlareSystem`.
  127060. * It controls one of the indiviual texture used in the effect.
  127061. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127062. */
  127063. export class LensFlare {
  127064. /**
  127065. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127066. */
  127067. size: number;
  127068. /**
  127069. * 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.
  127070. */
  127071. position: number;
  127072. /**
  127073. * Define the lens color.
  127074. */
  127075. color: Color3;
  127076. /**
  127077. * Define the lens texture.
  127078. */
  127079. texture: Nullable<Texture>;
  127080. /**
  127081. * Define the alpha mode to render this particular lens.
  127082. */
  127083. alphaMode: number;
  127084. private _system;
  127085. /**
  127086. * Creates a new Lens Flare.
  127087. * This represents one of the lens effect in a `lensFlareSystem`.
  127088. * It controls one of the indiviual texture used in the effect.
  127089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127090. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127091. * @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.
  127092. * @param color Define the lens color
  127093. * @param imgUrl Define the lens texture url
  127094. * @param system Define the `lensFlareSystem` this flare is part of
  127095. * @returns The newly created Lens Flare
  127096. */
  127097. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127098. /**
  127099. * Instantiates a new Lens Flare.
  127100. * This represents one of the lens effect in a `lensFlareSystem`.
  127101. * It controls one of the indiviual texture used in the effect.
  127102. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127103. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127104. * @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.
  127105. * @param color Define the lens color
  127106. * @param imgUrl Define the lens texture url
  127107. * @param system Define the `lensFlareSystem` this flare is part of
  127108. */
  127109. constructor(
  127110. /**
  127111. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127112. */
  127113. size: number,
  127114. /**
  127115. * 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.
  127116. */
  127117. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127118. /**
  127119. * Dispose and release the lens flare with its associated resources.
  127120. */
  127121. dispose(): void;
  127122. }
  127123. }
  127124. declare module BABYLON {
  127125. interface AbstractScene {
  127126. /**
  127127. * The list of lens flare system added to the scene
  127128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127129. */
  127130. lensFlareSystems: Array<LensFlareSystem>;
  127131. /**
  127132. * Removes the given lens flare system from this scene.
  127133. * @param toRemove The lens flare system to remove
  127134. * @returns The index of the removed lens flare system
  127135. */
  127136. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127137. /**
  127138. * Adds the given lens flare system to this scene
  127139. * @param newLensFlareSystem The lens flare system to add
  127140. */
  127141. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127142. /**
  127143. * Gets a lens flare system using its name
  127144. * @param name defines the name to look for
  127145. * @returns the lens flare system or null if not found
  127146. */
  127147. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127148. /**
  127149. * Gets a lens flare system using its id
  127150. * @param id defines the id to look for
  127151. * @returns the lens flare system or null if not found
  127152. */
  127153. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127154. }
  127155. /**
  127156. * Defines the lens flare scene component responsible to manage any lens flares
  127157. * in a given scene.
  127158. */
  127159. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127160. /**
  127161. * The component name helpfull to identify the component in the list of scene components.
  127162. */
  127163. readonly name: string;
  127164. /**
  127165. * The scene the component belongs to.
  127166. */
  127167. scene: Scene;
  127168. /**
  127169. * Creates a new instance of the component for the given scene
  127170. * @param scene Defines the scene to register the component in
  127171. */
  127172. constructor(scene: Scene);
  127173. /**
  127174. * Registers the component in a given scene
  127175. */
  127176. register(): void;
  127177. /**
  127178. * Rebuilds the elements related to this component in case of
  127179. * context lost for instance.
  127180. */
  127181. rebuild(): void;
  127182. /**
  127183. * Adds all the elements from the container to the scene
  127184. * @param container the container holding the elements
  127185. */
  127186. addFromContainer(container: AbstractScene): void;
  127187. /**
  127188. * Removes all the elements in the container from the scene
  127189. * @param container contains the elements to remove
  127190. * @param dispose if the removed element should be disposed (default: false)
  127191. */
  127192. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127193. /**
  127194. * Serializes the component data to the specified json object
  127195. * @param serializationObject The object to serialize to
  127196. */
  127197. serialize(serializationObject: any): void;
  127198. /**
  127199. * Disposes the component and the associated ressources.
  127200. */
  127201. dispose(): void;
  127202. private _draw;
  127203. }
  127204. }
  127205. declare module BABYLON {
  127206. /** @hidden */
  127207. export var depthPixelShader: {
  127208. name: string;
  127209. shader: string;
  127210. };
  127211. }
  127212. declare module BABYLON {
  127213. /** @hidden */
  127214. export var depthVertexShader: {
  127215. name: string;
  127216. shader: string;
  127217. };
  127218. }
  127219. declare module BABYLON {
  127220. /**
  127221. * This represents a depth renderer in Babylon.
  127222. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127223. */
  127224. export class DepthRenderer {
  127225. private _scene;
  127226. private _depthMap;
  127227. private _effect;
  127228. private readonly _storeNonLinearDepth;
  127229. private readonly _clearColor;
  127230. /** Get if the depth renderer is using packed depth or not */
  127231. readonly isPacked: boolean;
  127232. private _cachedDefines;
  127233. private _camera;
  127234. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127235. enabled: boolean;
  127236. /**
  127237. * Specifiess that the depth renderer will only be used within
  127238. * the camera it is created for.
  127239. * This can help forcing its rendering during the camera processing.
  127240. */
  127241. useOnlyInActiveCamera: boolean;
  127242. /** @hidden */
  127243. static _SceneComponentInitialization: (scene: Scene) => void;
  127244. /**
  127245. * Instantiates a depth renderer
  127246. * @param scene The scene the renderer belongs to
  127247. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127248. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127249. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127250. */
  127251. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127252. /**
  127253. * Creates the depth rendering effect and checks if the effect is ready.
  127254. * @param subMesh The submesh to be used to render the depth map of
  127255. * @param useInstances If multiple world instances should be used
  127256. * @returns if the depth renderer is ready to render the depth map
  127257. */
  127258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127259. /**
  127260. * Gets the texture which the depth map will be written to.
  127261. * @returns The depth map texture
  127262. */
  127263. getDepthMap(): RenderTargetTexture;
  127264. /**
  127265. * Disposes of the depth renderer.
  127266. */
  127267. dispose(): void;
  127268. }
  127269. }
  127270. declare module BABYLON {
  127271. /** @hidden */
  127272. export var minmaxReduxPixelShader: {
  127273. name: string;
  127274. shader: string;
  127275. };
  127276. }
  127277. declare module BABYLON {
  127278. /**
  127279. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127280. * and maximum values from all values of the texture.
  127281. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127282. * The source values are read from the red channel of the texture.
  127283. */
  127284. export class MinMaxReducer {
  127285. /**
  127286. * Observable triggered when the computation has been performed
  127287. */
  127288. onAfterReductionPerformed: Observable<{
  127289. min: number;
  127290. max: number;
  127291. }>;
  127292. protected _camera: Camera;
  127293. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127294. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127295. protected _postProcessManager: PostProcessManager;
  127296. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127297. protected _forceFullscreenViewport: boolean;
  127298. /**
  127299. * Creates a min/max reducer
  127300. * @param camera The camera to use for the post processes
  127301. */
  127302. constructor(camera: Camera);
  127303. /**
  127304. * Gets the texture used to read the values from.
  127305. */
  127306. get sourceTexture(): Nullable<RenderTargetTexture>;
  127307. /**
  127308. * Sets the source texture to read the values from.
  127309. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127310. * because in such textures '1' value must not be taken into account to compute the maximum
  127311. * as this value is used to clear the texture.
  127312. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127313. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127314. * @param depthRedux Indicates if the texture is a depth texture or not
  127315. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127316. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127317. */
  127318. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127319. /**
  127320. * Defines the refresh rate of the computation.
  127321. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127322. */
  127323. get refreshRate(): number;
  127324. set refreshRate(value: number);
  127325. protected _activated: boolean;
  127326. /**
  127327. * Gets the activation status of the reducer
  127328. */
  127329. get activated(): boolean;
  127330. /**
  127331. * Activates the reduction computation.
  127332. * When activated, the observers registered in onAfterReductionPerformed are
  127333. * called after the compuation is performed
  127334. */
  127335. activate(): void;
  127336. /**
  127337. * Deactivates the reduction computation.
  127338. */
  127339. deactivate(): void;
  127340. /**
  127341. * Disposes the min/max reducer
  127342. * @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.
  127343. */
  127344. dispose(disposeAll?: boolean): void;
  127345. }
  127346. }
  127347. declare module BABYLON {
  127348. /**
  127349. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127350. */
  127351. export class DepthReducer extends MinMaxReducer {
  127352. private _depthRenderer;
  127353. private _depthRendererId;
  127354. /**
  127355. * Gets the depth renderer used for the computation.
  127356. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127357. */
  127358. get depthRenderer(): Nullable<DepthRenderer>;
  127359. /**
  127360. * Creates a depth reducer
  127361. * @param camera The camera used to render the depth texture
  127362. */
  127363. constructor(camera: Camera);
  127364. /**
  127365. * Sets the depth renderer to use to generate the depth map
  127366. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127367. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127368. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127369. */
  127370. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127371. /** @hidden */
  127372. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127373. /**
  127374. * Activates the reduction computation.
  127375. * When activated, the observers registered in onAfterReductionPerformed are
  127376. * called after the compuation is performed
  127377. */
  127378. activate(): void;
  127379. /**
  127380. * Deactivates the reduction computation.
  127381. */
  127382. deactivate(): void;
  127383. /**
  127384. * Disposes the depth reducer
  127385. * @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.
  127386. */
  127387. dispose(disposeAll?: boolean): void;
  127388. }
  127389. }
  127390. declare module BABYLON {
  127391. /**
  127392. * A CSM implementation allowing casting shadows on large scenes.
  127393. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127394. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127395. */
  127396. export class CascadedShadowGenerator extends ShadowGenerator {
  127397. private static readonly frustumCornersNDCSpace;
  127398. /**
  127399. * Name of the CSM class
  127400. */
  127401. static CLASSNAME: string;
  127402. /**
  127403. * Defines the default number of cascades used by the CSM.
  127404. */
  127405. static readonly DEFAULT_CASCADES_COUNT: number;
  127406. /**
  127407. * Defines the minimum number of cascades used by the CSM.
  127408. */
  127409. static readonly MIN_CASCADES_COUNT: number;
  127410. /**
  127411. * Defines the maximum number of cascades used by the CSM.
  127412. */
  127413. static readonly MAX_CASCADES_COUNT: number;
  127414. protected _validateFilter(filter: number): number;
  127415. /**
  127416. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127417. */
  127418. penumbraDarkness: number;
  127419. private _numCascades;
  127420. /**
  127421. * Gets or set the number of cascades used by the CSM.
  127422. */
  127423. get numCascades(): number;
  127424. set numCascades(value: number);
  127425. /**
  127426. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127427. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127428. */
  127429. stabilizeCascades: boolean;
  127430. private _freezeShadowCastersBoundingInfo;
  127431. private _freezeShadowCastersBoundingInfoObservable;
  127432. /**
  127433. * Enables or disables the shadow casters bounding info computation.
  127434. * If your shadow casters don't move, you can disable this feature.
  127435. * If it is enabled, the bounding box computation is done every frame.
  127436. */
  127437. get freezeShadowCastersBoundingInfo(): boolean;
  127438. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127439. private _scbiMin;
  127440. private _scbiMax;
  127441. protected _computeShadowCastersBoundingInfo(): void;
  127442. protected _shadowCastersBoundingInfo: BoundingInfo;
  127443. /**
  127444. * Gets or sets the shadow casters bounding info.
  127445. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127446. * so that the system won't overwrite the bounds you provide
  127447. */
  127448. get shadowCastersBoundingInfo(): BoundingInfo;
  127449. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127450. protected _breaksAreDirty: boolean;
  127451. protected _minDistance: number;
  127452. protected _maxDistance: number;
  127453. /**
  127454. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127455. *
  127456. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127457. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127458. * @param min minimal distance for the breaks (default to 0.)
  127459. * @param max maximal distance for the breaks (default to 1.)
  127460. */
  127461. setMinMaxDistance(min: number, max: number): void;
  127462. /** Gets the minimal distance used in the cascade break computation */
  127463. get minDistance(): number;
  127464. /** Gets the maximal distance used in the cascade break computation */
  127465. get maxDistance(): number;
  127466. /**
  127467. * Gets the class name of that object
  127468. * @returns "CascadedShadowGenerator"
  127469. */
  127470. getClassName(): string;
  127471. private _cascadeMinExtents;
  127472. private _cascadeMaxExtents;
  127473. /**
  127474. * Gets a cascade minimum extents
  127475. * @param cascadeIndex index of the cascade
  127476. * @returns the minimum cascade extents
  127477. */
  127478. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127479. /**
  127480. * Gets a cascade maximum extents
  127481. * @param cascadeIndex index of the cascade
  127482. * @returns the maximum cascade extents
  127483. */
  127484. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127485. private _cascades;
  127486. private _currentLayer;
  127487. private _viewSpaceFrustumsZ;
  127488. private _viewMatrices;
  127489. private _projectionMatrices;
  127490. private _transformMatrices;
  127491. private _transformMatricesAsArray;
  127492. private _frustumLengths;
  127493. private _lightSizeUVCorrection;
  127494. private _depthCorrection;
  127495. private _frustumCornersWorldSpace;
  127496. private _frustumCenter;
  127497. private _shadowCameraPos;
  127498. private _shadowMaxZ;
  127499. /**
  127500. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127501. * It defaults to camera.maxZ
  127502. */
  127503. get shadowMaxZ(): number;
  127504. /**
  127505. * Sets the shadow max z distance.
  127506. */
  127507. set shadowMaxZ(value: number);
  127508. protected _debug: boolean;
  127509. /**
  127510. * Gets or sets the debug flag.
  127511. * When enabled, the cascades are materialized by different colors on the screen.
  127512. */
  127513. get debug(): boolean;
  127514. set debug(dbg: boolean);
  127515. private _depthClamp;
  127516. /**
  127517. * Gets or sets the depth clamping value.
  127518. *
  127519. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127520. * to account for the shadow casters far away.
  127521. *
  127522. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127523. */
  127524. get depthClamp(): boolean;
  127525. set depthClamp(value: boolean);
  127526. private _cascadeBlendPercentage;
  127527. /**
  127528. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127529. * It defaults to 0.1 (10% blending).
  127530. */
  127531. get cascadeBlendPercentage(): number;
  127532. set cascadeBlendPercentage(value: number);
  127533. private _lambda;
  127534. /**
  127535. * Gets or set the lambda parameter.
  127536. * This parameter is used to split the camera frustum and create the cascades.
  127537. * 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.
  127538. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127539. */
  127540. get lambda(): number;
  127541. set lambda(value: number);
  127542. /**
  127543. * Gets the view matrix corresponding to a given cascade
  127544. * @param cascadeNum cascade to retrieve the view matrix from
  127545. * @returns the cascade view matrix
  127546. */
  127547. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127548. /**
  127549. * Gets the projection matrix corresponding to a given cascade
  127550. * @param cascadeNum cascade to retrieve the projection matrix from
  127551. * @returns the cascade projection matrix
  127552. */
  127553. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127554. /**
  127555. * Gets the transformation matrix corresponding to a given cascade
  127556. * @param cascadeNum cascade to retrieve the transformation matrix from
  127557. * @returns the cascade transformation matrix
  127558. */
  127559. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127560. private _depthRenderer;
  127561. /**
  127562. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127563. *
  127564. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127565. *
  127566. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127567. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127568. * @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
  127569. */
  127570. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127571. private _depthReducer;
  127572. private _autoCalcDepthBounds;
  127573. /**
  127574. * Gets or sets the autoCalcDepthBounds property.
  127575. *
  127576. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127577. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127578. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127579. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127580. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127581. */
  127582. get autoCalcDepthBounds(): boolean;
  127583. set autoCalcDepthBounds(value: boolean);
  127584. /**
  127585. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127586. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127587. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127588. * for setting the refresh rate on the renderer yourself!
  127589. */
  127590. get autoCalcDepthBoundsRefreshRate(): number;
  127591. set autoCalcDepthBoundsRefreshRate(value: number);
  127592. /**
  127593. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127594. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127595. * you change the camera near/far planes!
  127596. */
  127597. splitFrustum(): void;
  127598. private _splitFrustum;
  127599. private _computeMatrices;
  127600. private _computeFrustumInWorldSpace;
  127601. private _computeCascadeFrustum;
  127602. /** @hidden */
  127603. static _SceneComponentInitialization: (scene: Scene) => void;
  127604. /**
  127605. * Creates a Cascaded Shadow Generator object.
  127606. * A ShadowGenerator is the required tool to use the shadows.
  127607. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127608. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127609. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127610. * @param light The directional light object generating the shadows.
  127611. * @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.
  127612. */
  127613. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127614. protected _initializeGenerator(): void;
  127615. protected _createTargetRenderTexture(): void;
  127616. protected _initializeShadowMap(): void;
  127617. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127618. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127619. /**
  127620. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127621. * @param defines Defines of the material we want to update
  127622. * @param lightIndex Index of the light in the enabled light list of the material
  127623. */
  127624. prepareDefines(defines: any, lightIndex: number): void;
  127625. /**
  127626. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127627. * defined in the generator but impacting the effect).
  127628. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127629. * @param effect The effect we are binfing the information for
  127630. */
  127631. bindShadowLight(lightIndex: string, effect: Effect): void;
  127632. /**
  127633. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127634. * (eq to view projection * shadow projection matrices)
  127635. * @returns The transform matrix used to create the shadow map
  127636. */
  127637. getTransformMatrix(): Matrix;
  127638. /**
  127639. * Disposes the ShadowGenerator.
  127640. * Returns nothing.
  127641. */
  127642. dispose(): void;
  127643. /**
  127644. * Serializes the shadow generator setup to a json object.
  127645. * @returns The serialized JSON object
  127646. */
  127647. serialize(): any;
  127648. /**
  127649. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127650. * @param parsedShadowGenerator The JSON object to parse
  127651. * @param scene The scene to create the shadow map for
  127652. * @returns The parsed shadow generator
  127653. */
  127654. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127655. }
  127656. }
  127657. declare module BABYLON {
  127658. /**
  127659. * Defines the shadow generator component responsible to manage any shadow generators
  127660. * in a given scene.
  127661. */
  127662. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127663. /**
  127664. * The component name helpfull to identify the component in the list of scene components.
  127665. */
  127666. readonly name: string;
  127667. /**
  127668. * The scene the component belongs to.
  127669. */
  127670. scene: Scene;
  127671. /**
  127672. * Creates a new instance of the component for the given scene
  127673. * @param scene Defines the scene to register the component in
  127674. */
  127675. constructor(scene: Scene);
  127676. /**
  127677. * Registers the component in a given scene
  127678. */
  127679. register(): void;
  127680. /**
  127681. * Rebuilds the elements related to this component in case of
  127682. * context lost for instance.
  127683. */
  127684. rebuild(): void;
  127685. /**
  127686. * Serializes the component data to the specified json object
  127687. * @param serializationObject The object to serialize to
  127688. */
  127689. serialize(serializationObject: any): void;
  127690. /**
  127691. * Adds all the elements from the container to the scene
  127692. * @param container the container holding the elements
  127693. */
  127694. addFromContainer(container: AbstractScene): void;
  127695. /**
  127696. * Removes all the elements in the container from the scene
  127697. * @param container contains the elements to remove
  127698. * @param dispose if the removed element should be disposed (default: false)
  127699. */
  127700. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127701. /**
  127702. * Rebuilds the elements related to this component in case of
  127703. * context lost for instance.
  127704. */
  127705. dispose(): void;
  127706. private _gatherRenderTargets;
  127707. }
  127708. }
  127709. declare module BABYLON {
  127710. /**
  127711. * A point light is a light defined by an unique point in world space.
  127712. * The light is emitted in every direction from this point.
  127713. * A good example of a point light is a standard light bulb.
  127714. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127715. */
  127716. export class PointLight extends ShadowLight {
  127717. private _shadowAngle;
  127718. /**
  127719. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127720. * This specifies what angle the shadow will use to be created.
  127721. *
  127722. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127723. */
  127724. get shadowAngle(): number;
  127725. /**
  127726. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127727. * This specifies what angle the shadow will use to be created.
  127728. *
  127729. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127730. */
  127731. set shadowAngle(value: number);
  127732. /**
  127733. * Gets the direction if it has been set.
  127734. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127735. */
  127736. get direction(): Vector3;
  127737. /**
  127738. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127739. */
  127740. set direction(value: Vector3);
  127741. /**
  127742. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127743. * A PointLight emits the light in every direction.
  127744. * It can cast shadows.
  127745. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127746. * ```javascript
  127747. * var pointLight = new PointLight("pl", camera.position, scene);
  127748. * ```
  127749. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127750. * @param name The light friendly name
  127751. * @param position The position of the point light in the scene
  127752. * @param scene The scene the lights belongs to
  127753. */
  127754. constructor(name: string, position: Vector3, scene: Scene);
  127755. /**
  127756. * Returns the string "PointLight"
  127757. * @returns the class name
  127758. */
  127759. getClassName(): string;
  127760. /**
  127761. * Returns the integer 0.
  127762. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127763. */
  127764. getTypeID(): number;
  127765. /**
  127766. * Specifies wether or not the shadowmap should be a cube texture.
  127767. * @returns true if the shadowmap needs to be a cube texture.
  127768. */
  127769. needCube(): boolean;
  127770. /**
  127771. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127772. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127773. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127774. */
  127775. getShadowDirection(faceIndex?: number): Vector3;
  127776. /**
  127777. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127778. * - fov = PI / 2
  127779. * - aspect ratio : 1.0
  127780. * - z-near and far equal to the active camera minZ and maxZ.
  127781. * Returns the PointLight.
  127782. */
  127783. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127784. protected _buildUniformLayout(): void;
  127785. /**
  127786. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127787. * @param effect The effect to update
  127788. * @param lightIndex The index of the light in the effect to update
  127789. * @returns The point light
  127790. */
  127791. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127792. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127793. /**
  127794. * Prepares the list of defines specific to the light type.
  127795. * @param defines the list of defines
  127796. * @param lightIndex defines the index of the light for the effect
  127797. */
  127798. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127799. }
  127800. }
  127801. declare module BABYLON {
  127802. /**
  127803. * Header information of HDR texture files.
  127804. */
  127805. export interface HDRInfo {
  127806. /**
  127807. * The height of the texture in pixels.
  127808. */
  127809. height: number;
  127810. /**
  127811. * The width of the texture in pixels.
  127812. */
  127813. width: number;
  127814. /**
  127815. * The index of the beginning of the data in the binary file.
  127816. */
  127817. dataPosition: number;
  127818. }
  127819. /**
  127820. * This groups tools to convert HDR texture to native colors array.
  127821. */
  127822. export class HDRTools {
  127823. private static Ldexp;
  127824. private static Rgbe2float;
  127825. private static readStringLine;
  127826. /**
  127827. * Reads header information from an RGBE texture stored in a native array.
  127828. * More information on this format are available here:
  127829. * https://en.wikipedia.org/wiki/RGBE_image_format
  127830. *
  127831. * @param uint8array The binary file stored in native array.
  127832. * @return The header information.
  127833. */
  127834. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127835. /**
  127836. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127837. * This RGBE texture needs to store the information as a panorama.
  127838. *
  127839. * More information on this format are available here:
  127840. * https://en.wikipedia.org/wiki/RGBE_image_format
  127841. *
  127842. * @param buffer The binary file stored in an array buffer.
  127843. * @param size The expected size of the extracted cubemap.
  127844. * @return The Cube Map information.
  127845. */
  127846. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127847. /**
  127848. * Returns the pixels data extracted from an RGBE texture.
  127849. * This pixels will be stored left to right up to down in the R G B order in one array.
  127850. *
  127851. * More information on this format are available here:
  127852. * https://en.wikipedia.org/wiki/RGBE_image_format
  127853. *
  127854. * @param uint8array The binary file stored in an array buffer.
  127855. * @param hdrInfo The header information of the file.
  127856. * @return The pixels data in RGB right to left up to down order.
  127857. */
  127858. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127859. private static RGBE_ReadPixels_RLE;
  127860. }
  127861. }
  127862. declare module BABYLON {
  127863. /**
  127864. * This represents a texture coming from an HDR input.
  127865. *
  127866. * The only supported format is currently panorama picture stored in RGBE format.
  127867. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127868. */
  127869. export class HDRCubeTexture extends BaseTexture {
  127870. private static _facesMapping;
  127871. private _generateHarmonics;
  127872. private _noMipmap;
  127873. private _textureMatrix;
  127874. private _size;
  127875. private _onLoad;
  127876. private _onError;
  127877. /**
  127878. * The texture URL.
  127879. */
  127880. url: string;
  127881. /**
  127882. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127883. */
  127884. coordinatesMode: number;
  127885. protected _isBlocking: boolean;
  127886. /**
  127887. * Sets wether or not the texture is blocking during loading.
  127888. */
  127889. set isBlocking(value: boolean);
  127890. /**
  127891. * Gets wether or not the texture is blocking during loading.
  127892. */
  127893. get isBlocking(): boolean;
  127894. protected _rotationY: number;
  127895. /**
  127896. * Sets texture matrix rotation angle around Y axis in radians.
  127897. */
  127898. set rotationY(value: number);
  127899. /**
  127900. * Gets texture matrix rotation angle around Y axis radians.
  127901. */
  127902. get rotationY(): number;
  127903. /**
  127904. * Gets or sets the center of the bounding box associated with the cube texture
  127905. * It must define where the camera used to render the texture was set
  127906. */
  127907. boundingBoxPosition: Vector3;
  127908. private _boundingBoxSize;
  127909. /**
  127910. * Gets or sets the size of the bounding box associated with the cube texture
  127911. * When defined, the cubemap will switch to local mode
  127912. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127913. * @example https://www.babylonjs-playground.com/#RNASML
  127914. */
  127915. set boundingBoxSize(value: Vector3);
  127916. get boundingBoxSize(): Vector3;
  127917. /**
  127918. * Instantiates an HDRTexture from the following parameters.
  127919. *
  127920. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127921. * @param scene The scene the texture will be used in
  127922. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127923. * @param noMipmap Forces to not generate the mipmap if true
  127924. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127925. * @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)
  127926. * @param reserved Reserved flag for internal use.
  127927. */
  127928. 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>);
  127929. /**
  127930. * Get the current class name of the texture useful for serialization or dynamic coding.
  127931. * @returns "HDRCubeTexture"
  127932. */
  127933. getClassName(): string;
  127934. /**
  127935. * Occurs when the file is raw .hdr file.
  127936. */
  127937. private loadTexture;
  127938. clone(): HDRCubeTexture;
  127939. delayLoad(): void;
  127940. /**
  127941. * Get the texture reflection matrix used to rotate/transform the reflection.
  127942. * @returns the reflection matrix
  127943. */
  127944. getReflectionTextureMatrix(): Matrix;
  127945. /**
  127946. * Set the texture reflection matrix used to rotate/transform the reflection.
  127947. * @param value Define the reflection matrix to set
  127948. */
  127949. setReflectionTextureMatrix(value: Matrix): void;
  127950. /**
  127951. * Parses a JSON representation of an HDR Texture in order to create the texture
  127952. * @param parsedTexture Define the JSON representation
  127953. * @param scene Define the scene the texture should be created in
  127954. * @param rootUrl Define the root url in case we need to load relative dependencies
  127955. * @returns the newly created texture after parsing
  127956. */
  127957. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127958. serialize(): any;
  127959. }
  127960. }
  127961. declare module BABYLON {
  127962. /**
  127963. * Class used to control physics engine
  127964. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127965. */
  127966. export class PhysicsEngine implements IPhysicsEngine {
  127967. private _physicsPlugin;
  127968. /**
  127969. * Global value used to control the smallest number supported by the simulation
  127970. */
  127971. static Epsilon: number;
  127972. private _impostors;
  127973. private _joints;
  127974. private _subTimeStep;
  127975. /**
  127976. * Gets the gravity vector used by the simulation
  127977. */
  127978. gravity: Vector3;
  127979. /**
  127980. * Factory used to create the default physics plugin.
  127981. * @returns The default physics plugin
  127982. */
  127983. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127984. /**
  127985. * Creates a new Physics Engine
  127986. * @param gravity defines the gravity vector used by the simulation
  127987. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127988. */
  127989. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127990. /**
  127991. * Sets the gravity vector used by the simulation
  127992. * @param gravity defines the gravity vector to use
  127993. */
  127994. setGravity(gravity: Vector3): void;
  127995. /**
  127996. * Set the time step of the physics engine.
  127997. * Default is 1/60.
  127998. * To slow it down, enter 1/600 for example.
  127999. * To speed it up, 1/30
  128000. * @param newTimeStep defines the new timestep to apply to this world.
  128001. */
  128002. setTimeStep(newTimeStep?: number): void;
  128003. /**
  128004. * Get the time step of the physics engine.
  128005. * @returns the current time step
  128006. */
  128007. getTimeStep(): number;
  128008. /**
  128009. * Set the sub time step of the physics engine.
  128010. * Default is 0 meaning there is no sub steps
  128011. * To increase physics resolution precision, set a small value (like 1 ms)
  128012. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128013. */
  128014. setSubTimeStep(subTimeStep?: number): void;
  128015. /**
  128016. * Get the sub time step of the physics engine.
  128017. * @returns the current sub time step
  128018. */
  128019. getSubTimeStep(): number;
  128020. /**
  128021. * Release all resources
  128022. */
  128023. dispose(): void;
  128024. /**
  128025. * Gets the name of the current physics plugin
  128026. * @returns the name of the plugin
  128027. */
  128028. getPhysicsPluginName(): string;
  128029. /**
  128030. * Adding a new impostor for the impostor tracking.
  128031. * This will be done by the impostor itself.
  128032. * @param impostor the impostor to add
  128033. */
  128034. addImpostor(impostor: PhysicsImpostor): void;
  128035. /**
  128036. * Remove an impostor from the engine.
  128037. * This impostor and its mesh will not longer be updated by the physics engine.
  128038. * @param impostor the impostor to remove
  128039. */
  128040. removeImpostor(impostor: PhysicsImpostor): void;
  128041. /**
  128042. * Add a joint to the physics engine
  128043. * @param mainImpostor defines the main impostor to which the joint is added.
  128044. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128045. * @param joint defines the joint that will connect both impostors.
  128046. */
  128047. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128048. /**
  128049. * Removes a joint from the simulation
  128050. * @param mainImpostor defines the impostor used with the joint
  128051. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128052. * @param joint defines the joint to remove
  128053. */
  128054. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128055. /**
  128056. * Called by the scene. No need to call it.
  128057. * @param delta defines the timespam between frames
  128058. */
  128059. _step(delta: number): void;
  128060. /**
  128061. * Gets the current plugin used to run the simulation
  128062. * @returns current plugin
  128063. */
  128064. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128065. /**
  128066. * Gets the list of physic impostors
  128067. * @returns an array of PhysicsImpostor
  128068. */
  128069. getImpostors(): Array<PhysicsImpostor>;
  128070. /**
  128071. * Gets the impostor for a physics enabled object
  128072. * @param object defines the object impersonated by the impostor
  128073. * @returns the PhysicsImpostor or null if not found
  128074. */
  128075. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128076. /**
  128077. * Gets the impostor for a physics body object
  128078. * @param body defines physics body used by the impostor
  128079. * @returns the PhysicsImpostor or null if not found
  128080. */
  128081. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128082. /**
  128083. * Does a raycast in the physics world
  128084. * @param from when should the ray start?
  128085. * @param to when should the ray end?
  128086. * @returns PhysicsRaycastResult
  128087. */
  128088. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128089. }
  128090. }
  128091. declare module BABYLON {
  128092. /** @hidden */
  128093. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128094. private _useDeltaForWorldStep;
  128095. world: any;
  128096. name: string;
  128097. private _physicsMaterials;
  128098. private _fixedTimeStep;
  128099. private _cannonRaycastResult;
  128100. private _raycastResult;
  128101. private _physicsBodysToRemoveAfterStep;
  128102. BJSCANNON: any;
  128103. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128104. setGravity(gravity: Vector3): void;
  128105. setTimeStep(timeStep: number): void;
  128106. getTimeStep(): number;
  128107. executeStep(delta: number): void;
  128108. private _removeMarkedPhysicsBodiesFromWorld;
  128109. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128110. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128111. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128112. private _processChildMeshes;
  128113. removePhysicsBody(impostor: PhysicsImpostor): void;
  128114. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128115. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128116. private _addMaterial;
  128117. private _checkWithEpsilon;
  128118. private _createShape;
  128119. private _createHeightmap;
  128120. private _minus90X;
  128121. private _plus90X;
  128122. private _tmpPosition;
  128123. private _tmpDeltaPosition;
  128124. private _tmpUnityRotation;
  128125. private _updatePhysicsBodyTransformation;
  128126. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128127. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128128. isSupported(): boolean;
  128129. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128130. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128131. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128132. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128133. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128134. getBodyMass(impostor: PhysicsImpostor): number;
  128135. getBodyFriction(impostor: PhysicsImpostor): number;
  128136. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128137. getBodyRestitution(impostor: PhysicsImpostor): number;
  128138. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128139. sleepBody(impostor: PhysicsImpostor): void;
  128140. wakeUpBody(impostor: PhysicsImpostor): void;
  128141. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128142. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128143. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128144. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128145. getRadius(impostor: PhysicsImpostor): number;
  128146. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128147. dispose(): void;
  128148. private _extendNamespace;
  128149. /**
  128150. * Does a raycast in the physics world
  128151. * @param from when should the ray start?
  128152. * @param to when should the ray end?
  128153. * @returns PhysicsRaycastResult
  128154. */
  128155. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128156. }
  128157. }
  128158. declare module BABYLON {
  128159. /** @hidden */
  128160. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128161. world: any;
  128162. name: string;
  128163. BJSOIMO: any;
  128164. private _raycastResult;
  128165. constructor(iterations?: number, oimoInjection?: any);
  128166. setGravity(gravity: Vector3): void;
  128167. setTimeStep(timeStep: number): void;
  128168. getTimeStep(): number;
  128169. private _tmpImpostorsArray;
  128170. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128171. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128174. private _tmpPositionVector;
  128175. removePhysicsBody(impostor: PhysicsImpostor): void;
  128176. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128177. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128178. isSupported(): boolean;
  128179. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128180. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128181. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128182. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128183. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128184. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128185. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128186. getBodyMass(impostor: PhysicsImpostor): number;
  128187. getBodyFriction(impostor: PhysicsImpostor): number;
  128188. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128189. getBodyRestitution(impostor: PhysicsImpostor): number;
  128190. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128191. sleepBody(impostor: PhysicsImpostor): void;
  128192. wakeUpBody(impostor: PhysicsImpostor): void;
  128193. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128194. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128195. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128196. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128197. getRadius(impostor: PhysicsImpostor): number;
  128198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128199. dispose(): void;
  128200. /**
  128201. * Does a raycast in the physics world
  128202. * @param from when should the ray start?
  128203. * @param to when should the ray end?
  128204. * @returns PhysicsRaycastResult
  128205. */
  128206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128207. }
  128208. }
  128209. declare module BABYLON {
  128210. /**
  128211. * Class containing static functions to help procedurally build meshes
  128212. */
  128213. export class RibbonBuilder {
  128214. /**
  128215. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128216. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128217. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128218. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128219. * * 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
  128220. * * 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
  128221. * * 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
  128222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128225. * * 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
  128226. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128227. * * 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
  128228. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128230. * @param name defines the name of the mesh
  128231. * @param options defines the options used to create the mesh
  128232. * @param scene defines the hosting scene
  128233. * @returns the ribbon mesh
  128234. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128235. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128236. */
  128237. static CreateRibbon(name: string, options: {
  128238. pathArray: Vector3[][];
  128239. closeArray?: boolean;
  128240. closePath?: boolean;
  128241. offset?: number;
  128242. updatable?: boolean;
  128243. sideOrientation?: number;
  128244. frontUVs?: Vector4;
  128245. backUVs?: Vector4;
  128246. instance?: Mesh;
  128247. invertUV?: boolean;
  128248. uvs?: Vector2[];
  128249. colors?: Color4[];
  128250. }, scene?: Nullable<Scene>): Mesh;
  128251. }
  128252. }
  128253. declare module BABYLON {
  128254. /**
  128255. * Class containing static functions to help procedurally build meshes
  128256. */
  128257. export class ShapeBuilder {
  128258. /**
  128259. * 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.
  128260. * * 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.
  128261. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128262. * * 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.
  128263. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128264. * * 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
  128265. * * 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
  128266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128271. * @param name defines the name of the mesh
  128272. * @param options defines the options used to create the mesh
  128273. * @param scene defines the hosting scene
  128274. * @returns the extruded shape mesh
  128275. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128277. */
  128278. static ExtrudeShape(name: string, options: {
  128279. shape: Vector3[];
  128280. path: Vector3[];
  128281. scale?: number;
  128282. rotation?: number;
  128283. cap?: number;
  128284. updatable?: boolean;
  128285. sideOrientation?: number;
  128286. frontUVs?: Vector4;
  128287. backUVs?: Vector4;
  128288. instance?: Mesh;
  128289. invertUV?: boolean;
  128290. }, scene?: Nullable<Scene>): Mesh;
  128291. /**
  128292. * Creates an custom extruded shape mesh.
  128293. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128294. * * 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.
  128295. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128296. * * 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
  128297. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128298. * * 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
  128299. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128300. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128301. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128302. * * 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
  128303. * * 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
  128304. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128309. * @param name defines the name of the mesh
  128310. * @param options defines the options used to create the mesh
  128311. * @param scene defines the hosting scene
  128312. * @returns the custom extruded shape mesh
  128313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128316. */
  128317. static ExtrudeShapeCustom(name: string, options: {
  128318. shape: Vector3[];
  128319. path: Vector3[];
  128320. scaleFunction?: any;
  128321. rotationFunction?: any;
  128322. ribbonCloseArray?: boolean;
  128323. ribbonClosePath?: boolean;
  128324. cap?: number;
  128325. updatable?: boolean;
  128326. sideOrientation?: number;
  128327. frontUVs?: Vector4;
  128328. backUVs?: Vector4;
  128329. instance?: Mesh;
  128330. invertUV?: boolean;
  128331. }, scene?: Nullable<Scene>): Mesh;
  128332. private static _ExtrudeShapeGeneric;
  128333. }
  128334. }
  128335. declare module BABYLON {
  128336. /**
  128337. * AmmoJS Physics plugin
  128338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128339. * @see https://github.com/kripken/ammo.js/
  128340. */
  128341. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128342. private _useDeltaForWorldStep;
  128343. /**
  128344. * Reference to the Ammo library
  128345. */
  128346. bjsAMMO: any;
  128347. /**
  128348. * Created ammoJS world which physics bodies are added to
  128349. */
  128350. world: any;
  128351. /**
  128352. * Name of the plugin
  128353. */
  128354. name: string;
  128355. private _timeStep;
  128356. private _fixedTimeStep;
  128357. private _maxSteps;
  128358. private _tmpQuaternion;
  128359. private _tmpAmmoTransform;
  128360. private _tmpAmmoQuaternion;
  128361. private _tmpAmmoConcreteContactResultCallback;
  128362. private _collisionConfiguration;
  128363. private _dispatcher;
  128364. private _overlappingPairCache;
  128365. private _solver;
  128366. private _softBodySolver;
  128367. private _tmpAmmoVectorA;
  128368. private _tmpAmmoVectorB;
  128369. private _tmpAmmoVectorC;
  128370. private _tmpAmmoVectorD;
  128371. private _tmpContactCallbackResult;
  128372. private _tmpAmmoVectorRCA;
  128373. private _tmpAmmoVectorRCB;
  128374. private _raycastResult;
  128375. private static readonly DISABLE_COLLISION_FLAG;
  128376. private static readonly KINEMATIC_FLAG;
  128377. private static readonly DISABLE_DEACTIVATION_FLAG;
  128378. /**
  128379. * Initializes the ammoJS plugin
  128380. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128381. * @param ammoInjection can be used to inject your own ammo reference
  128382. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128383. */
  128384. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128385. /**
  128386. * Sets the gravity of the physics world (m/(s^2))
  128387. * @param gravity Gravity to set
  128388. */
  128389. setGravity(gravity: Vector3): void;
  128390. /**
  128391. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128392. * @param timeStep timestep to use in seconds
  128393. */
  128394. setTimeStep(timeStep: number): void;
  128395. /**
  128396. * 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)
  128397. * @param fixedTimeStep fixedTimeStep to use in seconds
  128398. */
  128399. setFixedTimeStep(fixedTimeStep: number): void;
  128400. /**
  128401. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128402. * @param maxSteps the maximum number of steps by the physics engine per frame
  128403. */
  128404. setMaxSteps(maxSteps: number): void;
  128405. /**
  128406. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128407. * @returns the current timestep in seconds
  128408. */
  128409. getTimeStep(): number;
  128410. /**
  128411. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128412. */
  128413. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128414. private _isImpostorInContact;
  128415. private _isImpostorPairInContact;
  128416. private _stepSimulation;
  128417. /**
  128418. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128419. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128420. * After the step the babylon meshes are set to the position of the physics imposters
  128421. * @param delta amount of time to step forward
  128422. * @param impostors array of imposters to update before/after the step
  128423. */
  128424. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128425. /**
  128426. * Update babylon mesh to match physics world object
  128427. * @param impostor imposter to match
  128428. */
  128429. private _afterSoftStep;
  128430. /**
  128431. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128432. * @param impostor imposter to match
  128433. */
  128434. private _ropeStep;
  128435. /**
  128436. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128437. * @param impostor imposter to match
  128438. */
  128439. private _softbodyOrClothStep;
  128440. private _tmpVector;
  128441. private _tmpMatrix;
  128442. /**
  128443. * Applies an impulse on the imposter
  128444. * @param impostor imposter to apply impulse to
  128445. * @param force amount of force to be applied to the imposter
  128446. * @param contactPoint the location to apply the impulse on the imposter
  128447. */
  128448. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128449. /**
  128450. * Applies a force on the imposter
  128451. * @param impostor imposter to apply force
  128452. * @param force amount of force to be applied to the imposter
  128453. * @param contactPoint the location to apply the force on the imposter
  128454. */
  128455. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128456. /**
  128457. * Creates a physics body using the plugin
  128458. * @param impostor the imposter to create the physics body on
  128459. */
  128460. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128461. /**
  128462. * Removes the physics body from the imposter and disposes of the body's memory
  128463. * @param impostor imposter to remove the physics body from
  128464. */
  128465. removePhysicsBody(impostor: PhysicsImpostor): void;
  128466. /**
  128467. * Generates a joint
  128468. * @param impostorJoint the imposter joint to create the joint with
  128469. */
  128470. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128471. /**
  128472. * Removes a joint
  128473. * @param impostorJoint the imposter joint to remove the joint from
  128474. */
  128475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128476. private _addMeshVerts;
  128477. /**
  128478. * Initialise the soft body vertices to match its object's (mesh) vertices
  128479. * Softbody vertices (nodes) are in world space and to match this
  128480. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128481. * @param impostor to create the softbody for
  128482. */
  128483. private _softVertexData;
  128484. /**
  128485. * Create an impostor's soft body
  128486. * @param impostor to create the softbody for
  128487. */
  128488. private _createSoftbody;
  128489. /**
  128490. * Create cloth for an impostor
  128491. * @param impostor to create the softbody for
  128492. */
  128493. private _createCloth;
  128494. /**
  128495. * Create rope for an impostor
  128496. * @param impostor to create the softbody for
  128497. */
  128498. private _createRope;
  128499. /**
  128500. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128501. * @param impostor to create the custom physics shape for
  128502. */
  128503. private _createCustom;
  128504. private _addHullVerts;
  128505. private _createShape;
  128506. /**
  128507. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128508. * @param impostor imposter containing the physics body and babylon object
  128509. */
  128510. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128511. /**
  128512. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128513. * @param impostor imposter containing the physics body and babylon object
  128514. * @param newPosition new position
  128515. * @param newRotation new rotation
  128516. */
  128517. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128518. /**
  128519. * If this plugin is supported
  128520. * @returns true if its supported
  128521. */
  128522. isSupported(): boolean;
  128523. /**
  128524. * Sets the linear velocity of the physics body
  128525. * @param impostor imposter to set the velocity on
  128526. * @param velocity velocity to set
  128527. */
  128528. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128529. /**
  128530. * Sets the angular velocity of the physics body
  128531. * @param impostor imposter to set the velocity on
  128532. * @param velocity velocity to set
  128533. */
  128534. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128535. /**
  128536. * gets the linear velocity
  128537. * @param impostor imposter to get linear velocity from
  128538. * @returns linear velocity
  128539. */
  128540. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128541. /**
  128542. * gets the angular velocity
  128543. * @param impostor imposter to get angular velocity from
  128544. * @returns angular velocity
  128545. */
  128546. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128547. /**
  128548. * Sets the mass of physics body
  128549. * @param impostor imposter to set the mass on
  128550. * @param mass mass to set
  128551. */
  128552. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128553. /**
  128554. * Gets the mass of the physics body
  128555. * @param impostor imposter to get the mass from
  128556. * @returns mass
  128557. */
  128558. getBodyMass(impostor: PhysicsImpostor): number;
  128559. /**
  128560. * Gets friction of the impostor
  128561. * @param impostor impostor to get friction from
  128562. * @returns friction value
  128563. */
  128564. getBodyFriction(impostor: PhysicsImpostor): number;
  128565. /**
  128566. * Sets friction of the impostor
  128567. * @param impostor impostor to set friction on
  128568. * @param friction friction value
  128569. */
  128570. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128571. /**
  128572. * Gets restitution of the impostor
  128573. * @param impostor impostor to get restitution from
  128574. * @returns restitution value
  128575. */
  128576. getBodyRestitution(impostor: PhysicsImpostor): number;
  128577. /**
  128578. * Sets resitution of the impostor
  128579. * @param impostor impostor to set resitution on
  128580. * @param restitution resitution value
  128581. */
  128582. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128583. /**
  128584. * Gets pressure inside the impostor
  128585. * @param impostor impostor to get pressure from
  128586. * @returns pressure value
  128587. */
  128588. getBodyPressure(impostor: PhysicsImpostor): number;
  128589. /**
  128590. * Sets pressure inside a soft body impostor
  128591. * Cloth and rope must remain 0 pressure
  128592. * @param impostor impostor to set pressure on
  128593. * @param pressure pressure value
  128594. */
  128595. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128596. /**
  128597. * Gets stiffness of the impostor
  128598. * @param impostor impostor to get stiffness from
  128599. * @returns pressure value
  128600. */
  128601. getBodyStiffness(impostor: PhysicsImpostor): number;
  128602. /**
  128603. * Sets stiffness of the impostor
  128604. * @param impostor impostor to set stiffness on
  128605. * @param stiffness stiffness value from 0 to 1
  128606. */
  128607. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128608. /**
  128609. * Gets velocityIterations of the impostor
  128610. * @param impostor impostor to get velocity iterations from
  128611. * @returns velocityIterations value
  128612. */
  128613. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128614. /**
  128615. * Sets velocityIterations of the impostor
  128616. * @param impostor impostor to set velocity iterations on
  128617. * @param velocityIterations velocityIterations value
  128618. */
  128619. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128620. /**
  128621. * Gets positionIterations of the impostor
  128622. * @param impostor impostor to get position iterations from
  128623. * @returns positionIterations value
  128624. */
  128625. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128626. /**
  128627. * Sets positionIterations of the impostor
  128628. * @param impostor impostor to set position on
  128629. * @param positionIterations positionIterations value
  128630. */
  128631. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128632. /**
  128633. * Append an anchor to a cloth object
  128634. * @param impostor is the cloth impostor to add anchor to
  128635. * @param otherImpostor is the rigid impostor to anchor to
  128636. * @param width ratio across width from 0 to 1
  128637. * @param height ratio up height from 0 to 1
  128638. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128639. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128640. */
  128641. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128642. /**
  128643. * Append an hook to a rope object
  128644. * @param impostor is the rope impostor to add hook to
  128645. * @param otherImpostor is the rigid impostor to hook to
  128646. * @param length ratio along the rope from 0 to 1
  128647. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128648. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128649. */
  128650. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128651. /**
  128652. * Sleeps the physics body and stops it from being active
  128653. * @param impostor impostor to sleep
  128654. */
  128655. sleepBody(impostor: PhysicsImpostor): void;
  128656. /**
  128657. * Activates the physics body
  128658. * @param impostor impostor to activate
  128659. */
  128660. wakeUpBody(impostor: PhysicsImpostor): void;
  128661. /**
  128662. * Updates the distance parameters of the joint
  128663. * @param joint joint to update
  128664. * @param maxDistance maximum distance of the joint
  128665. * @param minDistance minimum distance of the joint
  128666. */
  128667. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128668. /**
  128669. * Sets a motor on the joint
  128670. * @param joint joint to set motor on
  128671. * @param speed speed of the motor
  128672. * @param maxForce maximum force of the motor
  128673. * @param motorIndex index of the motor
  128674. */
  128675. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128676. /**
  128677. * Sets the motors limit
  128678. * @param joint joint to set limit on
  128679. * @param upperLimit upper limit
  128680. * @param lowerLimit lower limit
  128681. */
  128682. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128683. /**
  128684. * Syncs the position and rotation of a mesh with the impostor
  128685. * @param mesh mesh to sync
  128686. * @param impostor impostor to update the mesh with
  128687. */
  128688. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128689. /**
  128690. * Gets the radius of the impostor
  128691. * @param impostor impostor to get radius from
  128692. * @returns the radius
  128693. */
  128694. getRadius(impostor: PhysicsImpostor): number;
  128695. /**
  128696. * Gets the box size of the impostor
  128697. * @param impostor impostor to get box size from
  128698. * @param result the resulting box size
  128699. */
  128700. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128701. /**
  128702. * Disposes of the impostor
  128703. */
  128704. dispose(): void;
  128705. /**
  128706. * Does a raycast in the physics world
  128707. * @param from when should the ray start?
  128708. * @param to when should the ray end?
  128709. * @returns PhysicsRaycastResult
  128710. */
  128711. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128712. }
  128713. }
  128714. declare module BABYLON {
  128715. interface AbstractScene {
  128716. /**
  128717. * The list of reflection probes added to the scene
  128718. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128719. */
  128720. reflectionProbes: Array<ReflectionProbe>;
  128721. /**
  128722. * Removes the given reflection probe from this scene.
  128723. * @param toRemove The reflection probe to remove
  128724. * @returns The index of the removed reflection probe
  128725. */
  128726. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128727. /**
  128728. * Adds the given reflection probe to this scene.
  128729. * @param newReflectionProbe The reflection probe to add
  128730. */
  128731. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128732. }
  128733. /**
  128734. * Class used to generate realtime reflection / refraction cube textures
  128735. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128736. */
  128737. export class ReflectionProbe {
  128738. /** defines the name of the probe */
  128739. name: string;
  128740. private _scene;
  128741. private _renderTargetTexture;
  128742. private _projectionMatrix;
  128743. private _viewMatrix;
  128744. private _target;
  128745. private _add;
  128746. private _attachedMesh;
  128747. private _invertYAxis;
  128748. /** Gets or sets probe position (center of the cube map) */
  128749. position: Vector3;
  128750. /**
  128751. * Creates a new reflection probe
  128752. * @param name defines the name of the probe
  128753. * @param size defines the texture resolution (for each face)
  128754. * @param scene defines the hosting scene
  128755. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128756. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128757. */
  128758. constructor(
  128759. /** defines the name of the probe */
  128760. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128761. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128762. get samples(): number;
  128763. set samples(value: number);
  128764. /** Gets or sets the refresh rate to use (on every frame by default) */
  128765. get refreshRate(): number;
  128766. set refreshRate(value: number);
  128767. /**
  128768. * Gets the hosting scene
  128769. * @returns a Scene
  128770. */
  128771. getScene(): Scene;
  128772. /** Gets the internal CubeTexture used to render to */
  128773. get cubeTexture(): RenderTargetTexture;
  128774. /** Gets the list of meshes to render */
  128775. get renderList(): Nullable<AbstractMesh[]>;
  128776. /**
  128777. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128778. * @param mesh defines the mesh to attach to
  128779. */
  128780. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128781. /**
  128782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128783. * @param renderingGroupId The rendering group id corresponding to its index
  128784. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128785. */
  128786. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128787. /**
  128788. * Clean all associated resources
  128789. */
  128790. dispose(): void;
  128791. /**
  128792. * Converts the reflection probe information to a readable string for debug purpose.
  128793. * @param fullDetails Supports for multiple levels of logging within scene loading
  128794. * @returns the human readable reflection probe info
  128795. */
  128796. toString(fullDetails?: boolean): string;
  128797. /**
  128798. * Get the class name of the relfection probe.
  128799. * @returns "ReflectionProbe"
  128800. */
  128801. getClassName(): string;
  128802. /**
  128803. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128804. * @returns The JSON representation of the texture
  128805. */
  128806. serialize(): any;
  128807. /**
  128808. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128809. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128810. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128811. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128812. * @returns The parsed reflection probe if successful
  128813. */
  128814. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128815. }
  128816. }
  128817. declare module BABYLON {
  128818. /** @hidden */
  128819. export var _BabylonLoaderRegistered: boolean;
  128820. /**
  128821. * Helps setting up some configuration for the babylon file loader.
  128822. */
  128823. export class BabylonFileLoaderConfiguration {
  128824. /**
  128825. * The loader does not allow injecting custom physix engine into the plugins.
  128826. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128827. * So you could set this variable to your engine import to make it work.
  128828. */
  128829. static LoaderInjectedPhysicsEngine: any;
  128830. }
  128831. }
  128832. declare module BABYLON {
  128833. /**
  128834. * The Physically based simple base material of BJS.
  128835. *
  128836. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128837. * It is used as the base class for both the specGloss and metalRough conventions.
  128838. */
  128839. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128840. /**
  128841. * Number of Simultaneous lights allowed on the material.
  128842. */
  128843. maxSimultaneousLights: number;
  128844. /**
  128845. * If sets to true, disables all the lights affecting the material.
  128846. */
  128847. disableLighting: boolean;
  128848. /**
  128849. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128850. */
  128851. environmentTexture: BaseTexture;
  128852. /**
  128853. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128854. */
  128855. invertNormalMapX: boolean;
  128856. /**
  128857. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128858. */
  128859. invertNormalMapY: boolean;
  128860. /**
  128861. * Normal map used in the model.
  128862. */
  128863. normalTexture: BaseTexture;
  128864. /**
  128865. * Emissivie color used to self-illuminate the model.
  128866. */
  128867. emissiveColor: Color3;
  128868. /**
  128869. * Emissivie texture used to self-illuminate the model.
  128870. */
  128871. emissiveTexture: BaseTexture;
  128872. /**
  128873. * Occlusion Channel Strenght.
  128874. */
  128875. occlusionStrength: number;
  128876. /**
  128877. * Occlusion Texture of the material (adding extra occlusion effects).
  128878. */
  128879. occlusionTexture: BaseTexture;
  128880. /**
  128881. * Defines the alpha limits in alpha test mode.
  128882. */
  128883. alphaCutOff: number;
  128884. /**
  128885. * Gets the current double sided mode.
  128886. */
  128887. get doubleSided(): boolean;
  128888. /**
  128889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128890. */
  128891. set doubleSided(value: boolean);
  128892. /**
  128893. * Stores the pre-calculated light information of a mesh in a texture.
  128894. */
  128895. lightmapTexture: BaseTexture;
  128896. /**
  128897. * If true, the light map contains occlusion information instead of lighting info.
  128898. */
  128899. useLightmapAsShadowmap: boolean;
  128900. /**
  128901. * Instantiates a new PBRMaterial instance.
  128902. *
  128903. * @param name The material name
  128904. * @param scene The scene the material will be use in.
  128905. */
  128906. constructor(name: string, scene: Scene);
  128907. getClassName(): string;
  128908. }
  128909. }
  128910. declare module BABYLON {
  128911. /**
  128912. * The PBR material of BJS following the metal roughness convention.
  128913. *
  128914. * This fits to the PBR convention in the GLTF definition:
  128915. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128916. */
  128917. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128918. /**
  128919. * The base color has two different interpretations depending on the value of metalness.
  128920. * When the material is a metal, the base color is the specific measured reflectance value
  128921. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128922. * of the material.
  128923. */
  128924. baseColor: Color3;
  128925. /**
  128926. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128927. * well as opacity information in the alpha channel.
  128928. */
  128929. baseTexture: BaseTexture;
  128930. /**
  128931. * Specifies the metallic scalar value of the material.
  128932. * Can also be used to scale the metalness values of the metallic texture.
  128933. */
  128934. metallic: number;
  128935. /**
  128936. * Specifies the roughness scalar value of the material.
  128937. * Can also be used to scale the roughness values of the metallic texture.
  128938. */
  128939. roughness: number;
  128940. /**
  128941. * Texture containing both the metallic value in the B channel and the
  128942. * roughness value in the G channel to keep better precision.
  128943. */
  128944. metallicRoughnessTexture: BaseTexture;
  128945. /**
  128946. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128947. *
  128948. * @param name The material name
  128949. * @param scene The scene the material will be use in.
  128950. */
  128951. constructor(name: string, scene: Scene);
  128952. /**
  128953. * Return the currrent class name of the material.
  128954. */
  128955. getClassName(): string;
  128956. /**
  128957. * Makes a duplicate of the current material.
  128958. * @param name - name to use for the new material.
  128959. */
  128960. clone(name: string): PBRMetallicRoughnessMaterial;
  128961. /**
  128962. * Serialize the material to a parsable JSON object.
  128963. */
  128964. serialize(): any;
  128965. /**
  128966. * Parses a JSON object correponding to the serialize function.
  128967. */
  128968. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128969. }
  128970. }
  128971. declare module BABYLON {
  128972. /**
  128973. * The PBR material of BJS following the specular glossiness convention.
  128974. *
  128975. * This fits to the PBR convention in the GLTF definition:
  128976. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128977. */
  128978. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128979. /**
  128980. * Specifies the diffuse color of the material.
  128981. */
  128982. diffuseColor: Color3;
  128983. /**
  128984. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128985. * channel.
  128986. */
  128987. diffuseTexture: BaseTexture;
  128988. /**
  128989. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128990. */
  128991. specularColor: Color3;
  128992. /**
  128993. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128994. */
  128995. glossiness: number;
  128996. /**
  128997. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128998. */
  128999. specularGlossinessTexture: BaseTexture;
  129000. /**
  129001. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129002. *
  129003. * @param name The material name
  129004. * @param scene The scene the material will be use in.
  129005. */
  129006. constructor(name: string, scene: Scene);
  129007. /**
  129008. * Return the currrent class name of the material.
  129009. */
  129010. getClassName(): string;
  129011. /**
  129012. * Makes a duplicate of the current material.
  129013. * @param name - name to use for the new material.
  129014. */
  129015. clone(name: string): PBRSpecularGlossinessMaterial;
  129016. /**
  129017. * Serialize the material to a parsable JSON object.
  129018. */
  129019. serialize(): any;
  129020. /**
  129021. * Parses a JSON object correponding to the serialize function.
  129022. */
  129023. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129024. }
  129025. }
  129026. declare module BABYLON {
  129027. /**
  129028. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129029. * It can help converting any input color in a desired output one. This can then be used to create effects
  129030. * from sepia, black and white to sixties or futuristic rendering...
  129031. *
  129032. * The only supported format is currently 3dl.
  129033. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129034. */
  129035. export class ColorGradingTexture extends BaseTexture {
  129036. /**
  129037. * The current texture matrix. (will always be identity in color grading texture)
  129038. */
  129039. private _textureMatrix;
  129040. /**
  129041. * The texture URL.
  129042. */
  129043. url: string;
  129044. /**
  129045. * Empty line regex stored for GC.
  129046. */
  129047. private static _noneEmptyLineRegex;
  129048. private _engine;
  129049. /**
  129050. * Instantiates a ColorGradingTexture from the following parameters.
  129051. *
  129052. * @param url The location of the color gradind data (currently only supporting 3dl)
  129053. * @param scene The scene the texture will be used in
  129054. */
  129055. constructor(url: string, scene: Scene);
  129056. /**
  129057. * Returns the texture matrix used in most of the material.
  129058. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129059. */
  129060. getTextureMatrix(): Matrix;
  129061. /**
  129062. * Occurs when the file being loaded is a .3dl LUT file.
  129063. */
  129064. private load3dlTexture;
  129065. /**
  129066. * Starts the loading process of the texture.
  129067. */
  129068. private loadTexture;
  129069. /**
  129070. * Clones the color gradind texture.
  129071. */
  129072. clone(): ColorGradingTexture;
  129073. /**
  129074. * Called during delayed load for textures.
  129075. */
  129076. delayLoad(): void;
  129077. /**
  129078. * Parses a color grading texture serialized by Babylon.
  129079. * @param parsedTexture The texture information being parsedTexture
  129080. * @param scene The scene to load the texture in
  129081. * @param rootUrl The root url of the data assets to load
  129082. * @return A color gradind texture
  129083. */
  129084. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129085. /**
  129086. * Serializes the LUT texture to json format.
  129087. */
  129088. serialize(): any;
  129089. }
  129090. }
  129091. declare module BABYLON {
  129092. /**
  129093. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129094. */
  129095. export class EquiRectangularCubeTexture extends BaseTexture {
  129096. /** The six faces of the cube. */
  129097. private static _FacesMapping;
  129098. private _noMipmap;
  129099. private _onLoad;
  129100. private _onError;
  129101. /** The size of the cubemap. */
  129102. private _size;
  129103. /** The buffer of the image. */
  129104. private _buffer;
  129105. /** The width of the input image. */
  129106. private _width;
  129107. /** The height of the input image. */
  129108. private _height;
  129109. /** The URL to the image. */
  129110. url: string;
  129111. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129112. coordinatesMode: number;
  129113. /**
  129114. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129115. * @param url The location of the image
  129116. * @param scene The scene the texture will be used in
  129117. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129118. * @param noMipmap Forces to not generate the mipmap if true
  129119. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129120. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129121. * @param onLoad — defines a callback called when texture is loaded
  129122. * @param onError — defines a callback called if there is an error
  129123. */
  129124. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129125. /**
  129126. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129127. */
  129128. private loadImage;
  129129. /**
  129130. * Convert the image buffer into a cubemap and create a CubeTexture.
  129131. */
  129132. private loadTexture;
  129133. /**
  129134. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129135. * @param buffer The ArrayBuffer that should be converted.
  129136. * @returns The buffer as Float32Array.
  129137. */
  129138. private getFloat32ArrayFromArrayBuffer;
  129139. /**
  129140. * Get the current class name of the texture useful for serialization or dynamic coding.
  129141. * @returns "EquiRectangularCubeTexture"
  129142. */
  129143. getClassName(): string;
  129144. /**
  129145. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129146. * @returns A clone of the current EquiRectangularCubeTexture.
  129147. */
  129148. clone(): EquiRectangularCubeTexture;
  129149. }
  129150. }
  129151. declare module BABYLON {
  129152. /**
  129153. * Based on jsTGALoader - Javascript loader for TGA file
  129154. * By Vincent Thibault
  129155. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129156. */
  129157. export class TGATools {
  129158. private static _TYPE_INDEXED;
  129159. private static _TYPE_RGB;
  129160. private static _TYPE_GREY;
  129161. private static _TYPE_RLE_INDEXED;
  129162. private static _TYPE_RLE_RGB;
  129163. private static _TYPE_RLE_GREY;
  129164. private static _ORIGIN_MASK;
  129165. private static _ORIGIN_SHIFT;
  129166. private static _ORIGIN_BL;
  129167. private static _ORIGIN_BR;
  129168. private static _ORIGIN_UL;
  129169. private static _ORIGIN_UR;
  129170. /**
  129171. * Gets the header of a TGA file
  129172. * @param data defines the TGA data
  129173. * @returns the header
  129174. */
  129175. static GetTGAHeader(data: Uint8Array): any;
  129176. /**
  129177. * Uploads TGA content to a Babylon Texture
  129178. * @hidden
  129179. */
  129180. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129181. /** @hidden */
  129182. 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;
  129183. /** @hidden */
  129184. 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;
  129185. /** @hidden */
  129186. 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;
  129187. /** @hidden */
  129188. 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;
  129189. /** @hidden */
  129190. 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;
  129191. /** @hidden */
  129192. 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;
  129193. }
  129194. }
  129195. declare module BABYLON {
  129196. /**
  129197. * Implementation of the TGA Texture Loader.
  129198. * @hidden
  129199. */
  129200. export class _TGATextureLoader implements IInternalTextureLoader {
  129201. /**
  129202. * Defines wether the loader supports cascade loading the different faces.
  129203. */
  129204. readonly supportCascades: boolean;
  129205. /**
  129206. * This returns if the loader support the current file information.
  129207. * @param extension defines the file extension of the file being loaded
  129208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129209. * @param fallback defines the fallback internal texture if any
  129210. * @param isBase64 defines whether the texture is encoded as a base64
  129211. * @param isBuffer defines whether the texture data are stored as a buffer
  129212. * @returns true if the loader can load the specified file
  129213. */
  129214. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129215. /**
  129216. * Transform the url before loading if required.
  129217. * @param rootUrl the url of the texture
  129218. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129219. * @returns the transformed texture
  129220. */
  129221. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129222. /**
  129223. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129224. * @param rootUrl the url of the texture
  129225. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129226. * @returns the fallback texture
  129227. */
  129228. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129229. /**
  129230. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129231. * @param data contains the texture data
  129232. * @param texture defines the BabylonJS internal texture
  129233. * @param createPolynomials will be true if polynomials have been requested
  129234. * @param onLoad defines the callback to trigger once the texture is ready
  129235. * @param onError defines the callback to trigger in case of error
  129236. */
  129237. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129238. /**
  129239. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129240. * @param data contains the texture data
  129241. * @param texture defines the BabylonJS internal texture
  129242. * @param callback defines the method to call once ready to upload
  129243. */
  129244. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /**
  129249. * Info about the .basis files
  129250. */
  129251. class BasisFileInfo {
  129252. /**
  129253. * If the file has alpha
  129254. */
  129255. hasAlpha: boolean;
  129256. /**
  129257. * Info about each image of the basis file
  129258. */
  129259. images: Array<{
  129260. levels: Array<{
  129261. width: number;
  129262. height: number;
  129263. transcodedPixels: ArrayBufferView;
  129264. }>;
  129265. }>;
  129266. }
  129267. /**
  129268. * Result of transcoding a basis file
  129269. */
  129270. class TranscodeResult {
  129271. /**
  129272. * Info about the .basis file
  129273. */
  129274. fileInfo: BasisFileInfo;
  129275. /**
  129276. * Format to use when loading the file
  129277. */
  129278. format: number;
  129279. }
  129280. /**
  129281. * Configuration options for the Basis transcoder
  129282. */
  129283. export class BasisTranscodeConfiguration {
  129284. /**
  129285. * Supported compression formats used to determine the supported output format of the transcoder
  129286. */
  129287. supportedCompressionFormats?: {
  129288. /**
  129289. * etc1 compression format
  129290. */
  129291. etc1?: boolean;
  129292. /**
  129293. * s3tc compression format
  129294. */
  129295. s3tc?: boolean;
  129296. /**
  129297. * pvrtc compression format
  129298. */
  129299. pvrtc?: boolean;
  129300. /**
  129301. * etc2 compression format
  129302. */
  129303. etc2?: boolean;
  129304. };
  129305. /**
  129306. * If mipmap levels should be loaded for transcoded images (Default: true)
  129307. */
  129308. loadMipmapLevels?: boolean;
  129309. /**
  129310. * Index of a single image to load (Default: all images)
  129311. */
  129312. loadSingleImage?: number;
  129313. }
  129314. /**
  129315. * Used to load .Basis files
  129316. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129317. */
  129318. export class BasisTools {
  129319. private static _IgnoreSupportedFormats;
  129320. /**
  129321. * URL to use when loading the basis transcoder
  129322. */
  129323. static JSModuleURL: string;
  129324. /**
  129325. * URL to use when loading the wasm module for the transcoder
  129326. */
  129327. static WasmModuleURL: string;
  129328. /**
  129329. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129330. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129331. * @returns internal format corresponding to the Basis format
  129332. */
  129333. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129334. private static _WorkerPromise;
  129335. private static _Worker;
  129336. private static _actionId;
  129337. private static _CreateWorkerAsync;
  129338. /**
  129339. * Transcodes a loaded image file to compressed pixel data
  129340. * @param data image data to transcode
  129341. * @param config configuration options for the transcoding
  129342. * @returns a promise resulting in the transcoded image
  129343. */
  129344. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129345. /**
  129346. * Loads a texture from the transcode result
  129347. * @param texture texture load to
  129348. * @param transcodeResult the result of transcoding the basis file to load from
  129349. */
  129350. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129351. }
  129352. }
  129353. declare module BABYLON {
  129354. /**
  129355. * Loader for .basis file format
  129356. */
  129357. export class _BasisTextureLoader implements IInternalTextureLoader {
  129358. /**
  129359. * Defines whether the loader supports cascade loading the different faces.
  129360. */
  129361. readonly supportCascades: boolean;
  129362. /**
  129363. * This returns if the loader support the current file information.
  129364. * @param extension defines the file extension of the file being loaded
  129365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129366. * @param fallback defines the fallback internal texture if any
  129367. * @param isBase64 defines whether the texture is encoded as a base64
  129368. * @param isBuffer defines whether the texture data are stored as a buffer
  129369. * @returns true if the loader can load the specified file
  129370. */
  129371. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129372. /**
  129373. * Transform the url before loading if required.
  129374. * @param rootUrl the url of the texture
  129375. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129376. * @returns the transformed texture
  129377. */
  129378. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129379. /**
  129380. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129381. * @param rootUrl the url of the texture
  129382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129383. * @returns the fallback texture
  129384. */
  129385. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129386. /**
  129387. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129388. * @param data contains the texture data
  129389. * @param texture defines the BabylonJS internal texture
  129390. * @param createPolynomials will be true if polynomials have been requested
  129391. * @param onLoad defines the callback to trigger once the texture is ready
  129392. * @param onError defines the callback to trigger in case of error
  129393. */
  129394. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129395. /**
  129396. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129397. * @param data contains the texture data
  129398. * @param texture defines the BabylonJS internal texture
  129399. * @param callback defines the method to call once ready to upload
  129400. */
  129401. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129402. }
  129403. }
  129404. declare module BABYLON {
  129405. /**
  129406. * 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.
  129407. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129408. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129409. */
  129410. export class CustomProceduralTexture extends ProceduralTexture {
  129411. private _animate;
  129412. private _time;
  129413. private _config;
  129414. private _texturePath;
  129415. /**
  129416. * Instantiates a new Custom Procedural Texture.
  129417. * 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.
  129418. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129419. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129420. * @param name Define the name of the texture
  129421. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129422. * @param size Define the size of the texture to create
  129423. * @param scene Define the scene the texture belongs to
  129424. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129425. * @param generateMipMaps Define if the texture should creates mip maps or not
  129426. */
  129427. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129428. private _loadJson;
  129429. /**
  129430. * Is the texture ready to be used ? (rendered at least once)
  129431. * @returns true if ready, otherwise, false.
  129432. */
  129433. isReady(): boolean;
  129434. /**
  129435. * Render the texture to its associated render target.
  129436. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129437. */
  129438. render(useCameraPostProcess?: boolean): void;
  129439. /**
  129440. * Update the list of dependant textures samplers in the shader.
  129441. */
  129442. updateTextures(): void;
  129443. /**
  129444. * Update the uniform values of the procedural texture in the shader.
  129445. */
  129446. updateShaderUniforms(): void;
  129447. /**
  129448. * Define if the texture animates or not.
  129449. */
  129450. get animate(): boolean;
  129451. set animate(value: boolean);
  129452. }
  129453. }
  129454. declare module BABYLON {
  129455. /** @hidden */
  129456. export var noisePixelShader: {
  129457. name: string;
  129458. shader: string;
  129459. };
  129460. }
  129461. declare module BABYLON {
  129462. /**
  129463. * Class used to generate noise procedural textures
  129464. */
  129465. export class NoiseProceduralTexture extends ProceduralTexture {
  129466. private _time;
  129467. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129468. brightness: number;
  129469. /** Defines the number of octaves to process */
  129470. octaves: number;
  129471. /** Defines the level of persistence (0.8 by default) */
  129472. persistence: number;
  129473. /** Gets or sets animation speed factor (default is 1) */
  129474. animationSpeedFactor: number;
  129475. /**
  129476. * Creates a new NoiseProceduralTexture
  129477. * @param name defines the name fo the texture
  129478. * @param size defines the size of the texture (default is 256)
  129479. * @param scene defines the hosting scene
  129480. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129481. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129482. */
  129483. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129484. private _updateShaderUniforms;
  129485. protected _getDefines(): string;
  129486. /** Generate the current state of the procedural texture */
  129487. render(useCameraPostProcess?: boolean): void;
  129488. /**
  129489. * Serializes this noise procedural texture
  129490. * @returns a serialized noise procedural texture object
  129491. */
  129492. serialize(): any;
  129493. /**
  129494. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129495. * @param parsedTexture defines parsed texture data
  129496. * @param scene defines the current scene
  129497. * @param rootUrl defines the root URL containing noise procedural texture information
  129498. * @returns a parsed NoiseProceduralTexture
  129499. */
  129500. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129501. }
  129502. }
  129503. declare module BABYLON {
  129504. /**
  129505. * Raw cube texture where the raw buffers are passed in
  129506. */
  129507. export class RawCubeTexture extends CubeTexture {
  129508. /**
  129509. * Creates a cube texture where the raw buffers are passed in.
  129510. * @param scene defines the scene the texture is attached to
  129511. * @param data defines the array of data to use to create each face
  129512. * @param size defines the size of the textures
  129513. * @param format defines the format of the data
  129514. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129515. * @param generateMipMaps defines if the engine should generate the mip levels
  129516. * @param invertY defines if data must be stored with Y axis inverted
  129517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129518. * @param compression defines the compression used (null by default)
  129519. */
  129520. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129521. /**
  129522. * Updates the raw cube texture.
  129523. * @param data defines the data to store
  129524. * @param format defines the data format
  129525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129526. * @param invertY defines if data must be stored with Y axis inverted
  129527. * @param compression defines the compression used (null by default)
  129528. * @param level defines which level of the texture to update
  129529. */
  129530. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129531. /**
  129532. * Updates a raw cube texture with RGBD encoded data.
  129533. * @param data defines the array of data [mipmap][face] to use to create each face
  129534. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129535. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129536. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129537. * @returns a promsie that resolves when the operation is complete
  129538. */
  129539. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129540. /**
  129541. * Clones the raw cube texture.
  129542. * @return a new cube texture
  129543. */
  129544. clone(): CubeTexture;
  129545. /** @hidden */
  129546. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129547. }
  129548. }
  129549. declare module BABYLON {
  129550. /**
  129551. * Class used to store 3D textures containing user data
  129552. */
  129553. export class RawTexture3D extends Texture {
  129554. /** Gets or sets the texture format to use */
  129555. format: number;
  129556. private _engine;
  129557. /**
  129558. * Create a new RawTexture3D
  129559. * @param data defines the data of the texture
  129560. * @param width defines the width of the texture
  129561. * @param height defines the height of the texture
  129562. * @param depth defines the depth of the texture
  129563. * @param format defines the texture format to use
  129564. * @param scene defines the hosting scene
  129565. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129566. * @param invertY defines if texture must be stored with Y axis inverted
  129567. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129568. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129569. */
  129570. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129571. /** Gets or sets the texture format to use */
  129572. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129573. /**
  129574. * Update the texture with new data
  129575. * @param data defines the data to store in the texture
  129576. */
  129577. update(data: ArrayBufferView): void;
  129578. }
  129579. }
  129580. declare module BABYLON {
  129581. /**
  129582. * Class used to store 2D array textures containing user data
  129583. */
  129584. export class RawTexture2DArray extends Texture {
  129585. /** Gets or sets the texture format to use */
  129586. format: number;
  129587. private _engine;
  129588. /**
  129589. * Create a new RawTexture2DArray
  129590. * @param data defines the data of the texture
  129591. * @param width defines the width of the texture
  129592. * @param height defines the height of the texture
  129593. * @param depth defines the number of layers of the texture
  129594. * @param format defines the texture format to use
  129595. * @param scene defines the hosting scene
  129596. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129597. * @param invertY defines if texture must be stored with Y axis inverted
  129598. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129599. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129600. */
  129601. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129602. /** Gets or sets the texture format to use */
  129603. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129604. /**
  129605. * Update the texture with new data
  129606. * @param data defines the data to store in the texture
  129607. */
  129608. update(data: ArrayBufferView): void;
  129609. }
  129610. }
  129611. declare module BABYLON {
  129612. /**
  129613. * Creates a refraction texture used by refraction channel of the standard material.
  129614. * It is like a mirror but to see through a material.
  129615. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129616. */
  129617. export class RefractionTexture extends RenderTargetTexture {
  129618. /**
  129619. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129620. * 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.
  129621. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129622. */
  129623. refractionPlane: Plane;
  129624. /**
  129625. * Define how deep under the surface we should see.
  129626. */
  129627. depth: number;
  129628. /**
  129629. * Creates a refraction texture used by refraction channel of the standard material.
  129630. * It is like a mirror but to see through a material.
  129631. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129632. * @param name Define the texture name
  129633. * @param size Define the size of the underlying texture
  129634. * @param scene Define the scene the refraction belongs to
  129635. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129636. */
  129637. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129638. /**
  129639. * Clone the refraction texture.
  129640. * @returns the cloned texture
  129641. */
  129642. clone(): RefractionTexture;
  129643. /**
  129644. * Serialize the texture to a JSON representation you could use in Parse later on
  129645. * @returns the serialized JSON representation
  129646. */
  129647. serialize(): any;
  129648. }
  129649. }
  129650. declare module BABYLON {
  129651. /**
  129652. * Defines the options related to the creation of an HtmlElementTexture
  129653. */
  129654. export interface IHtmlElementTextureOptions {
  129655. /**
  129656. * Defines wether mip maps should be created or not.
  129657. */
  129658. generateMipMaps?: boolean;
  129659. /**
  129660. * Defines the sampling mode of the texture.
  129661. */
  129662. samplingMode?: number;
  129663. /**
  129664. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129665. */
  129666. engine: Nullable<ThinEngine>;
  129667. /**
  129668. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129669. */
  129670. scene: Nullable<Scene>;
  129671. }
  129672. /**
  129673. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129674. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129675. * is automatically managed.
  129676. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129677. * in your application.
  129678. *
  129679. * As the update is not automatic, you need to call them manually.
  129680. */
  129681. export class HtmlElementTexture extends BaseTexture {
  129682. /**
  129683. * The texture URL.
  129684. */
  129685. element: HTMLVideoElement | HTMLCanvasElement;
  129686. private static readonly DefaultOptions;
  129687. private _textureMatrix;
  129688. private _engine;
  129689. private _isVideo;
  129690. private _generateMipMaps;
  129691. private _samplingMode;
  129692. /**
  129693. * Instantiates a HtmlElementTexture from the following parameters.
  129694. *
  129695. * @param name Defines the name of the texture
  129696. * @param element Defines the video or canvas the texture is filled with
  129697. * @param options Defines the other none mandatory texture creation options
  129698. */
  129699. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129700. private _createInternalTexture;
  129701. /**
  129702. * Returns the texture matrix used in most of the material.
  129703. */
  129704. getTextureMatrix(): Matrix;
  129705. /**
  129706. * Updates the content of the texture.
  129707. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129708. */
  129709. update(invertY?: Nullable<boolean>): void;
  129710. }
  129711. }
  129712. declare module BABYLON {
  129713. /**
  129714. * Defines the basic options interface of a TexturePacker Frame
  129715. */
  129716. export interface ITexturePackerFrame {
  129717. /**
  129718. * The frame ID
  129719. */
  129720. id: number;
  129721. /**
  129722. * The frames Scale
  129723. */
  129724. scale: Vector2;
  129725. /**
  129726. * The Frames offset
  129727. */
  129728. offset: Vector2;
  129729. }
  129730. /**
  129731. * This is a support class for frame Data on texture packer sets.
  129732. */
  129733. export class TexturePackerFrame implements ITexturePackerFrame {
  129734. /**
  129735. * The frame ID
  129736. */
  129737. id: number;
  129738. /**
  129739. * The frames Scale
  129740. */
  129741. scale: Vector2;
  129742. /**
  129743. * The Frames offset
  129744. */
  129745. offset: Vector2;
  129746. /**
  129747. * Initializes a texture package frame.
  129748. * @param id The numerical frame identifier
  129749. * @param scale Scalar Vector2 for UV frame
  129750. * @param offset Vector2 for the frame position in UV units.
  129751. * @returns TexturePackerFrame
  129752. */
  129753. constructor(id: number, scale: Vector2, offset: Vector2);
  129754. }
  129755. }
  129756. declare module BABYLON {
  129757. /**
  129758. * Defines the basic options interface of a TexturePacker
  129759. */
  129760. export interface ITexturePackerOptions {
  129761. /**
  129762. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129763. */
  129764. map?: string[];
  129765. /**
  129766. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129767. */
  129768. uvsIn?: string;
  129769. /**
  129770. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129771. */
  129772. uvsOut?: string;
  129773. /**
  129774. * number representing the layout style. Defaults to LAYOUT_STRIP
  129775. */
  129776. layout?: number;
  129777. /**
  129778. * number of columns if using custom column count layout(2). This defaults to 4.
  129779. */
  129780. colnum?: number;
  129781. /**
  129782. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129783. */
  129784. updateInputMeshes?: boolean;
  129785. /**
  129786. * boolean flag to dispose all the source textures. Defaults to true.
  129787. */
  129788. disposeSources?: boolean;
  129789. /**
  129790. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129791. */
  129792. fillBlanks?: boolean;
  129793. /**
  129794. * string value representing the context fill style color. Defaults to 'black'.
  129795. */
  129796. customFillColor?: string;
  129797. /**
  129798. * Width and Height Value of each Frame in the TexturePacker Sets
  129799. */
  129800. frameSize?: number;
  129801. /**
  129802. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129803. */
  129804. paddingRatio?: number;
  129805. /**
  129806. * Number that declares the fill method for the padding gutter.
  129807. */
  129808. paddingMode?: number;
  129809. /**
  129810. * If in SUBUV_COLOR padding mode what color to use.
  129811. */
  129812. paddingColor?: Color3 | Color4;
  129813. }
  129814. /**
  129815. * Defines the basic interface of a TexturePacker JSON File
  129816. */
  129817. export interface ITexturePackerJSON {
  129818. /**
  129819. * The frame ID
  129820. */
  129821. name: string;
  129822. /**
  129823. * The base64 channel data
  129824. */
  129825. sets: any;
  129826. /**
  129827. * The options of the Packer
  129828. */
  129829. options: ITexturePackerOptions;
  129830. /**
  129831. * The frame data of the Packer
  129832. */
  129833. frames: Array<number>;
  129834. }
  129835. /**
  129836. * This is a support class that generates a series of packed texture sets.
  129837. * @see https://doc.babylonjs.com/babylon101/materials
  129838. */
  129839. export class TexturePacker {
  129840. /** Packer Layout Constant 0 */
  129841. static readonly LAYOUT_STRIP: number;
  129842. /** Packer Layout Constant 1 */
  129843. static readonly LAYOUT_POWER2: number;
  129844. /** Packer Layout Constant 2 */
  129845. static readonly LAYOUT_COLNUM: number;
  129846. /** Packer Layout Constant 0 */
  129847. static readonly SUBUV_WRAP: number;
  129848. /** Packer Layout Constant 1 */
  129849. static readonly SUBUV_EXTEND: number;
  129850. /** Packer Layout Constant 2 */
  129851. static readonly SUBUV_COLOR: number;
  129852. /** The Name of the Texture Package */
  129853. name: string;
  129854. /** The scene scope of the TexturePacker */
  129855. scene: Scene;
  129856. /** The Meshes to target */
  129857. meshes: AbstractMesh[];
  129858. /** Arguments passed with the Constructor */
  129859. options: ITexturePackerOptions;
  129860. /** The promise that is started upon initialization */
  129861. promise: Nullable<Promise<TexturePacker | string>>;
  129862. /** The Container object for the channel sets that are generated */
  129863. sets: object;
  129864. /** The Container array for the frames that are generated */
  129865. frames: TexturePackerFrame[];
  129866. /** The expected number of textures the system is parsing. */
  129867. private _expecting;
  129868. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129869. private _paddingValue;
  129870. /**
  129871. * Initializes a texture package series from an array of meshes or a single mesh.
  129872. * @param name The name of the package
  129873. * @param meshes The target meshes to compose the package from
  129874. * @param options The arguments that texture packer should follow while building.
  129875. * @param scene The scene which the textures are scoped to.
  129876. * @returns TexturePacker
  129877. */
  129878. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129879. /**
  129880. * Starts the package process
  129881. * @param resolve The promises resolution function
  129882. * @returns TexturePacker
  129883. */
  129884. private _createFrames;
  129885. /**
  129886. * Calculates the Size of the Channel Sets
  129887. * @returns Vector2
  129888. */
  129889. private _calculateSize;
  129890. /**
  129891. * Calculates the UV data for the frames.
  129892. * @param baseSize the base frameSize
  129893. * @param padding the base frame padding
  129894. * @param dtSize size of the Dynamic Texture for that channel
  129895. * @param dtUnits is 1/dtSize
  129896. * @param update flag to update the input meshes
  129897. */
  129898. private _calculateMeshUVFrames;
  129899. /**
  129900. * Calculates the frames Offset.
  129901. * @param index of the frame
  129902. * @returns Vector2
  129903. */
  129904. private _getFrameOffset;
  129905. /**
  129906. * Updates a Mesh to the frame data
  129907. * @param mesh that is the target
  129908. * @param frameID or the frame index
  129909. */
  129910. private _updateMeshUV;
  129911. /**
  129912. * Updates a Meshes materials to use the texture packer channels
  129913. * @param m is the mesh to target
  129914. * @param force all channels on the packer to be set.
  129915. */
  129916. private _updateTextureReferences;
  129917. /**
  129918. * Public method to set a Mesh to a frame
  129919. * @param m that is the target
  129920. * @param frameID or the frame index
  129921. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129922. */
  129923. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129924. /**
  129925. * Starts the async promise to compile the texture packer.
  129926. * @returns Promise<void>
  129927. */
  129928. processAsync(): Promise<void>;
  129929. /**
  129930. * Disposes all textures associated with this packer
  129931. */
  129932. dispose(): void;
  129933. /**
  129934. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129935. * @param imageType is the image type to use.
  129936. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129937. */
  129938. download(imageType?: string, quality?: number): void;
  129939. /**
  129940. * Public method to load a texturePacker JSON file.
  129941. * @param data of the JSON file in string format.
  129942. */
  129943. updateFromJSON(data: string): void;
  129944. }
  129945. }
  129946. declare module BABYLON {
  129947. /**
  129948. * Enum used to define the target of a block
  129949. */
  129950. export enum NodeMaterialBlockTargets {
  129951. /** Vertex shader */
  129952. Vertex = 1,
  129953. /** Fragment shader */
  129954. Fragment = 2,
  129955. /** Neutral */
  129956. Neutral = 4,
  129957. /** Vertex and Fragment */
  129958. VertexAndFragment = 3
  129959. }
  129960. }
  129961. declare module BABYLON {
  129962. /**
  129963. * Defines the kind of connection point for node based material
  129964. */
  129965. export enum NodeMaterialBlockConnectionPointTypes {
  129966. /** Float */
  129967. Float = 1,
  129968. /** Int */
  129969. Int = 2,
  129970. /** Vector2 */
  129971. Vector2 = 4,
  129972. /** Vector3 */
  129973. Vector3 = 8,
  129974. /** Vector4 */
  129975. Vector4 = 16,
  129976. /** Color3 */
  129977. Color3 = 32,
  129978. /** Color4 */
  129979. Color4 = 64,
  129980. /** Matrix */
  129981. Matrix = 128,
  129982. /** Detect type based on connection */
  129983. AutoDetect = 1024,
  129984. /** Output type that will be defined by input type */
  129985. BasedOnInput = 2048
  129986. }
  129987. }
  129988. declare module BABYLON {
  129989. /**
  129990. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129991. */
  129992. export enum NodeMaterialBlockConnectionPointMode {
  129993. /** Value is an uniform */
  129994. Uniform = 0,
  129995. /** Value is a mesh attribute */
  129996. Attribute = 1,
  129997. /** Value is a varying between vertex and fragment shaders */
  129998. Varying = 2,
  129999. /** Mode is undefined */
  130000. Undefined = 3
  130001. }
  130002. }
  130003. declare module BABYLON {
  130004. /**
  130005. * Enum used to define system values e.g. values automatically provided by the system
  130006. */
  130007. export enum NodeMaterialSystemValues {
  130008. /** World */
  130009. World = 1,
  130010. /** View */
  130011. View = 2,
  130012. /** Projection */
  130013. Projection = 3,
  130014. /** ViewProjection */
  130015. ViewProjection = 4,
  130016. /** WorldView */
  130017. WorldView = 5,
  130018. /** WorldViewProjection */
  130019. WorldViewProjection = 6,
  130020. /** CameraPosition */
  130021. CameraPosition = 7,
  130022. /** Fog Color */
  130023. FogColor = 8,
  130024. /** Delta time */
  130025. DeltaTime = 9
  130026. }
  130027. }
  130028. declare module BABYLON {
  130029. /**
  130030. * Root class for all node material optimizers
  130031. */
  130032. export class NodeMaterialOptimizer {
  130033. /**
  130034. * Function used to optimize a NodeMaterial graph
  130035. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130036. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130037. */
  130038. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130039. }
  130040. }
  130041. declare module BABYLON {
  130042. /**
  130043. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130044. */
  130045. export class TransformBlock extends NodeMaterialBlock {
  130046. /**
  130047. * Defines the value to use to complement W value to transform it to a Vector4
  130048. */
  130049. complementW: number;
  130050. /**
  130051. * Defines the value to use to complement z value to transform it to a Vector4
  130052. */
  130053. complementZ: number;
  130054. /**
  130055. * Creates a new TransformBlock
  130056. * @param name defines the block name
  130057. */
  130058. constructor(name: string);
  130059. /**
  130060. * Gets the current class name
  130061. * @returns the class name
  130062. */
  130063. getClassName(): string;
  130064. /**
  130065. * Gets the vector input
  130066. */
  130067. get vector(): NodeMaterialConnectionPoint;
  130068. /**
  130069. * Gets the output component
  130070. */
  130071. get output(): NodeMaterialConnectionPoint;
  130072. /**
  130073. * Gets the matrix transform input
  130074. */
  130075. get transform(): NodeMaterialConnectionPoint;
  130076. protected _buildBlock(state: NodeMaterialBuildState): this;
  130077. serialize(): any;
  130078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130079. protected _dumpPropertiesCode(): string;
  130080. }
  130081. }
  130082. declare module BABYLON {
  130083. /**
  130084. * Block used to output the vertex position
  130085. */
  130086. export class VertexOutputBlock extends NodeMaterialBlock {
  130087. /**
  130088. * Creates a new VertexOutputBlock
  130089. * @param name defines the block name
  130090. */
  130091. constructor(name: string);
  130092. /**
  130093. * Gets the current class name
  130094. * @returns the class name
  130095. */
  130096. getClassName(): string;
  130097. /**
  130098. * Gets the vector input component
  130099. */
  130100. get vector(): NodeMaterialConnectionPoint;
  130101. protected _buildBlock(state: NodeMaterialBuildState): this;
  130102. }
  130103. }
  130104. declare module BABYLON {
  130105. /**
  130106. * Block used to output the final color
  130107. */
  130108. export class FragmentOutputBlock extends NodeMaterialBlock {
  130109. /**
  130110. * Create a new FragmentOutputBlock
  130111. * @param name defines the block name
  130112. */
  130113. constructor(name: string);
  130114. /**
  130115. * Gets the current class name
  130116. * @returns the class name
  130117. */
  130118. getClassName(): string;
  130119. /**
  130120. * Gets the rgba input component
  130121. */
  130122. get rgba(): NodeMaterialConnectionPoint;
  130123. /**
  130124. * Gets the rgb input component
  130125. */
  130126. get rgb(): NodeMaterialConnectionPoint;
  130127. /**
  130128. * Gets the a input component
  130129. */
  130130. get a(): NodeMaterialConnectionPoint;
  130131. protected _buildBlock(state: NodeMaterialBuildState): this;
  130132. }
  130133. }
  130134. declare module BABYLON {
  130135. /**
  130136. * Block used to read a reflection texture from a sampler
  130137. */
  130138. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130139. private _define3DName;
  130140. private _defineCubicName;
  130141. private _defineExplicitName;
  130142. private _defineProjectionName;
  130143. private _defineLocalCubicName;
  130144. private _defineSphericalName;
  130145. private _definePlanarName;
  130146. private _defineEquirectangularName;
  130147. private _defineMirroredEquirectangularFixedName;
  130148. private _defineEquirectangularFixedName;
  130149. private _defineSkyboxName;
  130150. private _cubeSamplerName;
  130151. private _2DSamplerName;
  130152. private _positionUVWName;
  130153. private _directionWName;
  130154. private _reflectionCoordsName;
  130155. private _reflection2DCoordsName;
  130156. private _reflectionColorName;
  130157. private _reflectionMatrixName;
  130158. /**
  130159. * Gets or sets the texture associated with the node
  130160. */
  130161. texture: Nullable<BaseTexture>;
  130162. /**
  130163. * Create a new TextureBlock
  130164. * @param name defines the block name
  130165. */
  130166. constructor(name: string);
  130167. /**
  130168. * Gets the current class name
  130169. * @returns the class name
  130170. */
  130171. getClassName(): string;
  130172. /**
  130173. * Gets the world position input component
  130174. */
  130175. get position(): NodeMaterialConnectionPoint;
  130176. /**
  130177. * Gets the world position input component
  130178. */
  130179. get worldPosition(): NodeMaterialConnectionPoint;
  130180. /**
  130181. * Gets the world normal input component
  130182. */
  130183. get worldNormal(): NodeMaterialConnectionPoint;
  130184. /**
  130185. * Gets the world input component
  130186. */
  130187. get world(): NodeMaterialConnectionPoint;
  130188. /**
  130189. * Gets the camera (or eye) position component
  130190. */
  130191. get cameraPosition(): NodeMaterialConnectionPoint;
  130192. /**
  130193. * Gets the view input component
  130194. */
  130195. get view(): NodeMaterialConnectionPoint;
  130196. /**
  130197. * Gets the rgb output component
  130198. */
  130199. get rgb(): NodeMaterialConnectionPoint;
  130200. /**
  130201. * Gets the r output component
  130202. */
  130203. get r(): NodeMaterialConnectionPoint;
  130204. /**
  130205. * Gets the g output component
  130206. */
  130207. get g(): NodeMaterialConnectionPoint;
  130208. /**
  130209. * Gets the b output component
  130210. */
  130211. get b(): NodeMaterialConnectionPoint;
  130212. autoConfigure(material: NodeMaterial): void;
  130213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130214. isReady(): boolean;
  130215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130216. private _injectVertexCode;
  130217. private _writeOutput;
  130218. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130219. protected _dumpPropertiesCode(): string;
  130220. serialize(): any;
  130221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130222. }
  130223. }
  130224. declare module BABYLON {
  130225. /**
  130226. * Interface used to configure the node material editor
  130227. */
  130228. export interface INodeMaterialEditorOptions {
  130229. /** Define the URl to load node editor script */
  130230. editorURL?: string;
  130231. }
  130232. /** @hidden */
  130233. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130234. NORMAL: boolean;
  130235. TANGENT: boolean;
  130236. UV1: boolean;
  130237. /** BONES */
  130238. NUM_BONE_INFLUENCERS: number;
  130239. BonesPerMesh: number;
  130240. BONETEXTURE: boolean;
  130241. /** MORPH TARGETS */
  130242. MORPHTARGETS: boolean;
  130243. MORPHTARGETS_NORMAL: boolean;
  130244. MORPHTARGETS_TANGENT: boolean;
  130245. MORPHTARGETS_UV: boolean;
  130246. NUM_MORPH_INFLUENCERS: number;
  130247. /** IMAGE PROCESSING */
  130248. IMAGEPROCESSING: boolean;
  130249. VIGNETTE: boolean;
  130250. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130251. VIGNETTEBLENDMODEOPAQUE: boolean;
  130252. TONEMAPPING: boolean;
  130253. TONEMAPPING_ACES: boolean;
  130254. CONTRAST: boolean;
  130255. EXPOSURE: boolean;
  130256. COLORCURVES: boolean;
  130257. COLORGRADING: boolean;
  130258. COLORGRADING3D: boolean;
  130259. SAMPLER3DGREENDEPTH: boolean;
  130260. SAMPLER3DBGRMAP: boolean;
  130261. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130262. /** MISC. */
  130263. BUMPDIRECTUV: number;
  130264. constructor();
  130265. setValue(name: string, value: boolean): void;
  130266. }
  130267. /**
  130268. * Class used to configure NodeMaterial
  130269. */
  130270. export interface INodeMaterialOptions {
  130271. /**
  130272. * Defines if blocks should emit comments
  130273. */
  130274. emitComments: boolean;
  130275. }
  130276. /**
  130277. * Class used to create a node based material built by assembling shader blocks
  130278. */
  130279. export class NodeMaterial extends PushMaterial {
  130280. private static _BuildIdGenerator;
  130281. private _options;
  130282. private _vertexCompilationState;
  130283. private _fragmentCompilationState;
  130284. private _sharedData;
  130285. private _buildId;
  130286. private _buildWasSuccessful;
  130287. private _cachedWorldViewMatrix;
  130288. private _cachedWorldViewProjectionMatrix;
  130289. private _optimizers;
  130290. private _animationFrame;
  130291. /** Define the Url to load node editor script */
  130292. static EditorURL: string;
  130293. /** Define the Url to load snippets */
  130294. static SnippetUrl: string;
  130295. private BJSNODEMATERIALEDITOR;
  130296. /** Get the inspector from bundle or global */
  130297. private _getGlobalNodeMaterialEditor;
  130298. /**
  130299. * Gets or sets data used by visual editor
  130300. * @see https://nme.babylonjs.com
  130301. */
  130302. editorData: any;
  130303. /**
  130304. * 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)
  130305. */
  130306. ignoreAlpha: boolean;
  130307. /**
  130308. * Defines the maximum number of lights that can be used in the material
  130309. */
  130310. maxSimultaneousLights: number;
  130311. /**
  130312. * Observable raised when the material is built
  130313. */
  130314. onBuildObservable: Observable<NodeMaterial>;
  130315. /**
  130316. * Gets or sets the root nodes of the material vertex shader
  130317. */
  130318. _vertexOutputNodes: NodeMaterialBlock[];
  130319. /**
  130320. * Gets or sets the root nodes of the material fragment (pixel) shader
  130321. */
  130322. _fragmentOutputNodes: NodeMaterialBlock[];
  130323. /** Gets or sets options to control the node material overall behavior */
  130324. get options(): INodeMaterialOptions;
  130325. set options(options: INodeMaterialOptions);
  130326. /**
  130327. * Default configuration related to image processing available in the standard Material.
  130328. */
  130329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130330. /**
  130331. * Gets the image processing configuration used either in this material.
  130332. */
  130333. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130334. /**
  130335. * Sets the Default image processing configuration used either in the this material.
  130336. *
  130337. * If sets to null, the scene one is in use.
  130338. */
  130339. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130340. /**
  130341. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130342. */
  130343. attachedBlocks: NodeMaterialBlock[];
  130344. /**
  130345. * Create a new node based material
  130346. * @param name defines the material name
  130347. * @param scene defines the hosting scene
  130348. * @param options defines creation option
  130349. */
  130350. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130351. /**
  130352. * Gets the current class name of the material e.g. "NodeMaterial"
  130353. * @returns the class name
  130354. */
  130355. getClassName(): string;
  130356. /**
  130357. * Keep track of the image processing observer to allow dispose and replace.
  130358. */
  130359. private _imageProcessingObserver;
  130360. /**
  130361. * Attaches a new image processing configuration to the Standard Material.
  130362. * @param configuration
  130363. */
  130364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130365. /**
  130366. * Get a block by its name
  130367. * @param name defines the name of the block to retrieve
  130368. * @returns the required block or null if not found
  130369. */
  130370. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130371. /**
  130372. * Get a block by its name
  130373. * @param predicate defines the predicate used to find the good candidate
  130374. * @returns the required block or null if not found
  130375. */
  130376. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130377. /**
  130378. * Get an input block by its name
  130379. * @param predicate defines the predicate used to find the good candidate
  130380. * @returns the required input block or null if not found
  130381. */
  130382. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130383. /**
  130384. * Gets the list of input blocks attached to this material
  130385. * @returns an array of InputBlocks
  130386. */
  130387. getInputBlocks(): InputBlock[];
  130388. /**
  130389. * Adds a new optimizer to the list of optimizers
  130390. * @param optimizer defines the optimizers to add
  130391. * @returns the current material
  130392. */
  130393. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130394. /**
  130395. * Remove an optimizer from the list of optimizers
  130396. * @param optimizer defines the optimizers to remove
  130397. * @returns the current material
  130398. */
  130399. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130400. /**
  130401. * Add a new block to the list of output nodes
  130402. * @param node defines the node to add
  130403. * @returns the current material
  130404. */
  130405. addOutputNode(node: NodeMaterialBlock): this;
  130406. /**
  130407. * Remove a block from the list of root nodes
  130408. * @param node defines the node to remove
  130409. * @returns the current material
  130410. */
  130411. removeOutputNode(node: NodeMaterialBlock): this;
  130412. private _addVertexOutputNode;
  130413. private _removeVertexOutputNode;
  130414. private _addFragmentOutputNode;
  130415. private _removeFragmentOutputNode;
  130416. /**
  130417. * Specifies if the material will require alpha blending
  130418. * @returns a boolean specifying if alpha blending is needed
  130419. */
  130420. needAlphaBlending(): boolean;
  130421. /**
  130422. * Specifies if this material should be rendered in alpha test mode
  130423. * @returns a boolean specifying if an alpha test is needed.
  130424. */
  130425. needAlphaTesting(): boolean;
  130426. private _initializeBlock;
  130427. private _resetDualBlocks;
  130428. /**
  130429. * Remove a block from the current node material
  130430. * @param block defines the block to remove
  130431. */
  130432. removeBlock(block: NodeMaterialBlock): void;
  130433. /**
  130434. * Build the material and generates the inner effect
  130435. * @param verbose defines if the build should log activity
  130436. */
  130437. build(verbose?: boolean): void;
  130438. /**
  130439. * Runs an otpimization phase to try to improve the shader code
  130440. */
  130441. optimize(): void;
  130442. private _prepareDefinesForAttributes;
  130443. /**
  130444. * Get if the submesh is ready to be used and all its information available.
  130445. * Child classes can use it to update shaders
  130446. * @param mesh defines the mesh to check
  130447. * @param subMesh defines which submesh to check
  130448. * @param useInstances specifies that instances should be used
  130449. * @returns a boolean indicating that the submesh is ready or not
  130450. */
  130451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130452. /**
  130453. * Get a string representing the shaders built by the current node graph
  130454. */
  130455. get compiledShaders(): string;
  130456. /**
  130457. * Binds the world matrix to the material
  130458. * @param world defines the world transformation matrix
  130459. */
  130460. bindOnlyWorldMatrix(world: Matrix): void;
  130461. /**
  130462. * Binds the submesh to this material by preparing the effect and shader to draw
  130463. * @param world defines the world transformation matrix
  130464. * @param mesh defines the mesh containing the submesh
  130465. * @param subMesh defines the submesh to bind the material to
  130466. */
  130467. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130468. /**
  130469. * Gets the active textures from the material
  130470. * @returns an array of textures
  130471. */
  130472. getActiveTextures(): BaseTexture[];
  130473. /**
  130474. * Gets the list of texture blocks
  130475. * @returns an array of texture blocks
  130476. */
  130477. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130478. /**
  130479. * Specifies if the material uses a texture
  130480. * @param texture defines the texture to check against the material
  130481. * @returns a boolean specifying if the material uses the texture
  130482. */
  130483. hasTexture(texture: BaseTexture): boolean;
  130484. /**
  130485. * Disposes the material
  130486. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130487. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130488. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130489. */
  130490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130491. /** Creates the node editor window. */
  130492. private _createNodeEditor;
  130493. /**
  130494. * Launch the node material editor
  130495. * @param config Define the configuration of the editor
  130496. * @return a promise fulfilled when the node editor is visible
  130497. */
  130498. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130499. /**
  130500. * Clear the current material
  130501. */
  130502. clear(): void;
  130503. /**
  130504. * Clear the current material and set it to a default state
  130505. */
  130506. setToDefault(): void;
  130507. /**
  130508. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130509. * @param url defines the url to load from
  130510. * @returns a promise that will fullfil when the material is fully loaded
  130511. */
  130512. loadAsync(url: string): Promise<void>;
  130513. private _gatherBlocks;
  130514. /**
  130515. * Generate a string containing the code declaration required to create an equivalent of this material
  130516. * @returns a string
  130517. */
  130518. generateCode(): string;
  130519. /**
  130520. * Serializes this material in a JSON representation
  130521. * @returns the serialized material object
  130522. */
  130523. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130524. private _restoreConnections;
  130525. /**
  130526. * Clear the current graph and load a new one from a serialization object
  130527. * @param source defines the JSON representation of the material
  130528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130529. */
  130530. loadFromSerialization(source: any, rootUrl?: string): void;
  130531. /**
  130532. * Creates a node material from parsed material data
  130533. * @param source defines the JSON representation of the material
  130534. * @param scene defines the hosting scene
  130535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130536. * @returns a new node material
  130537. */
  130538. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130539. /**
  130540. * Creates a node material from a snippet saved in a remote file
  130541. * @param name defines the name of the material to create
  130542. * @param url defines the url to load from
  130543. * @param scene defines the hosting scene
  130544. * @returns a promise that will resolve to the new node material
  130545. */
  130546. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130547. /**
  130548. * Creates a node material from a snippet saved by the node material editor
  130549. * @param snippetId defines the snippet to load
  130550. * @param scene defines the hosting scene
  130551. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130552. * @returns a promise that will resolve to the new node material
  130553. */
  130554. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130555. /**
  130556. * Creates a new node material set to default basic configuration
  130557. * @param name defines the name of the material
  130558. * @param scene defines the hosting scene
  130559. * @returns a new NodeMaterial
  130560. */
  130561. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130562. }
  130563. }
  130564. declare module BABYLON {
  130565. /**
  130566. * Block used to read a texture from a sampler
  130567. */
  130568. export class TextureBlock extends NodeMaterialBlock {
  130569. private _defineName;
  130570. private _linearDefineName;
  130571. private _tempTextureRead;
  130572. private _samplerName;
  130573. private _transformedUVName;
  130574. private _textureTransformName;
  130575. private _textureInfoName;
  130576. private _mainUVName;
  130577. private _mainUVDefineName;
  130578. /**
  130579. * Gets or sets the texture associated with the node
  130580. */
  130581. texture: Nullable<Texture>;
  130582. /**
  130583. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130584. */
  130585. convertToGammaSpace: boolean;
  130586. /**
  130587. * Create a new TextureBlock
  130588. * @param name defines the block name
  130589. */
  130590. constructor(name: string);
  130591. /**
  130592. * Gets the current class name
  130593. * @returns the class name
  130594. */
  130595. getClassName(): string;
  130596. /**
  130597. * Gets the uv input component
  130598. */
  130599. get uv(): NodeMaterialConnectionPoint;
  130600. /**
  130601. * Gets the rgba output component
  130602. */
  130603. get rgba(): NodeMaterialConnectionPoint;
  130604. /**
  130605. * Gets the rgb output component
  130606. */
  130607. get rgb(): NodeMaterialConnectionPoint;
  130608. /**
  130609. * Gets the r output component
  130610. */
  130611. get r(): NodeMaterialConnectionPoint;
  130612. /**
  130613. * Gets the g output component
  130614. */
  130615. get g(): NodeMaterialConnectionPoint;
  130616. /**
  130617. * Gets the b output component
  130618. */
  130619. get b(): NodeMaterialConnectionPoint;
  130620. /**
  130621. * Gets the a output component
  130622. */
  130623. get a(): NodeMaterialConnectionPoint;
  130624. get target(): NodeMaterialBlockTargets;
  130625. autoConfigure(material: NodeMaterial): void;
  130626. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130628. isReady(): boolean;
  130629. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130630. private get _isMixed();
  130631. private _injectVertexCode;
  130632. private _writeTextureRead;
  130633. private _writeOutput;
  130634. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130635. protected _dumpPropertiesCode(): string;
  130636. serialize(): any;
  130637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130638. }
  130639. }
  130640. declare module BABYLON {
  130641. /**
  130642. * Class used to store shared data between 2 NodeMaterialBuildState
  130643. */
  130644. export class NodeMaterialBuildStateSharedData {
  130645. /**
  130646. * Gets the list of emitted varyings
  130647. */
  130648. temps: string[];
  130649. /**
  130650. * Gets the list of emitted varyings
  130651. */
  130652. varyings: string[];
  130653. /**
  130654. * Gets the varying declaration string
  130655. */
  130656. varyingDeclaration: string;
  130657. /**
  130658. * Input blocks
  130659. */
  130660. inputBlocks: InputBlock[];
  130661. /**
  130662. * Input blocks
  130663. */
  130664. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130665. /**
  130666. * Bindable blocks (Blocks that need to set data to the effect)
  130667. */
  130668. bindableBlocks: NodeMaterialBlock[];
  130669. /**
  130670. * List of blocks that can provide a compilation fallback
  130671. */
  130672. blocksWithFallbacks: NodeMaterialBlock[];
  130673. /**
  130674. * List of blocks that can provide a define update
  130675. */
  130676. blocksWithDefines: NodeMaterialBlock[];
  130677. /**
  130678. * List of blocks that can provide a repeatable content
  130679. */
  130680. repeatableContentBlocks: NodeMaterialBlock[];
  130681. /**
  130682. * List of blocks that can provide a dynamic list of uniforms
  130683. */
  130684. dynamicUniformBlocks: NodeMaterialBlock[];
  130685. /**
  130686. * List of blocks that can block the isReady function for the material
  130687. */
  130688. blockingBlocks: NodeMaterialBlock[];
  130689. /**
  130690. * Gets the list of animated inputs
  130691. */
  130692. animatedInputs: InputBlock[];
  130693. /**
  130694. * Build Id used to avoid multiple recompilations
  130695. */
  130696. buildId: number;
  130697. /** List of emitted variables */
  130698. variableNames: {
  130699. [key: string]: number;
  130700. };
  130701. /** List of emitted defines */
  130702. defineNames: {
  130703. [key: string]: number;
  130704. };
  130705. /** Should emit comments? */
  130706. emitComments: boolean;
  130707. /** Emit build activity */
  130708. verbose: boolean;
  130709. /** Gets or sets the hosting scene */
  130710. scene: Scene;
  130711. /**
  130712. * Gets the compilation hints emitted at compilation time
  130713. */
  130714. hints: {
  130715. needWorldViewMatrix: boolean;
  130716. needWorldViewProjectionMatrix: boolean;
  130717. needAlphaBlending: boolean;
  130718. needAlphaTesting: boolean;
  130719. };
  130720. /**
  130721. * List of compilation checks
  130722. */
  130723. checks: {
  130724. emitVertex: boolean;
  130725. emitFragment: boolean;
  130726. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130727. };
  130728. /** Creates a new shared data */
  130729. constructor();
  130730. /**
  130731. * Emits console errors and exceptions if there is a failing check
  130732. */
  130733. emitErrors(): void;
  130734. }
  130735. }
  130736. declare module BABYLON {
  130737. /**
  130738. * Class used to store node based material build state
  130739. */
  130740. export class NodeMaterialBuildState {
  130741. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130742. supportUniformBuffers: boolean;
  130743. /**
  130744. * Gets the list of emitted attributes
  130745. */
  130746. attributes: string[];
  130747. /**
  130748. * Gets the list of emitted uniforms
  130749. */
  130750. uniforms: string[];
  130751. /**
  130752. * Gets the list of emitted constants
  130753. */
  130754. constants: string[];
  130755. /**
  130756. * Gets the list of emitted samplers
  130757. */
  130758. samplers: string[];
  130759. /**
  130760. * Gets the list of emitted functions
  130761. */
  130762. functions: {
  130763. [key: string]: string;
  130764. };
  130765. /**
  130766. * Gets the list of emitted extensions
  130767. */
  130768. extensions: {
  130769. [key: string]: string;
  130770. };
  130771. /**
  130772. * Gets the target of the compilation state
  130773. */
  130774. target: NodeMaterialBlockTargets;
  130775. /**
  130776. * Gets the list of emitted counters
  130777. */
  130778. counters: {
  130779. [key: string]: number;
  130780. };
  130781. /**
  130782. * Shared data between multiple NodeMaterialBuildState instances
  130783. */
  130784. sharedData: NodeMaterialBuildStateSharedData;
  130785. /** @hidden */
  130786. _vertexState: NodeMaterialBuildState;
  130787. /** @hidden */
  130788. _attributeDeclaration: string;
  130789. /** @hidden */
  130790. _uniformDeclaration: string;
  130791. /** @hidden */
  130792. _constantDeclaration: string;
  130793. /** @hidden */
  130794. _samplerDeclaration: string;
  130795. /** @hidden */
  130796. _varyingTransfer: string;
  130797. private _repeatableContentAnchorIndex;
  130798. /** @hidden */
  130799. _builtCompilationString: string;
  130800. /**
  130801. * Gets the emitted compilation strings
  130802. */
  130803. compilationString: string;
  130804. /**
  130805. * Finalize the compilation strings
  130806. * @param state defines the current compilation state
  130807. */
  130808. finalize(state: NodeMaterialBuildState): void;
  130809. /** @hidden */
  130810. get _repeatableContentAnchor(): string;
  130811. /** @hidden */
  130812. _getFreeVariableName(prefix: string): string;
  130813. /** @hidden */
  130814. _getFreeDefineName(prefix: string): string;
  130815. /** @hidden */
  130816. _excludeVariableName(name: string): void;
  130817. /** @hidden */
  130818. _emit2DSampler(name: string): void;
  130819. /** @hidden */
  130820. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130821. /** @hidden */
  130822. _emitExtension(name: string, extension: string): void;
  130823. /** @hidden */
  130824. _emitFunction(name: string, code: string, comments: string): void;
  130825. /** @hidden */
  130826. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130827. replaceStrings?: {
  130828. search: RegExp;
  130829. replace: string;
  130830. }[];
  130831. repeatKey?: string;
  130832. }): string;
  130833. /** @hidden */
  130834. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130835. repeatKey?: string;
  130836. removeAttributes?: boolean;
  130837. removeUniforms?: boolean;
  130838. removeVaryings?: boolean;
  130839. removeIfDef?: boolean;
  130840. replaceStrings?: {
  130841. search: RegExp;
  130842. replace: string;
  130843. }[];
  130844. }, storeKey?: string): void;
  130845. /** @hidden */
  130846. _registerTempVariable(name: string): boolean;
  130847. /** @hidden */
  130848. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130849. /** @hidden */
  130850. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130851. /** @hidden */
  130852. _emitFloat(value: number): string;
  130853. }
  130854. }
  130855. declare module BABYLON {
  130856. /**
  130857. * Defines a block that can be used inside a node based material
  130858. */
  130859. export class NodeMaterialBlock {
  130860. private _buildId;
  130861. private _buildTarget;
  130862. private _target;
  130863. private _isFinalMerger;
  130864. private _isInput;
  130865. protected _isUnique: boolean;
  130866. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130867. inputsAreExclusive: boolean;
  130868. /** @hidden */
  130869. _codeVariableName: string;
  130870. /** @hidden */
  130871. _inputs: NodeMaterialConnectionPoint[];
  130872. /** @hidden */
  130873. _outputs: NodeMaterialConnectionPoint[];
  130874. /** @hidden */
  130875. _preparationId: number;
  130876. /**
  130877. * Gets or sets the name of the block
  130878. */
  130879. name: string;
  130880. /**
  130881. * Gets or sets the unique id of the node
  130882. */
  130883. uniqueId: number;
  130884. /**
  130885. * Gets or sets the comments associated with this block
  130886. */
  130887. comments: string;
  130888. /**
  130889. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130890. */
  130891. get isUnique(): boolean;
  130892. /**
  130893. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130894. */
  130895. get isFinalMerger(): boolean;
  130896. /**
  130897. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130898. */
  130899. get isInput(): boolean;
  130900. /**
  130901. * Gets or sets the build Id
  130902. */
  130903. get buildId(): number;
  130904. set buildId(value: number);
  130905. /**
  130906. * Gets or sets the target of the block
  130907. */
  130908. get target(): NodeMaterialBlockTargets;
  130909. set target(value: NodeMaterialBlockTargets);
  130910. /**
  130911. * Gets the list of input points
  130912. */
  130913. get inputs(): NodeMaterialConnectionPoint[];
  130914. /** Gets the list of output points */
  130915. get outputs(): NodeMaterialConnectionPoint[];
  130916. /**
  130917. * Find an input by its name
  130918. * @param name defines the name of the input to look for
  130919. * @returns the input or null if not found
  130920. */
  130921. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130922. /**
  130923. * Find an output by its name
  130924. * @param name defines the name of the outputto look for
  130925. * @returns the output or null if not found
  130926. */
  130927. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130928. /**
  130929. * Creates a new NodeMaterialBlock
  130930. * @param name defines the block name
  130931. * @param target defines the target of that block (Vertex by default)
  130932. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130933. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130934. */
  130935. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130936. /**
  130937. * Initialize the block and prepare the context for build
  130938. * @param state defines the state that will be used for the build
  130939. */
  130940. initialize(state: NodeMaterialBuildState): void;
  130941. /**
  130942. * Bind data to effect. Will only be called for blocks with isBindable === true
  130943. * @param effect defines the effect to bind data to
  130944. * @param nodeMaterial defines the hosting NodeMaterial
  130945. * @param mesh defines the mesh that will be rendered
  130946. */
  130947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130948. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130949. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130950. protected _writeFloat(value: number): string;
  130951. /**
  130952. * Gets the current class name e.g. "NodeMaterialBlock"
  130953. * @returns the class name
  130954. */
  130955. getClassName(): string;
  130956. /**
  130957. * Register a new input. Must be called inside a block constructor
  130958. * @param name defines the connection point name
  130959. * @param type defines the connection point type
  130960. * @param isOptional defines a boolean indicating that this input can be omitted
  130961. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130962. * @returns the current block
  130963. */
  130964. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130965. /**
  130966. * Register a new output. Must be called inside a block constructor
  130967. * @param name defines the connection point name
  130968. * @param type defines the connection point type
  130969. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130970. * @returns the current block
  130971. */
  130972. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130973. /**
  130974. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130975. * @param forOutput defines an optional connection point to check compatibility with
  130976. * @returns the first available input or null
  130977. */
  130978. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130979. /**
  130980. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130981. * @param forBlock defines an optional block to check compatibility with
  130982. * @returns the first available input or null
  130983. */
  130984. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130985. /**
  130986. * Gets the sibling of the given output
  130987. * @param current defines the current output
  130988. * @returns the next output in the list or null
  130989. */
  130990. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130991. /**
  130992. * Connect current block with another block
  130993. * @param other defines the block to connect with
  130994. * @param options define the various options to help pick the right connections
  130995. * @returns the current block
  130996. */
  130997. connectTo(other: NodeMaterialBlock, options?: {
  130998. input?: string;
  130999. output?: string;
  131000. outputSwizzle?: string;
  131001. }): this | undefined;
  131002. protected _buildBlock(state: NodeMaterialBuildState): void;
  131003. /**
  131004. * Add uniforms, samplers and uniform buffers at compilation time
  131005. * @param state defines the state to update
  131006. * @param nodeMaterial defines the node material requesting the update
  131007. * @param defines defines the material defines to update
  131008. * @param uniformBuffers defines the list of uniform buffer names
  131009. */
  131010. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131011. /**
  131012. * Add potential fallbacks if shader compilation fails
  131013. * @param mesh defines the mesh to be rendered
  131014. * @param fallbacks defines the current prioritized list of fallbacks
  131015. */
  131016. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131017. /**
  131018. * Initialize defines for shader compilation
  131019. * @param mesh defines the mesh to be rendered
  131020. * @param nodeMaterial defines the node material requesting the update
  131021. * @param defines defines the material defines to update
  131022. * @param useInstances specifies that instances should be used
  131023. */
  131024. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131025. /**
  131026. * Update defines for shader compilation
  131027. * @param mesh defines the mesh to be rendered
  131028. * @param nodeMaterial defines the node material requesting the update
  131029. * @param defines defines the material defines to update
  131030. * @param useInstances specifies that instances should be used
  131031. */
  131032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131033. /**
  131034. * Lets the block try to connect some inputs automatically
  131035. * @param material defines the hosting NodeMaterial
  131036. */
  131037. autoConfigure(material: NodeMaterial): void;
  131038. /**
  131039. * Function called when a block is declared as repeatable content generator
  131040. * @param vertexShaderState defines the current compilation state for the vertex shader
  131041. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131042. * @param mesh defines the mesh to be rendered
  131043. * @param defines defines the material defines to update
  131044. */
  131045. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131046. /**
  131047. * Checks if the block is ready
  131048. * @param mesh defines the mesh to be rendered
  131049. * @param nodeMaterial defines the node material requesting the update
  131050. * @param defines defines the material defines to update
  131051. * @param useInstances specifies that instances should be used
  131052. * @returns true if the block is ready
  131053. */
  131054. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131055. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131056. private _processBuild;
  131057. /**
  131058. * Compile the current node and generate the shader code
  131059. * @param state defines the current compilation state (uniforms, samplers, current string)
  131060. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131061. * @returns true if already built
  131062. */
  131063. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131064. protected _inputRename(name: string): string;
  131065. protected _outputRename(name: string): string;
  131066. protected _dumpPropertiesCode(): string;
  131067. /** @hidden */
  131068. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131069. /** @hidden */
  131070. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131071. /**
  131072. * Clone the current block to a new identical block
  131073. * @param scene defines the hosting scene
  131074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131075. * @returns a copy of the current block
  131076. */
  131077. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131078. /**
  131079. * Serializes this block in a JSON representation
  131080. * @returns the serialized block object
  131081. */
  131082. serialize(): any;
  131083. /** @hidden */
  131084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131085. /**
  131086. * Release resources
  131087. */
  131088. dispose(): void;
  131089. }
  131090. }
  131091. declare module BABYLON {
  131092. /**
  131093. * Enum defining the type of animations supported by InputBlock
  131094. */
  131095. export enum AnimatedInputBlockTypes {
  131096. /** No animation */
  131097. None = 0,
  131098. /** Time based animation. Will only work for floats */
  131099. Time = 1
  131100. }
  131101. }
  131102. declare module BABYLON {
  131103. /**
  131104. * Block used to expose an input value
  131105. */
  131106. export class InputBlock extends NodeMaterialBlock {
  131107. private _mode;
  131108. private _associatedVariableName;
  131109. private _storedValue;
  131110. private _valueCallback;
  131111. private _type;
  131112. private _animationType;
  131113. /** Gets or set a value used to limit the range of float values */
  131114. min: number;
  131115. /** Gets or set a value used to limit the range of float values */
  131116. max: number;
  131117. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131118. isBoolean: boolean;
  131119. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131120. matrixMode: number;
  131121. /** @hidden */
  131122. _systemValue: Nullable<NodeMaterialSystemValues>;
  131123. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131124. visibleInInspector: boolean;
  131125. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131126. isConstant: boolean;
  131127. /** Gets or sets the group to use to display this block in the Inspector */
  131128. groupInInspector: string;
  131129. /**
  131130. * Gets or sets the connection point type (default is float)
  131131. */
  131132. get type(): NodeMaterialBlockConnectionPointTypes;
  131133. /**
  131134. * Creates a new InputBlock
  131135. * @param name defines the block name
  131136. * @param target defines the target of that block (Vertex by default)
  131137. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131138. */
  131139. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131140. /**
  131141. * Gets the output component
  131142. */
  131143. get output(): NodeMaterialConnectionPoint;
  131144. /**
  131145. * Set the source of this connection point to a vertex attribute
  131146. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131147. * @returns the current connection point
  131148. */
  131149. setAsAttribute(attributeName?: string): InputBlock;
  131150. /**
  131151. * Set the source of this connection point to a system value
  131152. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131153. * @returns the current connection point
  131154. */
  131155. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131156. /**
  131157. * Gets or sets the value of that point.
  131158. * Please note that this value will be ignored if valueCallback is defined
  131159. */
  131160. get value(): any;
  131161. set value(value: any);
  131162. /**
  131163. * Gets or sets a callback used to get the value of that point.
  131164. * Please note that setting this value will force the connection point to ignore the value property
  131165. */
  131166. get valueCallback(): () => any;
  131167. set valueCallback(value: () => any);
  131168. /**
  131169. * Gets or sets the associated variable name in the shader
  131170. */
  131171. get associatedVariableName(): string;
  131172. set associatedVariableName(value: string);
  131173. /** Gets or sets the type of animation applied to the input */
  131174. get animationType(): AnimatedInputBlockTypes;
  131175. set animationType(value: AnimatedInputBlockTypes);
  131176. /**
  131177. * Gets a boolean indicating that this connection point not defined yet
  131178. */
  131179. get isUndefined(): boolean;
  131180. /**
  131181. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131182. * In this case the connection point name must be the name of the uniform to use.
  131183. * Can only be set on inputs
  131184. */
  131185. get isUniform(): boolean;
  131186. set isUniform(value: boolean);
  131187. /**
  131188. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131189. * In this case the connection point name must be the name of the attribute to use
  131190. * Can only be set on inputs
  131191. */
  131192. get isAttribute(): boolean;
  131193. set isAttribute(value: boolean);
  131194. /**
  131195. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131196. * Can only be set on exit points
  131197. */
  131198. get isVarying(): boolean;
  131199. set isVarying(value: boolean);
  131200. /**
  131201. * Gets a boolean indicating that the current connection point is a system value
  131202. */
  131203. get isSystemValue(): boolean;
  131204. /**
  131205. * Gets or sets the current well known value or null if not defined as a system value
  131206. */
  131207. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131208. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131209. /**
  131210. * Gets the current class name
  131211. * @returns the class name
  131212. */
  131213. getClassName(): string;
  131214. /**
  131215. * Animate the input if animationType !== None
  131216. * @param scene defines the rendering scene
  131217. */
  131218. animate(scene: Scene): void;
  131219. private _emitDefine;
  131220. initialize(state: NodeMaterialBuildState): void;
  131221. /**
  131222. * Set the input block to its default value (based on its type)
  131223. */
  131224. setDefaultValue(): void;
  131225. private _emitConstant;
  131226. private _emit;
  131227. /** @hidden */
  131228. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131229. /** @hidden */
  131230. _transmit(effect: Effect, scene: Scene): void;
  131231. protected _buildBlock(state: NodeMaterialBuildState): void;
  131232. protected _dumpPropertiesCode(): string;
  131233. serialize(): any;
  131234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131235. }
  131236. }
  131237. declare module BABYLON {
  131238. /**
  131239. * Enum used to define the compatibility state between two connection points
  131240. */
  131241. export enum NodeMaterialConnectionPointCompatibilityStates {
  131242. /** Points are compatibles */
  131243. Compatible = 0,
  131244. /** Points are incompatible because of their types */
  131245. TypeIncompatible = 1,
  131246. /** Points are incompatible because of their targets (vertex vs fragment) */
  131247. TargetIncompatible = 2
  131248. }
  131249. /**
  131250. * Defines the direction of a connection point
  131251. */
  131252. export enum NodeMaterialConnectionPointDirection {
  131253. /** Input */
  131254. Input = 0,
  131255. /** Output */
  131256. Output = 1
  131257. }
  131258. /**
  131259. * Defines a connection point for a block
  131260. */
  131261. export class NodeMaterialConnectionPoint {
  131262. /** @hidden */
  131263. _ownerBlock: NodeMaterialBlock;
  131264. /** @hidden */
  131265. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131266. private _endpoints;
  131267. private _associatedVariableName;
  131268. private _direction;
  131269. /** @hidden */
  131270. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131271. /** @hidden */
  131272. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131273. private _type;
  131274. /** @hidden */
  131275. _enforceAssociatedVariableName: boolean;
  131276. /** Gets the direction of the point */
  131277. get direction(): NodeMaterialConnectionPointDirection;
  131278. /**
  131279. * Gets or sets the additional types supported by this connection point
  131280. */
  131281. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131282. /**
  131283. * Gets or sets the additional types excluded by this connection point
  131284. */
  131285. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131286. /**
  131287. * Observable triggered when this point is connected
  131288. */
  131289. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131290. /**
  131291. * Gets or sets the associated variable name in the shader
  131292. */
  131293. get associatedVariableName(): string;
  131294. set associatedVariableName(value: string);
  131295. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131296. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131297. /**
  131298. * Gets or sets the connection point type (default is float)
  131299. */
  131300. get type(): NodeMaterialBlockConnectionPointTypes;
  131301. set type(value: NodeMaterialBlockConnectionPointTypes);
  131302. /**
  131303. * Gets or sets the connection point name
  131304. */
  131305. name: string;
  131306. /**
  131307. * Gets or sets a boolean indicating that this connection point can be omitted
  131308. */
  131309. isOptional: boolean;
  131310. /**
  131311. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131312. */
  131313. define: string;
  131314. /** @hidden */
  131315. _prioritizeVertex: boolean;
  131316. private _target;
  131317. /** Gets or sets the target of that connection point */
  131318. get target(): NodeMaterialBlockTargets;
  131319. set target(value: NodeMaterialBlockTargets);
  131320. /**
  131321. * Gets a boolean indicating that the current point is connected
  131322. */
  131323. get isConnected(): boolean;
  131324. /**
  131325. * Gets a boolean indicating that the current point is connected to an input block
  131326. */
  131327. get isConnectedToInputBlock(): boolean;
  131328. /**
  131329. * Gets a the connected input block (if any)
  131330. */
  131331. get connectInputBlock(): Nullable<InputBlock>;
  131332. /** Get the other side of the connection (if any) */
  131333. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131334. /** Get the block that owns this connection point */
  131335. get ownerBlock(): NodeMaterialBlock;
  131336. /** Get the block connected on the other side of this connection (if any) */
  131337. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131338. /** Get the block connected on the endpoints of this connection (if any) */
  131339. get connectedBlocks(): Array<NodeMaterialBlock>;
  131340. /** Gets the list of connected endpoints */
  131341. get endpoints(): NodeMaterialConnectionPoint[];
  131342. /** Gets a boolean indicating if that output point is connected to at least one input */
  131343. get hasEndpoints(): boolean;
  131344. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131345. get isConnectedInVertexShader(): boolean;
  131346. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131347. get isConnectedInFragmentShader(): boolean;
  131348. /**
  131349. * Creates a new connection point
  131350. * @param name defines the connection point name
  131351. * @param ownerBlock defines the block hosting this connection point
  131352. * @param direction defines the direction of the connection point
  131353. */
  131354. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131355. /**
  131356. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131357. * @returns the class name
  131358. */
  131359. getClassName(): string;
  131360. /**
  131361. * Gets a boolean indicating if the current point can be connected to another point
  131362. * @param connectionPoint defines the other connection point
  131363. * @returns a boolean
  131364. */
  131365. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131366. /**
  131367. * Gets a number indicating if the current point can be connected to another point
  131368. * @param connectionPoint defines the other connection point
  131369. * @returns a number defining the compatibility state
  131370. */
  131371. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131372. /**
  131373. * Connect this point to another connection point
  131374. * @param connectionPoint defines the other connection point
  131375. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131376. * @returns the current connection point
  131377. */
  131378. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131379. /**
  131380. * Disconnect this point from one of his endpoint
  131381. * @param endpoint defines the other connection point
  131382. * @returns the current connection point
  131383. */
  131384. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131385. /**
  131386. * Serializes this point in a JSON representation
  131387. * @returns the serialized point object
  131388. */
  131389. serialize(): any;
  131390. /**
  131391. * Release resources
  131392. */
  131393. dispose(): void;
  131394. }
  131395. }
  131396. declare module BABYLON {
  131397. /**
  131398. * Block used to add support for vertex skinning (bones)
  131399. */
  131400. export class BonesBlock extends NodeMaterialBlock {
  131401. /**
  131402. * Creates a new BonesBlock
  131403. * @param name defines the block name
  131404. */
  131405. constructor(name: string);
  131406. /**
  131407. * Initialize the block and prepare the context for build
  131408. * @param state defines the state that will be used for the build
  131409. */
  131410. initialize(state: NodeMaterialBuildState): void;
  131411. /**
  131412. * Gets the current class name
  131413. * @returns the class name
  131414. */
  131415. getClassName(): string;
  131416. /**
  131417. * Gets the matrix indices input component
  131418. */
  131419. get matricesIndices(): NodeMaterialConnectionPoint;
  131420. /**
  131421. * Gets the matrix weights input component
  131422. */
  131423. get matricesWeights(): NodeMaterialConnectionPoint;
  131424. /**
  131425. * Gets the extra matrix indices input component
  131426. */
  131427. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131428. /**
  131429. * Gets the extra matrix weights input component
  131430. */
  131431. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131432. /**
  131433. * Gets the world input component
  131434. */
  131435. get world(): NodeMaterialConnectionPoint;
  131436. /**
  131437. * Gets the output component
  131438. */
  131439. get output(): NodeMaterialConnectionPoint;
  131440. autoConfigure(material: NodeMaterial): void;
  131441. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131444. protected _buildBlock(state: NodeMaterialBuildState): this;
  131445. }
  131446. }
  131447. declare module BABYLON {
  131448. /**
  131449. * Block used to add support for instances
  131450. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131451. */
  131452. export class InstancesBlock extends NodeMaterialBlock {
  131453. /**
  131454. * Creates a new InstancesBlock
  131455. * @param name defines the block name
  131456. */
  131457. constructor(name: string);
  131458. /**
  131459. * Gets the current class name
  131460. * @returns the class name
  131461. */
  131462. getClassName(): string;
  131463. /**
  131464. * Gets the first world row input component
  131465. */
  131466. get world0(): NodeMaterialConnectionPoint;
  131467. /**
  131468. * Gets the second world row input component
  131469. */
  131470. get world1(): NodeMaterialConnectionPoint;
  131471. /**
  131472. * Gets the third world row input component
  131473. */
  131474. get world2(): NodeMaterialConnectionPoint;
  131475. /**
  131476. * Gets the forth world row input component
  131477. */
  131478. get world3(): NodeMaterialConnectionPoint;
  131479. /**
  131480. * Gets the world input component
  131481. */
  131482. get world(): NodeMaterialConnectionPoint;
  131483. /**
  131484. * Gets the output component
  131485. */
  131486. get output(): NodeMaterialConnectionPoint;
  131487. /**
  131488. * Gets the isntanceID component
  131489. */
  131490. get instanceID(): NodeMaterialConnectionPoint;
  131491. autoConfigure(material: NodeMaterial): void;
  131492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131493. protected _buildBlock(state: NodeMaterialBuildState): this;
  131494. }
  131495. }
  131496. declare module BABYLON {
  131497. /**
  131498. * Block used to add morph targets support to vertex shader
  131499. */
  131500. export class MorphTargetsBlock extends NodeMaterialBlock {
  131501. private _repeatableContentAnchor;
  131502. /**
  131503. * Create a new MorphTargetsBlock
  131504. * @param name defines the block name
  131505. */
  131506. constructor(name: string);
  131507. /**
  131508. * Gets the current class name
  131509. * @returns the class name
  131510. */
  131511. getClassName(): string;
  131512. /**
  131513. * Gets the position input component
  131514. */
  131515. get position(): NodeMaterialConnectionPoint;
  131516. /**
  131517. * Gets the normal input component
  131518. */
  131519. get normal(): NodeMaterialConnectionPoint;
  131520. /**
  131521. * Gets the tangent input component
  131522. */
  131523. get tangent(): NodeMaterialConnectionPoint;
  131524. /**
  131525. * Gets the tangent input component
  131526. */
  131527. get uv(): NodeMaterialConnectionPoint;
  131528. /**
  131529. * Gets the position output component
  131530. */
  131531. get positionOutput(): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Gets the normal output component
  131534. */
  131535. get normalOutput(): NodeMaterialConnectionPoint;
  131536. /**
  131537. * Gets the tangent output component
  131538. */
  131539. get tangentOutput(): NodeMaterialConnectionPoint;
  131540. /**
  131541. * Gets the tangent output component
  131542. */
  131543. get uvOutput(): NodeMaterialConnectionPoint;
  131544. initialize(state: NodeMaterialBuildState): void;
  131545. autoConfigure(material: NodeMaterial): void;
  131546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131547. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131548. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131549. protected _buildBlock(state: NodeMaterialBuildState): this;
  131550. }
  131551. }
  131552. declare module BABYLON {
  131553. /**
  131554. * Block used to get data information from a light
  131555. */
  131556. export class LightInformationBlock extends NodeMaterialBlock {
  131557. private _lightDataUniformName;
  131558. private _lightColorUniformName;
  131559. private _lightTypeDefineName;
  131560. /**
  131561. * Gets or sets the light associated with this block
  131562. */
  131563. light: Nullable<Light>;
  131564. /**
  131565. * Creates a new LightInformationBlock
  131566. * @param name defines the block name
  131567. */
  131568. constructor(name: string);
  131569. /**
  131570. * Gets the current class name
  131571. * @returns the class name
  131572. */
  131573. getClassName(): string;
  131574. /**
  131575. * Gets the world position input component
  131576. */
  131577. get worldPosition(): NodeMaterialConnectionPoint;
  131578. /**
  131579. * Gets the direction output component
  131580. */
  131581. get direction(): NodeMaterialConnectionPoint;
  131582. /**
  131583. * Gets the direction output component
  131584. */
  131585. get color(): NodeMaterialConnectionPoint;
  131586. /**
  131587. * Gets the direction output component
  131588. */
  131589. get intensity(): NodeMaterialConnectionPoint;
  131590. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131592. protected _buildBlock(state: NodeMaterialBuildState): this;
  131593. serialize(): any;
  131594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131595. }
  131596. }
  131597. declare module BABYLON {
  131598. /**
  131599. * Block used to add image processing support to fragment shader
  131600. */
  131601. export class ImageProcessingBlock extends NodeMaterialBlock {
  131602. /**
  131603. * Create a new ImageProcessingBlock
  131604. * @param name defines the block name
  131605. */
  131606. constructor(name: string);
  131607. /**
  131608. * Gets the current class name
  131609. * @returns the class name
  131610. */
  131611. getClassName(): string;
  131612. /**
  131613. * Gets the color input component
  131614. */
  131615. get color(): NodeMaterialConnectionPoint;
  131616. /**
  131617. * Gets the output component
  131618. */
  131619. get output(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Initialize the block and prepare the context for build
  131622. * @param state defines the state that will be used for the build
  131623. */
  131624. initialize(state: NodeMaterialBuildState): void;
  131625. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131626. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131628. protected _buildBlock(state: NodeMaterialBuildState): this;
  131629. }
  131630. }
  131631. declare module BABYLON {
  131632. /**
  131633. * Block used to pertub normals based on a normal map
  131634. */
  131635. export class PerturbNormalBlock extends NodeMaterialBlock {
  131636. private _tangentSpaceParameterName;
  131637. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131638. invertX: boolean;
  131639. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131640. invertY: boolean;
  131641. /**
  131642. * Create a new PerturbNormalBlock
  131643. * @param name defines the block name
  131644. */
  131645. constructor(name: string);
  131646. /**
  131647. * Gets the current class name
  131648. * @returns the class name
  131649. */
  131650. getClassName(): string;
  131651. /**
  131652. * Gets the world position input component
  131653. */
  131654. get worldPosition(): NodeMaterialConnectionPoint;
  131655. /**
  131656. * Gets the world normal input component
  131657. */
  131658. get worldNormal(): NodeMaterialConnectionPoint;
  131659. /**
  131660. * Gets the world tangent input component
  131661. */
  131662. get worldTangent(): NodeMaterialConnectionPoint;
  131663. /**
  131664. * Gets the uv input component
  131665. */
  131666. get uv(): NodeMaterialConnectionPoint;
  131667. /**
  131668. * Gets the normal map color input component
  131669. */
  131670. get normalMapColor(): NodeMaterialConnectionPoint;
  131671. /**
  131672. * Gets the strength input component
  131673. */
  131674. get strength(): NodeMaterialConnectionPoint;
  131675. /**
  131676. * Gets the output component
  131677. */
  131678. get output(): NodeMaterialConnectionPoint;
  131679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131681. autoConfigure(material: NodeMaterial): void;
  131682. protected _buildBlock(state: NodeMaterialBuildState): this;
  131683. protected _dumpPropertiesCode(): string;
  131684. serialize(): any;
  131685. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131686. }
  131687. }
  131688. declare module BABYLON {
  131689. /**
  131690. * Block used to discard a pixel if a value is smaller than a cutoff
  131691. */
  131692. export class DiscardBlock extends NodeMaterialBlock {
  131693. /**
  131694. * Create a new DiscardBlock
  131695. * @param name defines the block name
  131696. */
  131697. constructor(name: string);
  131698. /**
  131699. * Gets the current class name
  131700. * @returns the class name
  131701. */
  131702. getClassName(): string;
  131703. /**
  131704. * Gets the color input component
  131705. */
  131706. get value(): NodeMaterialConnectionPoint;
  131707. /**
  131708. * Gets the cutoff input component
  131709. */
  131710. get cutoff(): NodeMaterialConnectionPoint;
  131711. protected _buildBlock(state: NodeMaterialBuildState): this;
  131712. }
  131713. }
  131714. declare module BABYLON {
  131715. /**
  131716. * Block used to test if the fragment shader is front facing
  131717. */
  131718. export class FrontFacingBlock extends NodeMaterialBlock {
  131719. /**
  131720. * Creates a new FrontFacingBlock
  131721. * @param name defines the block name
  131722. */
  131723. constructor(name: string);
  131724. /**
  131725. * Gets the current class name
  131726. * @returns the class name
  131727. */
  131728. getClassName(): string;
  131729. /**
  131730. * Gets the output component
  131731. */
  131732. get output(): NodeMaterialConnectionPoint;
  131733. protected _buildBlock(state: NodeMaterialBuildState): this;
  131734. }
  131735. }
  131736. declare module BABYLON {
  131737. /**
  131738. * Block used to get the derivative value on x and y of a given input
  131739. */
  131740. export class DerivativeBlock extends NodeMaterialBlock {
  131741. /**
  131742. * Create a new DerivativeBlock
  131743. * @param name defines the block name
  131744. */
  131745. constructor(name: string);
  131746. /**
  131747. * Gets the current class name
  131748. * @returns the class name
  131749. */
  131750. getClassName(): string;
  131751. /**
  131752. * Gets the input component
  131753. */
  131754. get input(): NodeMaterialConnectionPoint;
  131755. /**
  131756. * Gets the derivative output on x
  131757. */
  131758. get dx(): NodeMaterialConnectionPoint;
  131759. /**
  131760. * Gets the derivative output on y
  131761. */
  131762. get dy(): NodeMaterialConnectionPoint;
  131763. protected _buildBlock(state: NodeMaterialBuildState): this;
  131764. }
  131765. }
  131766. declare module BABYLON {
  131767. /**
  131768. * Block used to add support for scene fog
  131769. */
  131770. export class FogBlock extends NodeMaterialBlock {
  131771. private _fogDistanceName;
  131772. private _fogParameters;
  131773. /**
  131774. * Create a new FogBlock
  131775. * @param name defines the block name
  131776. */
  131777. constructor(name: string);
  131778. /**
  131779. * Gets the current class name
  131780. * @returns the class name
  131781. */
  131782. getClassName(): string;
  131783. /**
  131784. * Gets the world position input component
  131785. */
  131786. get worldPosition(): NodeMaterialConnectionPoint;
  131787. /**
  131788. * Gets the view input component
  131789. */
  131790. get view(): NodeMaterialConnectionPoint;
  131791. /**
  131792. * Gets the color input component
  131793. */
  131794. get input(): NodeMaterialConnectionPoint;
  131795. /**
  131796. * Gets the fog color input component
  131797. */
  131798. get fogColor(): NodeMaterialConnectionPoint;
  131799. /**
  131800. * Gets the output component
  131801. */
  131802. get output(): NodeMaterialConnectionPoint;
  131803. autoConfigure(material: NodeMaterial): void;
  131804. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131805. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131806. protected _buildBlock(state: NodeMaterialBuildState): this;
  131807. }
  131808. }
  131809. declare module BABYLON {
  131810. /**
  131811. * Block used to add light in the fragment shader
  131812. */
  131813. export class LightBlock extends NodeMaterialBlock {
  131814. private _lightId;
  131815. /**
  131816. * Gets or sets the light associated with this block
  131817. */
  131818. light: Nullable<Light>;
  131819. /**
  131820. * Create a new LightBlock
  131821. * @param name defines the block name
  131822. */
  131823. constructor(name: string);
  131824. /**
  131825. * Gets the current class name
  131826. * @returns the class name
  131827. */
  131828. getClassName(): string;
  131829. /**
  131830. * Gets the world position input component
  131831. */
  131832. get worldPosition(): NodeMaterialConnectionPoint;
  131833. /**
  131834. * Gets the world normal input component
  131835. */
  131836. get worldNormal(): NodeMaterialConnectionPoint;
  131837. /**
  131838. * Gets the camera (or eye) position component
  131839. */
  131840. get cameraPosition(): NodeMaterialConnectionPoint;
  131841. /**
  131842. * Gets the glossiness component
  131843. */
  131844. get glossiness(): NodeMaterialConnectionPoint;
  131845. /**
  131846. * Gets the glossinness power component
  131847. */
  131848. get glossPower(): NodeMaterialConnectionPoint;
  131849. /**
  131850. * Gets the diffuse color component
  131851. */
  131852. get diffuseColor(): NodeMaterialConnectionPoint;
  131853. /**
  131854. * Gets the specular color component
  131855. */
  131856. get specularColor(): NodeMaterialConnectionPoint;
  131857. /**
  131858. * Gets the diffuse output component
  131859. */
  131860. get diffuseOutput(): NodeMaterialConnectionPoint;
  131861. /**
  131862. * Gets the specular output component
  131863. */
  131864. get specularOutput(): NodeMaterialConnectionPoint;
  131865. /**
  131866. * Gets the shadow output component
  131867. */
  131868. get shadow(): NodeMaterialConnectionPoint;
  131869. autoConfigure(material: NodeMaterial): void;
  131870. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131871. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131873. private _injectVertexCode;
  131874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131875. serialize(): any;
  131876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131877. }
  131878. }
  131879. declare module BABYLON {
  131880. /**
  131881. * Block used to multiply 2 values
  131882. */
  131883. export class MultiplyBlock extends NodeMaterialBlock {
  131884. /**
  131885. * Creates a new MultiplyBlock
  131886. * @param name defines the block name
  131887. */
  131888. constructor(name: string);
  131889. /**
  131890. * Gets the current class name
  131891. * @returns the class name
  131892. */
  131893. getClassName(): string;
  131894. /**
  131895. * Gets the left operand input component
  131896. */
  131897. get left(): NodeMaterialConnectionPoint;
  131898. /**
  131899. * Gets the right operand input component
  131900. */
  131901. get right(): NodeMaterialConnectionPoint;
  131902. /**
  131903. * Gets the output component
  131904. */
  131905. get output(): NodeMaterialConnectionPoint;
  131906. protected _buildBlock(state: NodeMaterialBuildState): this;
  131907. }
  131908. }
  131909. declare module BABYLON {
  131910. /**
  131911. * Block used to add 2 vectors
  131912. */
  131913. export class AddBlock extends NodeMaterialBlock {
  131914. /**
  131915. * Creates a new AddBlock
  131916. * @param name defines the block name
  131917. */
  131918. constructor(name: string);
  131919. /**
  131920. * Gets the current class name
  131921. * @returns the class name
  131922. */
  131923. getClassName(): string;
  131924. /**
  131925. * Gets the left operand input component
  131926. */
  131927. get left(): NodeMaterialConnectionPoint;
  131928. /**
  131929. * Gets the right operand input component
  131930. */
  131931. get right(): NodeMaterialConnectionPoint;
  131932. /**
  131933. * Gets the output component
  131934. */
  131935. get output(): NodeMaterialConnectionPoint;
  131936. protected _buildBlock(state: NodeMaterialBuildState): this;
  131937. }
  131938. }
  131939. declare module BABYLON {
  131940. /**
  131941. * Block used to scale a vector by a float
  131942. */
  131943. export class ScaleBlock extends NodeMaterialBlock {
  131944. /**
  131945. * Creates a new ScaleBlock
  131946. * @param name defines the block name
  131947. */
  131948. constructor(name: string);
  131949. /**
  131950. * Gets the current class name
  131951. * @returns the class name
  131952. */
  131953. getClassName(): string;
  131954. /**
  131955. * Gets the input component
  131956. */
  131957. get input(): NodeMaterialConnectionPoint;
  131958. /**
  131959. * Gets the factor input component
  131960. */
  131961. get factor(): NodeMaterialConnectionPoint;
  131962. /**
  131963. * Gets the output component
  131964. */
  131965. get output(): NodeMaterialConnectionPoint;
  131966. protected _buildBlock(state: NodeMaterialBuildState): this;
  131967. }
  131968. }
  131969. declare module BABYLON {
  131970. /**
  131971. * Block used to clamp a float
  131972. */
  131973. export class ClampBlock extends NodeMaterialBlock {
  131974. /** Gets or sets the minimum range */
  131975. minimum: number;
  131976. /** Gets or sets the maximum range */
  131977. maximum: number;
  131978. /**
  131979. * Creates a new ClampBlock
  131980. * @param name defines the block name
  131981. */
  131982. constructor(name: string);
  131983. /**
  131984. * Gets the current class name
  131985. * @returns the class name
  131986. */
  131987. getClassName(): string;
  131988. /**
  131989. * Gets the value input component
  131990. */
  131991. get value(): NodeMaterialConnectionPoint;
  131992. /**
  131993. * Gets the output component
  131994. */
  131995. get output(): NodeMaterialConnectionPoint;
  131996. protected _buildBlock(state: NodeMaterialBuildState): this;
  131997. protected _dumpPropertiesCode(): string;
  131998. serialize(): any;
  131999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132000. }
  132001. }
  132002. declare module BABYLON {
  132003. /**
  132004. * Block used to apply a cross product between 2 vectors
  132005. */
  132006. export class CrossBlock extends NodeMaterialBlock {
  132007. /**
  132008. * Creates a new CrossBlock
  132009. * @param name defines the block name
  132010. */
  132011. constructor(name: string);
  132012. /**
  132013. * Gets the current class name
  132014. * @returns the class name
  132015. */
  132016. getClassName(): string;
  132017. /**
  132018. * Gets the left operand input component
  132019. */
  132020. get left(): NodeMaterialConnectionPoint;
  132021. /**
  132022. * Gets the right operand input component
  132023. */
  132024. get right(): NodeMaterialConnectionPoint;
  132025. /**
  132026. * Gets the output component
  132027. */
  132028. get output(): NodeMaterialConnectionPoint;
  132029. protected _buildBlock(state: NodeMaterialBuildState): this;
  132030. }
  132031. }
  132032. declare module BABYLON {
  132033. /**
  132034. * Block used to apply a dot product between 2 vectors
  132035. */
  132036. export class DotBlock extends NodeMaterialBlock {
  132037. /**
  132038. * Creates a new DotBlock
  132039. * @param name defines the block name
  132040. */
  132041. constructor(name: string);
  132042. /**
  132043. * Gets the current class name
  132044. * @returns the class name
  132045. */
  132046. getClassName(): string;
  132047. /**
  132048. * Gets the left operand input component
  132049. */
  132050. get left(): NodeMaterialConnectionPoint;
  132051. /**
  132052. * Gets the right operand input component
  132053. */
  132054. get right(): NodeMaterialConnectionPoint;
  132055. /**
  132056. * Gets the output component
  132057. */
  132058. get output(): NodeMaterialConnectionPoint;
  132059. protected _buildBlock(state: NodeMaterialBuildState): this;
  132060. }
  132061. }
  132062. declare module BABYLON {
  132063. /**
  132064. * Block used to remap a float from a range to a new one
  132065. */
  132066. export class RemapBlock extends NodeMaterialBlock {
  132067. /**
  132068. * Gets or sets the source range
  132069. */
  132070. sourceRange: Vector2;
  132071. /**
  132072. * Gets or sets the target range
  132073. */
  132074. targetRange: Vector2;
  132075. /**
  132076. * Creates a new RemapBlock
  132077. * @param name defines the block name
  132078. */
  132079. constructor(name: string);
  132080. /**
  132081. * Gets the current class name
  132082. * @returns the class name
  132083. */
  132084. getClassName(): string;
  132085. /**
  132086. * Gets the input component
  132087. */
  132088. get input(): NodeMaterialConnectionPoint;
  132089. /**
  132090. * Gets the source min input component
  132091. */
  132092. get sourceMin(): NodeMaterialConnectionPoint;
  132093. /**
  132094. * Gets the source max input component
  132095. */
  132096. get sourceMax(): NodeMaterialConnectionPoint;
  132097. /**
  132098. * Gets the target min input component
  132099. */
  132100. get targetMin(): NodeMaterialConnectionPoint;
  132101. /**
  132102. * Gets the target max input component
  132103. */
  132104. get targetMax(): NodeMaterialConnectionPoint;
  132105. /**
  132106. * Gets the output component
  132107. */
  132108. get output(): NodeMaterialConnectionPoint;
  132109. protected _buildBlock(state: NodeMaterialBuildState): this;
  132110. protected _dumpPropertiesCode(): string;
  132111. serialize(): any;
  132112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132113. }
  132114. }
  132115. declare module BABYLON {
  132116. /**
  132117. * Block used to normalize a vector
  132118. */
  132119. export class NormalizeBlock extends NodeMaterialBlock {
  132120. /**
  132121. * Creates a new NormalizeBlock
  132122. * @param name defines the block name
  132123. */
  132124. constructor(name: string);
  132125. /**
  132126. * Gets the current class name
  132127. * @returns the class name
  132128. */
  132129. getClassName(): string;
  132130. /**
  132131. * Gets the input component
  132132. */
  132133. get input(): NodeMaterialConnectionPoint;
  132134. /**
  132135. * Gets the output component
  132136. */
  132137. get output(): NodeMaterialConnectionPoint;
  132138. protected _buildBlock(state: NodeMaterialBuildState): this;
  132139. }
  132140. }
  132141. declare module BABYLON {
  132142. /**
  132143. * Operations supported by the Trigonometry block
  132144. */
  132145. export enum TrigonometryBlockOperations {
  132146. /** Cos */
  132147. Cos = 0,
  132148. /** Sin */
  132149. Sin = 1,
  132150. /** Abs */
  132151. Abs = 2,
  132152. /** Exp */
  132153. Exp = 3,
  132154. /** Exp2 */
  132155. Exp2 = 4,
  132156. /** Round */
  132157. Round = 5,
  132158. /** Floor */
  132159. Floor = 6,
  132160. /** Ceiling */
  132161. Ceiling = 7,
  132162. /** Square root */
  132163. Sqrt = 8,
  132164. /** Log */
  132165. Log = 9,
  132166. /** Tangent */
  132167. Tan = 10,
  132168. /** Arc tangent */
  132169. ArcTan = 11,
  132170. /** Arc cosinus */
  132171. ArcCos = 12,
  132172. /** Arc sinus */
  132173. ArcSin = 13,
  132174. /** Fraction */
  132175. Fract = 14,
  132176. /** Sign */
  132177. Sign = 15,
  132178. /** To radians (from degrees) */
  132179. Radians = 16,
  132180. /** To degrees (from radians) */
  132181. Degrees = 17
  132182. }
  132183. /**
  132184. * Block used to apply trigonometry operation to floats
  132185. */
  132186. export class TrigonometryBlock extends NodeMaterialBlock {
  132187. /**
  132188. * Gets or sets the operation applied by the block
  132189. */
  132190. operation: TrigonometryBlockOperations;
  132191. /**
  132192. * Creates a new TrigonometryBlock
  132193. * @param name defines the block name
  132194. */
  132195. constructor(name: string);
  132196. /**
  132197. * Gets the current class name
  132198. * @returns the class name
  132199. */
  132200. getClassName(): string;
  132201. /**
  132202. * Gets the input component
  132203. */
  132204. get input(): NodeMaterialConnectionPoint;
  132205. /**
  132206. * Gets the output component
  132207. */
  132208. get output(): NodeMaterialConnectionPoint;
  132209. protected _buildBlock(state: NodeMaterialBuildState): this;
  132210. serialize(): any;
  132211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132212. protected _dumpPropertiesCode(): string;
  132213. }
  132214. }
  132215. declare module BABYLON {
  132216. /**
  132217. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132218. */
  132219. export class ColorMergerBlock extends NodeMaterialBlock {
  132220. /**
  132221. * Create a new ColorMergerBlock
  132222. * @param name defines the block name
  132223. */
  132224. constructor(name: string);
  132225. /**
  132226. * Gets the current class name
  132227. * @returns the class name
  132228. */
  132229. getClassName(): string;
  132230. /**
  132231. * Gets the rgb component (input)
  132232. */
  132233. get rgbIn(): NodeMaterialConnectionPoint;
  132234. /**
  132235. * Gets the r component (input)
  132236. */
  132237. get r(): NodeMaterialConnectionPoint;
  132238. /**
  132239. * Gets the g component (input)
  132240. */
  132241. get g(): NodeMaterialConnectionPoint;
  132242. /**
  132243. * Gets the b component (input)
  132244. */
  132245. get b(): NodeMaterialConnectionPoint;
  132246. /**
  132247. * Gets the a component (input)
  132248. */
  132249. get a(): NodeMaterialConnectionPoint;
  132250. /**
  132251. * Gets the rgba component (output)
  132252. */
  132253. get rgba(): NodeMaterialConnectionPoint;
  132254. /**
  132255. * Gets the rgb component (output)
  132256. */
  132257. get rgbOut(): NodeMaterialConnectionPoint;
  132258. /**
  132259. * Gets the rgb component (output)
  132260. * @deprecated Please use rgbOut instead.
  132261. */
  132262. get rgb(): NodeMaterialConnectionPoint;
  132263. protected _buildBlock(state: NodeMaterialBuildState): this;
  132264. }
  132265. }
  132266. declare module BABYLON {
  132267. /**
  132268. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132269. */
  132270. export class VectorMergerBlock extends NodeMaterialBlock {
  132271. /**
  132272. * Create a new VectorMergerBlock
  132273. * @param name defines the block name
  132274. */
  132275. constructor(name: string);
  132276. /**
  132277. * Gets the current class name
  132278. * @returns the class name
  132279. */
  132280. getClassName(): string;
  132281. /**
  132282. * Gets the xyz component (input)
  132283. */
  132284. get xyzIn(): NodeMaterialConnectionPoint;
  132285. /**
  132286. * Gets the xy component (input)
  132287. */
  132288. get xyIn(): NodeMaterialConnectionPoint;
  132289. /**
  132290. * Gets the x component (input)
  132291. */
  132292. get x(): NodeMaterialConnectionPoint;
  132293. /**
  132294. * Gets the y component (input)
  132295. */
  132296. get y(): NodeMaterialConnectionPoint;
  132297. /**
  132298. * Gets the z component (input)
  132299. */
  132300. get z(): NodeMaterialConnectionPoint;
  132301. /**
  132302. * Gets the w component (input)
  132303. */
  132304. get w(): NodeMaterialConnectionPoint;
  132305. /**
  132306. * Gets the xyzw component (output)
  132307. */
  132308. get xyzw(): NodeMaterialConnectionPoint;
  132309. /**
  132310. * Gets the xyz component (output)
  132311. */
  132312. get xyzOut(): NodeMaterialConnectionPoint;
  132313. /**
  132314. * Gets the xy component (output)
  132315. */
  132316. get xyOut(): NodeMaterialConnectionPoint;
  132317. /**
  132318. * Gets the xy component (output)
  132319. * @deprecated Please use xyOut instead.
  132320. */
  132321. get xy(): NodeMaterialConnectionPoint;
  132322. /**
  132323. * Gets the xyz component (output)
  132324. * @deprecated Please use xyzOut instead.
  132325. */
  132326. get xyz(): NodeMaterialConnectionPoint;
  132327. protected _buildBlock(state: NodeMaterialBuildState): this;
  132328. }
  132329. }
  132330. declare module BABYLON {
  132331. /**
  132332. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132333. */
  132334. export class ColorSplitterBlock extends NodeMaterialBlock {
  132335. /**
  132336. * Create a new ColorSplitterBlock
  132337. * @param name defines the block name
  132338. */
  132339. constructor(name: string);
  132340. /**
  132341. * Gets the current class name
  132342. * @returns the class name
  132343. */
  132344. getClassName(): string;
  132345. /**
  132346. * Gets the rgba component (input)
  132347. */
  132348. get rgba(): NodeMaterialConnectionPoint;
  132349. /**
  132350. * Gets the rgb component (input)
  132351. */
  132352. get rgbIn(): NodeMaterialConnectionPoint;
  132353. /**
  132354. * Gets the rgb component (output)
  132355. */
  132356. get rgbOut(): NodeMaterialConnectionPoint;
  132357. /**
  132358. * Gets the r component (output)
  132359. */
  132360. get r(): NodeMaterialConnectionPoint;
  132361. /**
  132362. * Gets the g component (output)
  132363. */
  132364. get g(): NodeMaterialConnectionPoint;
  132365. /**
  132366. * Gets the b component (output)
  132367. */
  132368. get b(): NodeMaterialConnectionPoint;
  132369. /**
  132370. * Gets the a component (output)
  132371. */
  132372. get a(): NodeMaterialConnectionPoint;
  132373. protected _inputRename(name: string): string;
  132374. protected _outputRename(name: string): string;
  132375. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132376. }
  132377. }
  132378. declare module BABYLON {
  132379. /**
  132380. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132381. */
  132382. export class VectorSplitterBlock extends NodeMaterialBlock {
  132383. /**
  132384. * Create a new VectorSplitterBlock
  132385. * @param name defines the block name
  132386. */
  132387. constructor(name: string);
  132388. /**
  132389. * Gets the current class name
  132390. * @returns the class name
  132391. */
  132392. getClassName(): string;
  132393. /**
  132394. * Gets the xyzw component (input)
  132395. */
  132396. get xyzw(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the xyz component (input)
  132399. */
  132400. get xyzIn(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the xy component (input)
  132403. */
  132404. get xyIn(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the xyz component (output)
  132407. */
  132408. get xyzOut(): NodeMaterialConnectionPoint;
  132409. /**
  132410. * Gets the xy component (output)
  132411. */
  132412. get xyOut(): NodeMaterialConnectionPoint;
  132413. /**
  132414. * Gets the x component (output)
  132415. */
  132416. get x(): NodeMaterialConnectionPoint;
  132417. /**
  132418. * Gets the y component (output)
  132419. */
  132420. get y(): NodeMaterialConnectionPoint;
  132421. /**
  132422. * Gets the z component (output)
  132423. */
  132424. get z(): NodeMaterialConnectionPoint;
  132425. /**
  132426. * Gets the w component (output)
  132427. */
  132428. get w(): NodeMaterialConnectionPoint;
  132429. protected _inputRename(name: string): string;
  132430. protected _outputRename(name: string): string;
  132431. protected _buildBlock(state: NodeMaterialBuildState): this;
  132432. }
  132433. }
  132434. declare module BABYLON {
  132435. /**
  132436. * Block used to lerp between 2 values
  132437. */
  132438. export class LerpBlock extends NodeMaterialBlock {
  132439. /**
  132440. * Creates a new LerpBlock
  132441. * @param name defines the block name
  132442. */
  132443. constructor(name: string);
  132444. /**
  132445. * Gets the current class name
  132446. * @returns the class name
  132447. */
  132448. getClassName(): string;
  132449. /**
  132450. * Gets the left operand input component
  132451. */
  132452. get left(): NodeMaterialConnectionPoint;
  132453. /**
  132454. * Gets the right operand input component
  132455. */
  132456. get right(): NodeMaterialConnectionPoint;
  132457. /**
  132458. * Gets the gradient operand input component
  132459. */
  132460. get gradient(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the output component
  132463. */
  132464. get output(): NodeMaterialConnectionPoint;
  132465. protected _buildBlock(state: NodeMaterialBuildState): this;
  132466. }
  132467. }
  132468. declare module BABYLON {
  132469. /**
  132470. * Block used to divide 2 vectors
  132471. */
  132472. export class DivideBlock extends NodeMaterialBlock {
  132473. /**
  132474. * Creates a new DivideBlock
  132475. * @param name defines the block name
  132476. */
  132477. constructor(name: string);
  132478. /**
  132479. * Gets the current class name
  132480. * @returns the class name
  132481. */
  132482. getClassName(): string;
  132483. /**
  132484. * Gets the left operand input component
  132485. */
  132486. get left(): NodeMaterialConnectionPoint;
  132487. /**
  132488. * Gets the right operand input component
  132489. */
  132490. get right(): NodeMaterialConnectionPoint;
  132491. /**
  132492. * Gets the output component
  132493. */
  132494. get output(): NodeMaterialConnectionPoint;
  132495. protected _buildBlock(state: NodeMaterialBuildState): this;
  132496. }
  132497. }
  132498. declare module BABYLON {
  132499. /**
  132500. * Block used to subtract 2 vectors
  132501. */
  132502. export class SubtractBlock extends NodeMaterialBlock {
  132503. /**
  132504. * Creates a new SubtractBlock
  132505. * @param name defines the block name
  132506. */
  132507. constructor(name: string);
  132508. /**
  132509. * Gets the current class name
  132510. * @returns the class name
  132511. */
  132512. getClassName(): string;
  132513. /**
  132514. * Gets the left operand input component
  132515. */
  132516. get left(): NodeMaterialConnectionPoint;
  132517. /**
  132518. * Gets the right operand input component
  132519. */
  132520. get right(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the output component
  132523. */
  132524. get output(): NodeMaterialConnectionPoint;
  132525. protected _buildBlock(state: NodeMaterialBuildState): this;
  132526. }
  132527. }
  132528. declare module BABYLON {
  132529. /**
  132530. * Block used to step a value
  132531. */
  132532. export class StepBlock extends NodeMaterialBlock {
  132533. /**
  132534. * Creates a new StepBlock
  132535. * @param name defines the block name
  132536. */
  132537. constructor(name: string);
  132538. /**
  132539. * Gets the current class name
  132540. * @returns the class name
  132541. */
  132542. getClassName(): string;
  132543. /**
  132544. * Gets the value operand input component
  132545. */
  132546. get value(): NodeMaterialConnectionPoint;
  132547. /**
  132548. * Gets the edge operand input component
  132549. */
  132550. get edge(): NodeMaterialConnectionPoint;
  132551. /**
  132552. * Gets the output component
  132553. */
  132554. get output(): NodeMaterialConnectionPoint;
  132555. protected _buildBlock(state: NodeMaterialBuildState): this;
  132556. }
  132557. }
  132558. declare module BABYLON {
  132559. /**
  132560. * Block used to get the opposite (1 - x) of a value
  132561. */
  132562. export class OneMinusBlock extends NodeMaterialBlock {
  132563. /**
  132564. * Creates a new OneMinusBlock
  132565. * @param name defines the block name
  132566. */
  132567. constructor(name: string);
  132568. /**
  132569. * Gets the current class name
  132570. * @returns the class name
  132571. */
  132572. getClassName(): string;
  132573. /**
  132574. * Gets the input component
  132575. */
  132576. get input(): NodeMaterialConnectionPoint;
  132577. /**
  132578. * Gets the output component
  132579. */
  132580. get output(): NodeMaterialConnectionPoint;
  132581. protected _buildBlock(state: NodeMaterialBuildState): this;
  132582. }
  132583. }
  132584. declare module BABYLON {
  132585. /**
  132586. * Block used to get the view direction
  132587. */
  132588. export class ViewDirectionBlock extends NodeMaterialBlock {
  132589. /**
  132590. * Creates a new ViewDirectionBlock
  132591. * @param name defines the block name
  132592. */
  132593. constructor(name: string);
  132594. /**
  132595. * Gets the current class name
  132596. * @returns the class name
  132597. */
  132598. getClassName(): string;
  132599. /**
  132600. * Gets the world position component
  132601. */
  132602. get worldPosition(): NodeMaterialConnectionPoint;
  132603. /**
  132604. * Gets the camera position component
  132605. */
  132606. get cameraPosition(): NodeMaterialConnectionPoint;
  132607. /**
  132608. * Gets the output component
  132609. */
  132610. get output(): NodeMaterialConnectionPoint;
  132611. autoConfigure(material: NodeMaterial): void;
  132612. protected _buildBlock(state: NodeMaterialBuildState): this;
  132613. }
  132614. }
  132615. declare module BABYLON {
  132616. /**
  132617. * Block used to compute fresnel value
  132618. */
  132619. export class FresnelBlock extends NodeMaterialBlock {
  132620. /**
  132621. * Create a new FresnelBlock
  132622. * @param name defines the block name
  132623. */
  132624. constructor(name: string);
  132625. /**
  132626. * Gets the current class name
  132627. * @returns the class name
  132628. */
  132629. getClassName(): string;
  132630. /**
  132631. * Gets the world normal input component
  132632. */
  132633. get worldNormal(): NodeMaterialConnectionPoint;
  132634. /**
  132635. * Gets the view direction input component
  132636. */
  132637. get viewDirection(): NodeMaterialConnectionPoint;
  132638. /**
  132639. * Gets the bias input component
  132640. */
  132641. get bias(): NodeMaterialConnectionPoint;
  132642. /**
  132643. * Gets the camera (or eye) position component
  132644. */
  132645. get power(): NodeMaterialConnectionPoint;
  132646. /**
  132647. * Gets the fresnel output component
  132648. */
  132649. get fresnel(): NodeMaterialConnectionPoint;
  132650. autoConfigure(material: NodeMaterial): void;
  132651. protected _buildBlock(state: NodeMaterialBuildState): this;
  132652. }
  132653. }
  132654. declare module BABYLON {
  132655. /**
  132656. * Block used to get the max of 2 values
  132657. */
  132658. export class MaxBlock extends NodeMaterialBlock {
  132659. /**
  132660. * Creates a new MaxBlock
  132661. * @param name defines the block name
  132662. */
  132663. constructor(name: string);
  132664. /**
  132665. * Gets the current class name
  132666. * @returns the class name
  132667. */
  132668. getClassName(): string;
  132669. /**
  132670. * Gets the left operand input component
  132671. */
  132672. get left(): NodeMaterialConnectionPoint;
  132673. /**
  132674. * Gets the right operand input component
  132675. */
  132676. get right(): NodeMaterialConnectionPoint;
  132677. /**
  132678. * Gets the output component
  132679. */
  132680. get output(): NodeMaterialConnectionPoint;
  132681. protected _buildBlock(state: NodeMaterialBuildState): this;
  132682. }
  132683. }
  132684. declare module BABYLON {
  132685. /**
  132686. * Block used to get the min of 2 values
  132687. */
  132688. export class MinBlock extends NodeMaterialBlock {
  132689. /**
  132690. * Creates a new MinBlock
  132691. * @param name defines the block name
  132692. */
  132693. constructor(name: string);
  132694. /**
  132695. * Gets the current class name
  132696. * @returns the class name
  132697. */
  132698. getClassName(): string;
  132699. /**
  132700. * Gets the left operand input component
  132701. */
  132702. get left(): NodeMaterialConnectionPoint;
  132703. /**
  132704. * Gets the right operand input component
  132705. */
  132706. get right(): NodeMaterialConnectionPoint;
  132707. /**
  132708. * Gets the output component
  132709. */
  132710. get output(): NodeMaterialConnectionPoint;
  132711. protected _buildBlock(state: NodeMaterialBuildState): this;
  132712. }
  132713. }
  132714. declare module BABYLON {
  132715. /**
  132716. * Block used to get the distance between 2 values
  132717. */
  132718. export class DistanceBlock extends NodeMaterialBlock {
  132719. /**
  132720. * Creates a new DistanceBlock
  132721. * @param name defines the block name
  132722. */
  132723. constructor(name: string);
  132724. /**
  132725. * Gets the current class name
  132726. * @returns the class name
  132727. */
  132728. getClassName(): string;
  132729. /**
  132730. * Gets the left operand input component
  132731. */
  132732. get left(): NodeMaterialConnectionPoint;
  132733. /**
  132734. * Gets the right operand input component
  132735. */
  132736. get right(): NodeMaterialConnectionPoint;
  132737. /**
  132738. * Gets the output component
  132739. */
  132740. get output(): NodeMaterialConnectionPoint;
  132741. protected _buildBlock(state: NodeMaterialBuildState): this;
  132742. }
  132743. }
  132744. declare module BABYLON {
  132745. /**
  132746. * Block used to get the length of a vector
  132747. */
  132748. export class LengthBlock extends NodeMaterialBlock {
  132749. /**
  132750. * Creates a new LengthBlock
  132751. * @param name defines the block name
  132752. */
  132753. constructor(name: string);
  132754. /**
  132755. * Gets the current class name
  132756. * @returns the class name
  132757. */
  132758. getClassName(): string;
  132759. /**
  132760. * Gets the value input component
  132761. */
  132762. get value(): NodeMaterialConnectionPoint;
  132763. /**
  132764. * Gets the output component
  132765. */
  132766. get output(): NodeMaterialConnectionPoint;
  132767. protected _buildBlock(state: NodeMaterialBuildState): this;
  132768. }
  132769. }
  132770. declare module BABYLON {
  132771. /**
  132772. * Block used to get negative version of a value (i.e. x * -1)
  132773. */
  132774. export class NegateBlock extends NodeMaterialBlock {
  132775. /**
  132776. * Creates a new NegateBlock
  132777. * @param name defines the block name
  132778. */
  132779. constructor(name: string);
  132780. /**
  132781. * Gets the current class name
  132782. * @returns the class name
  132783. */
  132784. getClassName(): string;
  132785. /**
  132786. * Gets the value input component
  132787. */
  132788. get value(): NodeMaterialConnectionPoint;
  132789. /**
  132790. * Gets the output component
  132791. */
  132792. get output(): NodeMaterialConnectionPoint;
  132793. protected _buildBlock(state: NodeMaterialBuildState): this;
  132794. }
  132795. }
  132796. declare module BABYLON {
  132797. /**
  132798. * Block used to get the value of the first parameter raised to the power of the second
  132799. */
  132800. export class PowBlock extends NodeMaterialBlock {
  132801. /**
  132802. * Creates a new PowBlock
  132803. * @param name defines the block name
  132804. */
  132805. constructor(name: string);
  132806. /**
  132807. * Gets the current class name
  132808. * @returns the class name
  132809. */
  132810. getClassName(): string;
  132811. /**
  132812. * Gets the value operand input component
  132813. */
  132814. get value(): NodeMaterialConnectionPoint;
  132815. /**
  132816. * Gets the power operand input component
  132817. */
  132818. get power(): NodeMaterialConnectionPoint;
  132819. /**
  132820. * Gets the output component
  132821. */
  132822. get output(): NodeMaterialConnectionPoint;
  132823. protected _buildBlock(state: NodeMaterialBuildState): this;
  132824. }
  132825. }
  132826. declare module BABYLON {
  132827. /**
  132828. * Block used to get a random number
  132829. */
  132830. export class RandomNumberBlock extends NodeMaterialBlock {
  132831. /**
  132832. * Creates a new RandomNumberBlock
  132833. * @param name defines the block name
  132834. */
  132835. constructor(name: string);
  132836. /**
  132837. * Gets the current class name
  132838. * @returns the class name
  132839. */
  132840. getClassName(): string;
  132841. /**
  132842. * Gets the seed input component
  132843. */
  132844. get seed(): NodeMaterialConnectionPoint;
  132845. /**
  132846. * Gets the output component
  132847. */
  132848. get output(): NodeMaterialConnectionPoint;
  132849. protected _buildBlock(state: NodeMaterialBuildState): this;
  132850. }
  132851. }
  132852. declare module BABYLON {
  132853. /**
  132854. * Block used to compute arc tangent of 2 values
  132855. */
  132856. export class ArcTan2Block extends NodeMaterialBlock {
  132857. /**
  132858. * Creates a new ArcTan2Block
  132859. * @param name defines the block name
  132860. */
  132861. constructor(name: string);
  132862. /**
  132863. * Gets the current class name
  132864. * @returns the class name
  132865. */
  132866. getClassName(): string;
  132867. /**
  132868. * Gets the x operand input component
  132869. */
  132870. get x(): NodeMaterialConnectionPoint;
  132871. /**
  132872. * Gets the y operand input component
  132873. */
  132874. get y(): NodeMaterialConnectionPoint;
  132875. /**
  132876. * Gets the output component
  132877. */
  132878. get output(): NodeMaterialConnectionPoint;
  132879. protected _buildBlock(state: NodeMaterialBuildState): this;
  132880. }
  132881. }
  132882. declare module BABYLON {
  132883. /**
  132884. * Block used to smooth step a value
  132885. */
  132886. export class SmoothStepBlock extends NodeMaterialBlock {
  132887. /**
  132888. * Creates a new SmoothStepBlock
  132889. * @param name defines the block name
  132890. */
  132891. constructor(name: string);
  132892. /**
  132893. * Gets the current class name
  132894. * @returns the class name
  132895. */
  132896. getClassName(): string;
  132897. /**
  132898. * Gets the value operand input component
  132899. */
  132900. get value(): NodeMaterialConnectionPoint;
  132901. /**
  132902. * Gets the first edge operand input component
  132903. */
  132904. get edge0(): NodeMaterialConnectionPoint;
  132905. /**
  132906. * Gets the second edge operand input component
  132907. */
  132908. get edge1(): NodeMaterialConnectionPoint;
  132909. /**
  132910. * Gets the output component
  132911. */
  132912. get output(): NodeMaterialConnectionPoint;
  132913. protected _buildBlock(state: NodeMaterialBuildState): this;
  132914. }
  132915. }
  132916. declare module BABYLON {
  132917. /**
  132918. * Block used to get the reciprocal (1 / x) of a value
  132919. */
  132920. export class ReciprocalBlock extends NodeMaterialBlock {
  132921. /**
  132922. * Creates a new ReciprocalBlock
  132923. * @param name defines the block name
  132924. */
  132925. constructor(name: string);
  132926. /**
  132927. * Gets the current class name
  132928. * @returns the class name
  132929. */
  132930. getClassName(): string;
  132931. /**
  132932. * Gets the input component
  132933. */
  132934. get input(): NodeMaterialConnectionPoint;
  132935. /**
  132936. * Gets the output component
  132937. */
  132938. get output(): NodeMaterialConnectionPoint;
  132939. protected _buildBlock(state: NodeMaterialBuildState): this;
  132940. }
  132941. }
  132942. declare module BABYLON {
  132943. /**
  132944. * Block used to replace a color by another one
  132945. */
  132946. export class ReplaceColorBlock extends NodeMaterialBlock {
  132947. /**
  132948. * Creates a new ReplaceColorBlock
  132949. * @param name defines the block name
  132950. */
  132951. constructor(name: string);
  132952. /**
  132953. * Gets the current class name
  132954. * @returns the class name
  132955. */
  132956. getClassName(): string;
  132957. /**
  132958. * Gets the value input component
  132959. */
  132960. get value(): NodeMaterialConnectionPoint;
  132961. /**
  132962. * Gets the reference input component
  132963. */
  132964. get reference(): NodeMaterialConnectionPoint;
  132965. /**
  132966. * Gets the distance input component
  132967. */
  132968. get distance(): NodeMaterialConnectionPoint;
  132969. /**
  132970. * Gets the replacement input component
  132971. */
  132972. get replacement(): NodeMaterialConnectionPoint;
  132973. /**
  132974. * Gets the output component
  132975. */
  132976. get output(): NodeMaterialConnectionPoint;
  132977. protected _buildBlock(state: NodeMaterialBuildState): this;
  132978. }
  132979. }
  132980. declare module BABYLON {
  132981. /**
  132982. * Block used to posterize a value
  132983. * @see https://en.wikipedia.org/wiki/Posterization
  132984. */
  132985. export class PosterizeBlock extends NodeMaterialBlock {
  132986. /**
  132987. * Creates a new PosterizeBlock
  132988. * @param name defines the block name
  132989. */
  132990. constructor(name: string);
  132991. /**
  132992. * Gets the current class name
  132993. * @returns the class name
  132994. */
  132995. getClassName(): string;
  132996. /**
  132997. * Gets the value input component
  132998. */
  132999. get value(): NodeMaterialConnectionPoint;
  133000. /**
  133001. * Gets the steps input component
  133002. */
  133003. get steps(): NodeMaterialConnectionPoint;
  133004. /**
  133005. * Gets the output component
  133006. */
  133007. get output(): NodeMaterialConnectionPoint;
  133008. protected _buildBlock(state: NodeMaterialBuildState): this;
  133009. }
  133010. }
  133011. declare module BABYLON {
  133012. /**
  133013. * Operations supported by the Wave block
  133014. */
  133015. export enum WaveBlockKind {
  133016. /** SawTooth */
  133017. SawTooth = 0,
  133018. /** Square */
  133019. Square = 1,
  133020. /** Triangle */
  133021. Triangle = 2
  133022. }
  133023. /**
  133024. * Block used to apply wave operation to floats
  133025. */
  133026. export class WaveBlock extends NodeMaterialBlock {
  133027. /**
  133028. * Gets or sets the kibnd of wave to be applied by the block
  133029. */
  133030. kind: WaveBlockKind;
  133031. /**
  133032. * Creates a new WaveBlock
  133033. * @param name defines the block name
  133034. */
  133035. constructor(name: string);
  133036. /**
  133037. * Gets the current class name
  133038. * @returns the class name
  133039. */
  133040. getClassName(): string;
  133041. /**
  133042. * Gets the input component
  133043. */
  133044. get input(): NodeMaterialConnectionPoint;
  133045. /**
  133046. * Gets the output component
  133047. */
  133048. get output(): NodeMaterialConnectionPoint;
  133049. protected _buildBlock(state: NodeMaterialBuildState): this;
  133050. serialize(): any;
  133051. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133052. }
  133053. }
  133054. declare module BABYLON {
  133055. /**
  133056. * Class used to store a color step for the GradientBlock
  133057. */
  133058. export class GradientBlockColorStep {
  133059. /**
  133060. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133061. */
  133062. step: number;
  133063. /**
  133064. * Gets or sets the color associated with this step
  133065. */
  133066. color: Color3;
  133067. /**
  133068. * Creates a new GradientBlockColorStep
  133069. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133070. * @param color defines the color associated with this step
  133071. */
  133072. constructor(
  133073. /**
  133074. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133075. */
  133076. step: number,
  133077. /**
  133078. * Gets or sets the color associated with this step
  133079. */
  133080. color: Color3);
  133081. }
  133082. /**
  133083. * Block used to return a color from a gradient based on an input value between 0 and 1
  133084. */
  133085. export class GradientBlock extends NodeMaterialBlock {
  133086. /**
  133087. * Gets or sets the list of color steps
  133088. */
  133089. colorSteps: GradientBlockColorStep[];
  133090. /**
  133091. * Creates a new GradientBlock
  133092. * @param name defines the block name
  133093. */
  133094. constructor(name: string);
  133095. /**
  133096. * Gets the current class name
  133097. * @returns the class name
  133098. */
  133099. getClassName(): string;
  133100. /**
  133101. * Gets the gradient input component
  133102. */
  133103. get gradient(): NodeMaterialConnectionPoint;
  133104. /**
  133105. * Gets the output component
  133106. */
  133107. get output(): NodeMaterialConnectionPoint;
  133108. private _writeColorConstant;
  133109. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133110. serialize(): any;
  133111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133112. protected _dumpPropertiesCode(): string;
  133113. }
  133114. }
  133115. declare module BABYLON {
  133116. /**
  133117. * Block used to normalize lerp between 2 values
  133118. */
  133119. export class NLerpBlock extends NodeMaterialBlock {
  133120. /**
  133121. * Creates a new NLerpBlock
  133122. * @param name defines the block name
  133123. */
  133124. constructor(name: string);
  133125. /**
  133126. * Gets the current class name
  133127. * @returns the class name
  133128. */
  133129. getClassName(): string;
  133130. /**
  133131. * Gets the left operand input component
  133132. */
  133133. get left(): NodeMaterialConnectionPoint;
  133134. /**
  133135. * Gets the right operand input component
  133136. */
  133137. get right(): NodeMaterialConnectionPoint;
  133138. /**
  133139. * Gets the gradient operand input component
  133140. */
  133141. get gradient(): NodeMaterialConnectionPoint;
  133142. /**
  133143. * Gets the output component
  133144. */
  133145. get output(): NodeMaterialConnectionPoint;
  133146. protected _buildBlock(state: NodeMaterialBuildState): this;
  133147. }
  133148. }
  133149. declare module BABYLON {
  133150. /**
  133151. * block used to Generate a Worley Noise 3D Noise Pattern
  133152. */
  133153. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133154. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133155. manhattanDistance: boolean;
  133156. /**
  133157. * Creates a new WorleyNoise3DBlock
  133158. * @param name defines the block name
  133159. */
  133160. constructor(name: string);
  133161. /**
  133162. * Gets the current class name
  133163. * @returns the class name
  133164. */
  133165. getClassName(): string;
  133166. /**
  133167. * Gets the seed input component
  133168. */
  133169. get seed(): NodeMaterialConnectionPoint;
  133170. /**
  133171. * Gets the jitter input component
  133172. */
  133173. get jitter(): NodeMaterialConnectionPoint;
  133174. /**
  133175. * Gets the output component
  133176. */
  133177. get output(): NodeMaterialConnectionPoint;
  133178. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133179. /**
  133180. * Exposes the properties to the UI?
  133181. */
  133182. protected _dumpPropertiesCode(): string;
  133183. /**
  133184. * Exposes the properties to the Seralize?
  133185. */
  133186. serialize(): any;
  133187. /**
  133188. * Exposes the properties to the deseralize?
  133189. */
  133190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133191. }
  133192. }
  133193. declare module BABYLON {
  133194. /**
  133195. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133196. */
  133197. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133198. /**
  133199. * Creates a new SimplexPerlin3DBlock
  133200. * @param name defines the block name
  133201. */
  133202. constructor(name: string);
  133203. /**
  133204. * Gets the current class name
  133205. * @returns the class name
  133206. */
  133207. getClassName(): string;
  133208. /**
  133209. * Gets the seed operand input component
  133210. */
  133211. get seed(): NodeMaterialConnectionPoint;
  133212. /**
  133213. * Gets the output component
  133214. */
  133215. get output(): NodeMaterialConnectionPoint;
  133216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133217. }
  133218. }
  133219. declare module BABYLON {
  133220. /**
  133221. * Block used to blend normals
  133222. */
  133223. export class NormalBlendBlock extends NodeMaterialBlock {
  133224. /**
  133225. * Creates a new NormalBlendBlock
  133226. * @param name defines the block name
  133227. */
  133228. constructor(name: string);
  133229. /**
  133230. * Gets the current class name
  133231. * @returns the class name
  133232. */
  133233. getClassName(): string;
  133234. /**
  133235. * Gets the first input component
  133236. */
  133237. get normalMap0(): NodeMaterialConnectionPoint;
  133238. /**
  133239. * Gets the second input component
  133240. */
  133241. get normalMap1(): NodeMaterialConnectionPoint;
  133242. /**
  133243. * Gets the output component
  133244. */
  133245. get output(): NodeMaterialConnectionPoint;
  133246. protected _buildBlock(state: NodeMaterialBuildState): this;
  133247. }
  133248. }
  133249. declare module BABYLON {
  133250. /**
  133251. * Block used to rotate a 2d vector by a given angle
  133252. */
  133253. export class Rotate2dBlock extends NodeMaterialBlock {
  133254. /**
  133255. * Creates a new Rotate2dBlock
  133256. * @param name defines the block name
  133257. */
  133258. constructor(name: string);
  133259. /**
  133260. * Gets the current class name
  133261. * @returns the class name
  133262. */
  133263. getClassName(): string;
  133264. /**
  133265. * Gets the input vector
  133266. */
  133267. get input(): NodeMaterialConnectionPoint;
  133268. /**
  133269. * Gets the input angle
  133270. */
  133271. get angle(): NodeMaterialConnectionPoint;
  133272. /**
  133273. * Gets the output component
  133274. */
  133275. get output(): NodeMaterialConnectionPoint;
  133276. autoConfigure(material: NodeMaterial): void;
  133277. protected _buildBlock(state: NodeMaterialBuildState): this;
  133278. }
  133279. }
  133280. declare module BABYLON {
  133281. /**
  133282. * Block used to get the reflected vector from a direction and a normal
  133283. */
  133284. export class ReflectBlock extends NodeMaterialBlock {
  133285. /**
  133286. * Creates a new ReflectBlock
  133287. * @param name defines the block name
  133288. */
  133289. constructor(name: string);
  133290. /**
  133291. * Gets the current class name
  133292. * @returns the class name
  133293. */
  133294. getClassName(): string;
  133295. /**
  133296. * Gets the incident component
  133297. */
  133298. get incident(): NodeMaterialConnectionPoint;
  133299. /**
  133300. * Gets the normal component
  133301. */
  133302. get normal(): NodeMaterialConnectionPoint;
  133303. /**
  133304. * Gets the output component
  133305. */
  133306. get output(): NodeMaterialConnectionPoint;
  133307. protected _buildBlock(state: NodeMaterialBuildState): this;
  133308. }
  133309. }
  133310. declare module BABYLON {
  133311. /**
  133312. * Block used to get the refracted vector from a direction and a normal
  133313. */
  133314. export class RefractBlock extends NodeMaterialBlock {
  133315. /**
  133316. * Creates a new RefractBlock
  133317. * @param name defines the block name
  133318. */
  133319. constructor(name: string);
  133320. /**
  133321. * Gets the current class name
  133322. * @returns the class name
  133323. */
  133324. getClassName(): string;
  133325. /**
  133326. * Gets the incident component
  133327. */
  133328. get incident(): NodeMaterialConnectionPoint;
  133329. /**
  133330. * Gets the normal component
  133331. */
  133332. get normal(): NodeMaterialConnectionPoint;
  133333. /**
  133334. * Gets the index of refraction component
  133335. */
  133336. get ior(): NodeMaterialConnectionPoint;
  133337. /**
  133338. * Gets the output component
  133339. */
  133340. get output(): NodeMaterialConnectionPoint;
  133341. protected _buildBlock(state: NodeMaterialBuildState): this;
  133342. }
  133343. }
  133344. declare module BABYLON {
  133345. /**
  133346. * Block used to desaturate a color
  133347. */
  133348. export class DesaturateBlock extends NodeMaterialBlock {
  133349. /**
  133350. * Creates a new DesaturateBlock
  133351. * @param name defines the block name
  133352. */
  133353. constructor(name: string);
  133354. /**
  133355. * Gets the current class name
  133356. * @returns the class name
  133357. */
  133358. getClassName(): string;
  133359. /**
  133360. * Gets the color operand input component
  133361. */
  133362. get color(): NodeMaterialConnectionPoint;
  133363. /**
  133364. * Gets the level operand input component
  133365. */
  133366. get level(): NodeMaterialConnectionPoint;
  133367. /**
  133368. * Gets the output component
  133369. */
  133370. get output(): NodeMaterialConnectionPoint;
  133371. protected _buildBlock(state: NodeMaterialBuildState): this;
  133372. }
  133373. }
  133374. declare module BABYLON {
  133375. /**
  133376. * Effect Render Options
  133377. */
  133378. export interface IEffectRendererOptions {
  133379. /**
  133380. * Defines the vertices positions.
  133381. */
  133382. positions?: number[];
  133383. /**
  133384. * Defines the indices.
  133385. */
  133386. indices?: number[];
  133387. }
  133388. /**
  133389. * Helper class to render one or more effects
  133390. */
  133391. export class EffectRenderer {
  133392. private engine;
  133393. private static _DefaultOptions;
  133394. private _vertexBuffers;
  133395. private _indexBuffer;
  133396. private _ringBufferIndex;
  133397. private _ringScreenBuffer;
  133398. private _fullscreenViewport;
  133399. private _getNextFrameBuffer;
  133400. /**
  133401. * Creates an effect renderer
  133402. * @param engine the engine to use for rendering
  133403. * @param options defines the options of the effect renderer
  133404. */
  133405. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133406. /**
  133407. * Sets the current viewport in normalized coordinates 0-1
  133408. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133409. */
  133410. setViewport(viewport?: Viewport): void;
  133411. /**
  133412. * Binds the embedded attributes buffer to the effect.
  133413. * @param effect Defines the effect to bind the attributes for
  133414. */
  133415. bindBuffers(effect: Effect): void;
  133416. /**
  133417. * Sets the current effect wrapper to use during draw.
  133418. * The effect needs to be ready before calling this api.
  133419. * This also sets the default full screen position attribute.
  133420. * @param effectWrapper Defines the effect to draw with
  133421. */
  133422. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133423. /**
  133424. * Draws a full screen quad.
  133425. */
  133426. draw(): void;
  133427. /**
  133428. * renders one or more effects to a specified texture
  133429. * @param effectWrappers list of effects to renderer
  133430. * @param outputTexture texture to draw to, if null it will render to the screen
  133431. */
  133432. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133433. /**
  133434. * Disposes of the effect renderer
  133435. */
  133436. dispose(): void;
  133437. }
  133438. /**
  133439. * Options to create an EffectWrapper
  133440. */
  133441. interface EffectWrapperCreationOptions {
  133442. /**
  133443. * Engine to use to create the effect
  133444. */
  133445. engine: ThinEngine;
  133446. /**
  133447. * Fragment shader for the effect
  133448. */
  133449. fragmentShader: string;
  133450. /**
  133451. * Vertex shader for the effect
  133452. */
  133453. vertexShader?: string;
  133454. /**
  133455. * Attributes to use in the shader
  133456. */
  133457. attributeNames?: Array<string>;
  133458. /**
  133459. * Uniforms to use in the shader
  133460. */
  133461. uniformNames?: Array<string>;
  133462. /**
  133463. * Texture sampler names to use in the shader
  133464. */
  133465. samplerNames?: Array<string>;
  133466. /**
  133467. * The friendly name of the effect displayed in Spector.
  133468. */
  133469. name?: string;
  133470. }
  133471. /**
  133472. * Wraps an effect to be used for rendering
  133473. */
  133474. export class EffectWrapper {
  133475. /**
  133476. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133477. */
  133478. onApplyObservable: Observable<{}>;
  133479. /**
  133480. * The underlying effect
  133481. */
  133482. effect: Effect;
  133483. /**
  133484. * Creates an effect to be renderer
  133485. * @param creationOptions options to create the effect
  133486. */
  133487. constructor(creationOptions: EffectWrapperCreationOptions);
  133488. /**
  133489. * Disposes of the effect wrapper
  133490. */
  133491. dispose(): void;
  133492. }
  133493. }
  133494. declare module BABYLON {
  133495. /**
  133496. * Helper class to push actions to a pool of workers.
  133497. */
  133498. export class WorkerPool implements IDisposable {
  133499. private _workerInfos;
  133500. private _pendingActions;
  133501. /**
  133502. * Constructor
  133503. * @param workers Array of workers to use for actions
  133504. */
  133505. constructor(workers: Array<Worker>);
  133506. /**
  133507. * Terminates all workers and clears any pending actions.
  133508. */
  133509. dispose(): void;
  133510. /**
  133511. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133512. * pended until a worker has completed its action.
  133513. * @param action The action to perform. Call onComplete when the action is complete.
  133514. */
  133515. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133516. private _execute;
  133517. }
  133518. }
  133519. declare module BABYLON {
  133520. /**
  133521. * Configuration for Draco compression
  133522. */
  133523. export interface IDracoCompressionConfiguration {
  133524. /**
  133525. * Configuration for the decoder.
  133526. */
  133527. decoder: {
  133528. /**
  133529. * The url to the WebAssembly module.
  133530. */
  133531. wasmUrl?: string;
  133532. /**
  133533. * The url to the WebAssembly binary.
  133534. */
  133535. wasmBinaryUrl?: string;
  133536. /**
  133537. * The url to the fallback JavaScript module.
  133538. */
  133539. fallbackUrl?: string;
  133540. };
  133541. }
  133542. /**
  133543. * Draco compression (https://google.github.io/draco/)
  133544. *
  133545. * This class wraps the Draco module.
  133546. *
  133547. * **Encoder**
  133548. *
  133549. * The encoder is not currently implemented.
  133550. *
  133551. * **Decoder**
  133552. *
  133553. * 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.
  133554. *
  133555. * To update the configuration, use the following code:
  133556. * ```javascript
  133557. * DracoCompression.Configuration = {
  133558. * decoder: {
  133559. * wasmUrl: "<url to the WebAssembly library>",
  133560. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133561. * fallbackUrl: "<url to the fallback JavaScript library>",
  133562. * }
  133563. * };
  133564. * ```
  133565. *
  133566. * 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.
  133567. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133568. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133569. *
  133570. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133571. * ```javascript
  133572. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133573. * ```
  133574. *
  133575. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133576. */
  133577. export class DracoCompression implements IDisposable {
  133578. private _workerPoolPromise?;
  133579. private _decoderModulePromise?;
  133580. /**
  133581. * The configuration. Defaults to the following urls:
  133582. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133583. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133584. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133585. */
  133586. static Configuration: IDracoCompressionConfiguration;
  133587. /**
  133588. * Returns true if the decoder configuration is available.
  133589. */
  133590. static get DecoderAvailable(): boolean;
  133591. /**
  133592. * Default number of workers to create when creating the draco compression object.
  133593. */
  133594. static DefaultNumWorkers: number;
  133595. private static GetDefaultNumWorkers;
  133596. private static _Default;
  133597. /**
  133598. * Default instance for the draco compression object.
  133599. */
  133600. static get Default(): DracoCompression;
  133601. /**
  133602. * Constructor
  133603. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133604. */
  133605. constructor(numWorkers?: number);
  133606. /**
  133607. * Stop all async operations and release resources.
  133608. */
  133609. dispose(): void;
  133610. /**
  133611. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133612. * @returns a promise that resolves when ready
  133613. */
  133614. whenReadyAsync(): Promise<void>;
  133615. /**
  133616. * Decode Draco compressed mesh data to vertex data.
  133617. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133618. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133619. * @returns A promise that resolves with the decoded vertex data
  133620. */
  133621. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133622. [kind: string]: number;
  133623. }): Promise<VertexData>;
  133624. }
  133625. }
  133626. declare module BABYLON {
  133627. /**
  133628. * Class for building Constructive Solid Geometry
  133629. */
  133630. export class CSG {
  133631. private polygons;
  133632. /**
  133633. * The world matrix
  133634. */
  133635. matrix: Matrix;
  133636. /**
  133637. * Stores the position
  133638. */
  133639. position: Vector3;
  133640. /**
  133641. * Stores the rotation
  133642. */
  133643. rotation: Vector3;
  133644. /**
  133645. * Stores the rotation quaternion
  133646. */
  133647. rotationQuaternion: Nullable<Quaternion>;
  133648. /**
  133649. * Stores the scaling vector
  133650. */
  133651. scaling: Vector3;
  133652. /**
  133653. * Convert the Mesh to CSG
  133654. * @param mesh The Mesh to convert to CSG
  133655. * @returns A new CSG from the Mesh
  133656. */
  133657. static FromMesh(mesh: Mesh): CSG;
  133658. /**
  133659. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133660. * @param polygons Polygons used to construct a CSG solid
  133661. */
  133662. private static FromPolygons;
  133663. /**
  133664. * Clones, or makes a deep copy, of the CSG
  133665. * @returns A new CSG
  133666. */
  133667. clone(): CSG;
  133668. /**
  133669. * Unions this CSG with another CSG
  133670. * @param csg The CSG to union against this CSG
  133671. * @returns The unioned CSG
  133672. */
  133673. union(csg: CSG): CSG;
  133674. /**
  133675. * Unions this CSG with another CSG in place
  133676. * @param csg The CSG to union against this CSG
  133677. */
  133678. unionInPlace(csg: CSG): void;
  133679. /**
  133680. * Subtracts this CSG with another CSG
  133681. * @param csg The CSG to subtract against this CSG
  133682. * @returns A new CSG
  133683. */
  133684. subtract(csg: CSG): CSG;
  133685. /**
  133686. * Subtracts this CSG with another CSG in place
  133687. * @param csg The CSG to subtact against this CSG
  133688. */
  133689. subtractInPlace(csg: CSG): void;
  133690. /**
  133691. * Intersect this CSG with another CSG
  133692. * @param csg The CSG to intersect against this CSG
  133693. * @returns A new CSG
  133694. */
  133695. intersect(csg: CSG): CSG;
  133696. /**
  133697. * Intersects this CSG with another CSG in place
  133698. * @param csg The CSG to intersect against this CSG
  133699. */
  133700. intersectInPlace(csg: CSG): void;
  133701. /**
  133702. * Return a new CSG solid with solid and empty space switched. This solid is
  133703. * not modified.
  133704. * @returns A new CSG solid with solid and empty space switched
  133705. */
  133706. inverse(): CSG;
  133707. /**
  133708. * Inverses the CSG in place
  133709. */
  133710. inverseInPlace(): void;
  133711. /**
  133712. * This is used to keep meshes transformations so they can be restored
  133713. * when we build back a Babylon Mesh
  133714. * NB : All CSG operations are performed in world coordinates
  133715. * @param csg The CSG to copy the transform attributes from
  133716. * @returns This CSG
  133717. */
  133718. copyTransformAttributes(csg: CSG): CSG;
  133719. /**
  133720. * Build Raw mesh from CSG
  133721. * Coordinates here are in world space
  133722. * @param name The name of the mesh geometry
  133723. * @param scene The Scene
  133724. * @param keepSubMeshes Specifies if the submeshes should be kept
  133725. * @returns A new Mesh
  133726. */
  133727. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133728. /**
  133729. * Build Mesh from CSG taking material and transforms into account
  133730. * @param name The name of the Mesh
  133731. * @param material The material of the Mesh
  133732. * @param scene The Scene
  133733. * @param keepSubMeshes Specifies if submeshes should be kept
  133734. * @returns The new Mesh
  133735. */
  133736. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133737. }
  133738. }
  133739. declare module BABYLON {
  133740. /**
  133741. * Class used to create a trail following a mesh
  133742. */
  133743. export class TrailMesh extends Mesh {
  133744. private _generator;
  133745. private _autoStart;
  133746. private _running;
  133747. private _diameter;
  133748. private _length;
  133749. private _sectionPolygonPointsCount;
  133750. private _sectionVectors;
  133751. private _sectionNormalVectors;
  133752. private _beforeRenderObserver;
  133753. /**
  133754. * @constructor
  133755. * @param name The value used by scene.getMeshByName() to do a lookup.
  133756. * @param generator The mesh or transform node to generate a trail.
  133757. * @param scene The scene to add this mesh to.
  133758. * @param diameter Diameter of trailing mesh. Default is 1.
  133759. * @param length Length of trailing mesh. Default is 60.
  133760. * @param autoStart Automatically start trailing mesh. Default true.
  133761. */
  133762. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133763. /**
  133764. * "TrailMesh"
  133765. * @returns "TrailMesh"
  133766. */
  133767. getClassName(): string;
  133768. private _createMesh;
  133769. /**
  133770. * Start trailing mesh.
  133771. */
  133772. start(): void;
  133773. /**
  133774. * Stop trailing mesh.
  133775. */
  133776. stop(): void;
  133777. /**
  133778. * Update trailing mesh geometry.
  133779. */
  133780. update(): void;
  133781. /**
  133782. * Returns a new TrailMesh object.
  133783. * @param name is a string, the name given to the new mesh
  133784. * @param newGenerator use new generator object for cloned trail mesh
  133785. * @returns a new mesh
  133786. */
  133787. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133788. /**
  133789. * Serializes this trail mesh
  133790. * @param serializationObject object to write serialization to
  133791. */
  133792. serialize(serializationObject: any): void;
  133793. /**
  133794. * Parses a serialized trail mesh
  133795. * @param parsedMesh the serialized mesh
  133796. * @param scene the scene to create the trail mesh in
  133797. * @returns the created trail mesh
  133798. */
  133799. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133800. }
  133801. }
  133802. declare module BABYLON {
  133803. /**
  133804. * Class containing static functions to help procedurally build meshes
  133805. */
  133806. export class TiledBoxBuilder {
  133807. /**
  133808. * Creates a box mesh
  133809. * 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)
  133810. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133814. * @param name defines the name of the mesh
  133815. * @param options defines the options used to create the mesh
  133816. * @param scene defines the hosting scene
  133817. * @returns the box mesh
  133818. */
  133819. static CreateTiledBox(name: string, options: {
  133820. pattern?: number;
  133821. width?: number;
  133822. height?: number;
  133823. depth?: number;
  133824. tileSize?: number;
  133825. tileWidth?: number;
  133826. tileHeight?: number;
  133827. alignHorizontal?: number;
  133828. alignVertical?: number;
  133829. faceUV?: Vector4[];
  133830. faceColors?: Color4[];
  133831. sideOrientation?: number;
  133832. updatable?: boolean;
  133833. }, scene?: Nullable<Scene>): Mesh;
  133834. }
  133835. }
  133836. declare module BABYLON {
  133837. /**
  133838. * Class containing static functions to help procedurally build meshes
  133839. */
  133840. export class TorusKnotBuilder {
  133841. /**
  133842. * Creates a torus knot mesh
  133843. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133844. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133845. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133846. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133847. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133848. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133850. * @param name defines the name of the mesh
  133851. * @param options defines the options used to create the mesh
  133852. * @param scene defines the hosting scene
  133853. * @returns the torus knot mesh
  133854. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133855. */
  133856. static CreateTorusKnot(name: string, options: {
  133857. radius?: number;
  133858. tube?: number;
  133859. radialSegments?: number;
  133860. tubularSegments?: number;
  133861. p?: number;
  133862. q?: number;
  133863. updatable?: boolean;
  133864. sideOrientation?: number;
  133865. frontUVs?: Vector4;
  133866. backUVs?: Vector4;
  133867. }, scene: any): Mesh;
  133868. }
  133869. }
  133870. declare module BABYLON {
  133871. /**
  133872. * Polygon
  133873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133874. */
  133875. export class Polygon {
  133876. /**
  133877. * Creates a rectangle
  133878. * @param xmin bottom X coord
  133879. * @param ymin bottom Y coord
  133880. * @param xmax top X coord
  133881. * @param ymax top Y coord
  133882. * @returns points that make the resulting rectation
  133883. */
  133884. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133885. /**
  133886. * Creates a circle
  133887. * @param radius radius of circle
  133888. * @param cx scale in x
  133889. * @param cy scale in y
  133890. * @param numberOfSides number of sides that make up the circle
  133891. * @returns points that make the resulting circle
  133892. */
  133893. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133894. /**
  133895. * Creates a polygon from input string
  133896. * @param input Input polygon data
  133897. * @returns the parsed points
  133898. */
  133899. static Parse(input: string): Vector2[];
  133900. /**
  133901. * Starts building a polygon from x and y coordinates
  133902. * @param x x coordinate
  133903. * @param y y coordinate
  133904. * @returns the started path2
  133905. */
  133906. static StartingAt(x: number, y: number): Path2;
  133907. }
  133908. /**
  133909. * Builds a polygon
  133910. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133911. */
  133912. export class PolygonMeshBuilder {
  133913. private _points;
  133914. private _outlinepoints;
  133915. private _holes;
  133916. private _name;
  133917. private _scene;
  133918. private _epoints;
  133919. private _eholes;
  133920. private _addToepoint;
  133921. /**
  133922. * Babylon reference to the earcut plugin.
  133923. */
  133924. bjsEarcut: any;
  133925. /**
  133926. * Creates a PolygonMeshBuilder
  133927. * @param name name of the builder
  133928. * @param contours Path of the polygon
  133929. * @param scene scene to add to when creating the mesh
  133930. * @param earcutInjection can be used to inject your own earcut reference
  133931. */
  133932. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133933. /**
  133934. * Adds a whole within the polygon
  133935. * @param hole Array of points defining the hole
  133936. * @returns this
  133937. */
  133938. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133939. /**
  133940. * Creates the polygon
  133941. * @param updatable If the mesh should be updatable
  133942. * @param depth The depth of the mesh created
  133943. * @returns the created mesh
  133944. */
  133945. build(updatable?: boolean, depth?: number): Mesh;
  133946. /**
  133947. * Creates the polygon
  133948. * @param depth The depth of the mesh created
  133949. * @returns the created VertexData
  133950. */
  133951. buildVertexData(depth?: number): VertexData;
  133952. /**
  133953. * Adds a side to the polygon
  133954. * @param positions points that make the polygon
  133955. * @param normals normals of the polygon
  133956. * @param uvs uvs of the polygon
  133957. * @param indices indices of the polygon
  133958. * @param bounds bounds of the polygon
  133959. * @param points points of the polygon
  133960. * @param depth depth of the polygon
  133961. * @param flip flip of the polygon
  133962. */
  133963. private addSide;
  133964. }
  133965. }
  133966. declare module BABYLON {
  133967. /**
  133968. * Class containing static functions to help procedurally build meshes
  133969. */
  133970. export class PolygonBuilder {
  133971. /**
  133972. * Creates a polygon mesh
  133973. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133974. * * 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
  133975. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133978. * * Remember you can only change the shape positions, not their number when updating a polygon
  133979. * @param name defines the name of the mesh
  133980. * @param options defines the options used to create the mesh
  133981. * @param scene defines the hosting scene
  133982. * @param earcutInjection can be used to inject your own earcut reference
  133983. * @returns the polygon mesh
  133984. */
  133985. static CreatePolygon(name: string, options: {
  133986. shape: Vector3[];
  133987. holes?: Vector3[][];
  133988. depth?: number;
  133989. faceUV?: Vector4[];
  133990. faceColors?: Color4[];
  133991. updatable?: boolean;
  133992. sideOrientation?: number;
  133993. frontUVs?: Vector4;
  133994. backUVs?: Vector4;
  133995. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133996. /**
  133997. * Creates an extruded polygon mesh, with depth in the Y direction.
  133998. * * 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)
  133999. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134000. * @param name defines the name of the mesh
  134001. * @param options defines the options used to create the mesh
  134002. * @param scene defines the hosting scene
  134003. * @param earcutInjection can be used to inject your own earcut reference
  134004. * @returns the polygon mesh
  134005. */
  134006. static ExtrudePolygon(name: string, options: {
  134007. shape: Vector3[];
  134008. holes?: Vector3[][];
  134009. depth?: number;
  134010. faceUV?: Vector4[];
  134011. faceColors?: Color4[];
  134012. updatable?: boolean;
  134013. sideOrientation?: number;
  134014. frontUVs?: Vector4;
  134015. backUVs?: Vector4;
  134016. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134017. }
  134018. }
  134019. declare module BABYLON {
  134020. /**
  134021. * Class containing static functions to help procedurally build meshes
  134022. */
  134023. export class LatheBuilder {
  134024. /**
  134025. * Creates lathe mesh.
  134026. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134027. * * 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
  134028. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134029. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134030. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134031. * * 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
  134032. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134033. * * 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
  134034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134038. * @param name defines the name of the mesh
  134039. * @param options defines the options used to create the mesh
  134040. * @param scene defines the hosting scene
  134041. * @returns the lathe mesh
  134042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134043. */
  134044. static CreateLathe(name: string, options: {
  134045. shape: Vector3[];
  134046. radius?: number;
  134047. tessellation?: number;
  134048. clip?: number;
  134049. arc?: number;
  134050. closed?: boolean;
  134051. updatable?: boolean;
  134052. sideOrientation?: number;
  134053. frontUVs?: Vector4;
  134054. backUVs?: Vector4;
  134055. cap?: number;
  134056. invertUV?: boolean;
  134057. }, scene?: Nullable<Scene>): Mesh;
  134058. }
  134059. }
  134060. declare module BABYLON {
  134061. /**
  134062. * Class containing static functions to help procedurally build meshes
  134063. */
  134064. export class TiledPlaneBuilder {
  134065. /**
  134066. * Creates a tiled plane mesh
  134067. * * The parameter `pattern` will, depending on value, do nothing or
  134068. * * * flip (reflect about central vertical) alternate tiles across and up
  134069. * * * flip every tile on alternate rows
  134070. * * * rotate (180 degs) alternate tiles across and up
  134071. * * * rotate every tile on alternate rows
  134072. * * * flip and rotate alternate tiles across and up
  134073. * * * flip and rotate every tile on alternate rows
  134074. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134075. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134077. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134078. * * 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)
  134079. * * 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)
  134080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134081. * @param name defines the name of the mesh
  134082. * @param options defines the options used to create the mesh
  134083. * @param scene defines the hosting scene
  134084. * @returns the box mesh
  134085. */
  134086. static CreateTiledPlane(name: string, options: {
  134087. pattern?: number;
  134088. tileSize?: number;
  134089. tileWidth?: number;
  134090. tileHeight?: number;
  134091. size?: number;
  134092. width?: number;
  134093. height?: number;
  134094. alignHorizontal?: number;
  134095. alignVertical?: number;
  134096. sideOrientation?: number;
  134097. frontUVs?: Vector4;
  134098. backUVs?: Vector4;
  134099. updatable?: boolean;
  134100. }, scene?: Nullable<Scene>): Mesh;
  134101. }
  134102. }
  134103. declare module BABYLON {
  134104. /**
  134105. * Class containing static functions to help procedurally build meshes
  134106. */
  134107. export class TubeBuilder {
  134108. /**
  134109. * Creates a tube mesh.
  134110. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134111. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134112. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134113. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134114. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134115. * * 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)
  134116. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134117. * * 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
  134118. * * 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
  134119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134123. * @param name defines the name of the mesh
  134124. * @param options defines the options used to create the mesh
  134125. * @param scene defines the hosting scene
  134126. * @returns the tube mesh
  134127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134128. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134129. */
  134130. static CreateTube(name: string, options: {
  134131. path: Vector3[];
  134132. radius?: number;
  134133. tessellation?: number;
  134134. radiusFunction?: {
  134135. (i: number, distance: number): number;
  134136. };
  134137. cap?: number;
  134138. arc?: number;
  134139. updatable?: boolean;
  134140. sideOrientation?: number;
  134141. frontUVs?: Vector4;
  134142. backUVs?: Vector4;
  134143. instance?: Mesh;
  134144. invertUV?: boolean;
  134145. }, scene?: Nullable<Scene>): Mesh;
  134146. }
  134147. }
  134148. declare module BABYLON {
  134149. /**
  134150. * Class containing static functions to help procedurally build meshes
  134151. */
  134152. export class IcoSphereBuilder {
  134153. /**
  134154. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134155. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134156. * * 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`)
  134157. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134158. * * 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
  134159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134162. * @param name defines the name of the mesh
  134163. * @param options defines the options used to create the mesh
  134164. * @param scene defines the hosting scene
  134165. * @returns the icosahedron mesh
  134166. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134167. */
  134168. static CreateIcoSphere(name: string, options: {
  134169. radius?: number;
  134170. radiusX?: number;
  134171. radiusY?: number;
  134172. radiusZ?: number;
  134173. flat?: boolean;
  134174. subdivisions?: number;
  134175. sideOrientation?: number;
  134176. frontUVs?: Vector4;
  134177. backUVs?: Vector4;
  134178. updatable?: boolean;
  134179. }, scene?: Nullable<Scene>): Mesh;
  134180. }
  134181. }
  134182. declare module BABYLON {
  134183. /**
  134184. * Class containing static functions to help procedurally build meshes
  134185. */
  134186. export class DecalBuilder {
  134187. /**
  134188. * Creates a decal mesh.
  134189. * 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
  134190. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134191. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134192. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134193. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134194. * @param name defines the name of the mesh
  134195. * @param sourceMesh defines the mesh where the decal must be applied
  134196. * @param options defines the options used to create the mesh
  134197. * @param scene defines the hosting scene
  134198. * @returns the decal mesh
  134199. * @see https://doc.babylonjs.com/how_to/decals
  134200. */
  134201. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134202. position?: Vector3;
  134203. normal?: Vector3;
  134204. size?: Vector3;
  134205. angle?: number;
  134206. }): Mesh;
  134207. }
  134208. }
  134209. declare module BABYLON {
  134210. /**
  134211. * Class containing static functions to help procedurally build meshes
  134212. */
  134213. export class MeshBuilder {
  134214. /**
  134215. * Creates a box mesh
  134216. * * The parameter `size` sets the size (float) of each box side (default 1)
  134217. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134218. * * 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)
  134219. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134223. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134224. * @param name defines the name of the mesh
  134225. * @param options defines the options used to create the mesh
  134226. * @param scene defines the hosting scene
  134227. * @returns the box mesh
  134228. */
  134229. static CreateBox(name: string, options: {
  134230. size?: number;
  134231. width?: number;
  134232. height?: number;
  134233. depth?: number;
  134234. faceUV?: Vector4[];
  134235. faceColors?: Color4[];
  134236. sideOrientation?: number;
  134237. frontUVs?: Vector4;
  134238. backUVs?: Vector4;
  134239. updatable?: boolean;
  134240. }, scene?: Nullable<Scene>): Mesh;
  134241. /**
  134242. * Creates a tiled box mesh
  134243. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134245. * @param name defines the name of the mesh
  134246. * @param options defines the options used to create the mesh
  134247. * @param scene defines the hosting scene
  134248. * @returns the tiled box mesh
  134249. */
  134250. static CreateTiledBox(name: string, options: {
  134251. pattern?: number;
  134252. size?: number;
  134253. width?: number;
  134254. height?: number;
  134255. depth: number;
  134256. tileSize?: number;
  134257. tileWidth?: number;
  134258. tileHeight?: number;
  134259. faceUV?: Vector4[];
  134260. faceColors?: Color4[];
  134261. alignHorizontal?: number;
  134262. alignVertical?: number;
  134263. sideOrientation?: number;
  134264. updatable?: boolean;
  134265. }, scene?: Nullable<Scene>): Mesh;
  134266. /**
  134267. * Creates a sphere mesh
  134268. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134269. * * 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`)
  134270. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134271. * * 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
  134272. * * 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)
  134273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134276. * @param name defines the name of the mesh
  134277. * @param options defines the options used to create the mesh
  134278. * @param scene defines the hosting scene
  134279. * @returns the sphere mesh
  134280. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134281. */
  134282. static CreateSphere(name: string, options: {
  134283. segments?: number;
  134284. diameter?: number;
  134285. diameterX?: number;
  134286. diameterY?: number;
  134287. diameterZ?: number;
  134288. arc?: number;
  134289. slice?: number;
  134290. sideOrientation?: number;
  134291. frontUVs?: Vector4;
  134292. backUVs?: Vector4;
  134293. updatable?: boolean;
  134294. }, scene?: Nullable<Scene>): Mesh;
  134295. /**
  134296. * Creates a plane polygonal mesh. By default, this is a disc
  134297. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134298. * * 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
  134299. * * 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
  134300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134303. * @param name defines the name of the mesh
  134304. * @param options defines the options used to create the mesh
  134305. * @param scene defines the hosting scene
  134306. * @returns the plane polygonal mesh
  134307. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134308. */
  134309. static CreateDisc(name: string, options: {
  134310. radius?: number;
  134311. tessellation?: number;
  134312. arc?: number;
  134313. updatable?: boolean;
  134314. sideOrientation?: number;
  134315. frontUVs?: Vector4;
  134316. backUVs?: Vector4;
  134317. }, scene?: Nullable<Scene>): Mesh;
  134318. /**
  134319. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134320. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134321. * * 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`)
  134322. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134323. * * 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
  134324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134327. * @param name defines the name of the mesh
  134328. * @param options defines the options used to create the mesh
  134329. * @param scene defines the hosting scene
  134330. * @returns the icosahedron mesh
  134331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134332. */
  134333. static CreateIcoSphere(name: string, options: {
  134334. radius?: number;
  134335. radiusX?: number;
  134336. radiusY?: number;
  134337. radiusZ?: number;
  134338. flat?: boolean;
  134339. subdivisions?: number;
  134340. sideOrientation?: number;
  134341. frontUVs?: Vector4;
  134342. backUVs?: Vector4;
  134343. updatable?: boolean;
  134344. }, scene?: Nullable<Scene>): Mesh;
  134345. /**
  134346. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134347. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134348. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134349. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134350. * * 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
  134351. * * 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
  134352. * * 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
  134353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134355. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134356. * * 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
  134357. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134358. * * 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
  134359. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134361. * @param name defines the name of the mesh
  134362. * @param options defines the options used to create the mesh
  134363. * @param scene defines the hosting scene
  134364. * @returns the ribbon mesh
  134365. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134367. */
  134368. static CreateRibbon(name: string, options: {
  134369. pathArray: Vector3[][];
  134370. closeArray?: boolean;
  134371. closePath?: boolean;
  134372. offset?: number;
  134373. updatable?: boolean;
  134374. sideOrientation?: number;
  134375. frontUVs?: Vector4;
  134376. backUVs?: Vector4;
  134377. instance?: Mesh;
  134378. invertUV?: boolean;
  134379. uvs?: Vector2[];
  134380. colors?: Color4[];
  134381. }, scene?: Nullable<Scene>): Mesh;
  134382. /**
  134383. * Creates a cylinder or a cone mesh
  134384. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134385. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134386. * * 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.
  134387. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134388. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134389. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134390. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134391. * * 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).
  134392. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134393. * * 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).
  134394. * * 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
  134395. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134396. * * 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
  134397. * * 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.
  134398. * * If `enclose` is false, a ring surface is one element.
  134399. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134400. * * 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
  134401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134404. * @param name defines the name of the mesh
  134405. * @param options defines the options used to create the mesh
  134406. * @param scene defines the hosting scene
  134407. * @returns the cylinder mesh
  134408. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134409. */
  134410. static CreateCylinder(name: string, options: {
  134411. height?: number;
  134412. diameterTop?: number;
  134413. diameterBottom?: number;
  134414. diameter?: number;
  134415. tessellation?: number;
  134416. subdivisions?: number;
  134417. arc?: number;
  134418. faceColors?: Color4[];
  134419. faceUV?: Vector4[];
  134420. updatable?: boolean;
  134421. hasRings?: boolean;
  134422. enclose?: boolean;
  134423. cap?: number;
  134424. sideOrientation?: number;
  134425. frontUVs?: Vector4;
  134426. backUVs?: Vector4;
  134427. }, scene?: Nullable<Scene>): Mesh;
  134428. /**
  134429. * Creates a torus mesh
  134430. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134431. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134432. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134436. * @param name defines the name of the mesh
  134437. * @param options defines the options used to create the mesh
  134438. * @param scene defines the hosting scene
  134439. * @returns the torus mesh
  134440. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134441. */
  134442. static CreateTorus(name: string, options: {
  134443. diameter?: number;
  134444. thickness?: number;
  134445. tessellation?: number;
  134446. updatable?: boolean;
  134447. sideOrientation?: number;
  134448. frontUVs?: Vector4;
  134449. backUVs?: Vector4;
  134450. }, scene?: Nullable<Scene>): Mesh;
  134451. /**
  134452. * Creates a torus knot mesh
  134453. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134454. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134455. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134456. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134460. * @param name defines the name of the mesh
  134461. * @param options defines the options used to create the mesh
  134462. * @param scene defines the hosting scene
  134463. * @returns the torus knot mesh
  134464. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134465. */
  134466. static CreateTorusKnot(name: string, options: {
  134467. radius?: number;
  134468. tube?: number;
  134469. radialSegments?: number;
  134470. tubularSegments?: number;
  134471. p?: number;
  134472. q?: number;
  134473. updatable?: boolean;
  134474. sideOrientation?: number;
  134475. frontUVs?: Vector4;
  134476. backUVs?: Vector4;
  134477. }, scene?: Nullable<Scene>): Mesh;
  134478. /**
  134479. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134480. * * 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
  134481. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134482. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134483. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134484. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134485. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134486. * * 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
  134487. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134490. * @param name defines the name of the new line system
  134491. * @param options defines the options used to create the line system
  134492. * @param scene defines the hosting scene
  134493. * @returns a new line system mesh
  134494. */
  134495. static CreateLineSystem(name: string, options: {
  134496. lines: Vector3[][];
  134497. updatable?: boolean;
  134498. instance?: Nullable<LinesMesh>;
  134499. colors?: Nullable<Color4[][]>;
  134500. useVertexAlpha?: boolean;
  134501. }, scene: Nullable<Scene>): LinesMesh;
  134502. /**
  134503. * Creates a line mesh
  134504. * 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
  134505. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134506. * * The parameter `points` is an array successive Vector3
  134507. * * 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
  134508. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134509. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134510. * * When updating an instance, remember that only point positions can change, not the number of points
  134511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134513. * @param name defines the name of the new line system
  134514. * @param options defines the options used to create the line system
  134515. * @param scene defines the hosting scene
  134516. * @returns a new line mesh
  134517. */
  134518. static CreateLines(name: string, options: {
  134519. points: Vector3[];
  134520. updatable?: boolean;
  134521. instance?: Nullable<LinesMesh>;
  134522. colors?: Color4[];
  134523. useVertexAlpha?: boolean;
  134524. }, scene?: Nullable<Scene>): LinesMesh;
  134525. /**
  134526. * Creates a dashed line mesh
  134527. * * 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
  134528. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134529. * * The parameter `points` is an array successive Vector3
  134530. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134531. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134532. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134533. * * 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
  134534. * * When updating an instance, remember that only point positions can change, not the number of points
  134535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134536. * @param name defines the name of the mesh
  134537. * @param options defines the options used to create the mesh
  134538. * @param scene defines the hosting scene
  134539. * @returns the dashed line mesh
  134540. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134541. */
  134542. static CreateDashedLines(name: string, options: {
  134543. points: Vector3[];
  134544. dashSize?: number;
  134545. gapSize?: number;
  134546. dashNb?: number;
  134547. updatable?: boolean;
  134548. instance?: LinesMesh;
  134549. }, scene?: Nullable<Scene>): LinesMesh;
  134550. /**
  134551. * 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.
  134552. * * 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.
  134553. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134554. * * 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.
  134555. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134556. * * 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
  134557. * * 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
  134558. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134561. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134563. * @param name defines the name of the mesh
  134564. * @param options defines the options used to create the mesh
  134565. * @param scene defines the hosting scene
  134566. * @returns the extruded shape mesh
  134567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134569. */
  134570. static ExtrudeShape(name: string, options: {
  134571. shape: Vector3[];
  134572. path: Vector3[];
  134573. scale?: number;
  134574. rotation?: number;
  134575. cap?: number;
  134576. updatable?: boolean;
  134577. sideOrientation?: number;
  134578. frontUVs?: Vector4;
  134579. backUVs?: Vector4;
  134580. instance?: Mesh;
  134581. invertUV?: boolean;
  134582. }, scene?: Nullable<Scene>): Mesh;
  134583. /**
  134584. * Creates an custom extruded shape mesh.
  134585. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134586. * * 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.
  134587. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134588. * * 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
  134589. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134590. * * 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
  134591. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134592. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134593. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134594. * * 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
  134595. * * 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
  134596. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134599. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134601. * @param name defines the name of the mesh
  134602. * @param options defines the options used to create the mesh
  134603. * @param scene defines the hosting scene
  134604. * @returns the custom extruded shape mesh
  134605. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134606. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134607. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134608. */
  134609. static ExtrudeShapeCustom(name: string, options: {
  134610. shape: Vector3[];
  134611. path: Vector3[];
  134612. scaleFunction?: any;
  134613. rotationFunction?: any;
  134614. ribbonCloseArray?: boolean;
  134615. ribbonClosePath?: boolean;
  134616. cap?: number;
  134617. updatable?: boolean;
  134618. sideOrientation?: number;
  134619. frontUVs?: Vector4;
  134620. backUVs?: Vector4;
  134621. instance?: Mesh;
  134622. invertUV?: boolean;
  134623. }, scene?: Nullable<Scene>): Mesh;
  134624. /**
  134625. * Creates lathe mesh.
  134626. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134627. * * 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
  134628. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134629. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134630. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134631. * * 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
  134632. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134633. * * 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
  134634. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134635. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134636. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134638. * @param name defines the name of the mesh
  134639. * @param options defines the options used to create the mesh
  134640. * @param scene defines the hosting scene
  134641. * @returns the lathe mesh
  134642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134643. */
  134644. static CreateLathe(name: string, options: {
  134645. shape: Vector3[];
  134646. radius?: number;
  134647. tessellation?: number;
  134648. clip?: number;
  134649. arc?: number;
  134650. closed?: boolean;
  134651. updatable?: boolean;
  134652. sideOrientation?: number;
  134653. frontUVs?: Vector4;
  134654. backUVs?: Vector4;
  134655. cap?: number;
  134656. invertUV?: boolean;
  134657. }, scene?: Nullable<Scene>): Mesh;
  134658. /**
  134659. * Creates a tiled plane mesh
  134660. * * You can set a limited pattern arrangement with the tiles
  134661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134664. * @param name defines the name of the mesh
  134665. * @param options defines the options used to create the mesh
  134666. * @param scene defines the hosting scene
  134667. * @returns the plane mesh
  134668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134669. */
  134670. static CreateTiledPlane(name: string, options: {
  134671. pattern?: number;
  134672. tileSize?: number;
  134673. tileWidth?: number;
  134674. tileHeight?: number;
  134675. size?: number;
  134676. width?: number;
  134677. height?: number;
  134678. alignHorizontal?: number;
  134679. alignVertical?: number;
  134680. sideOrientation?: number;
  134681. frontUVs?: Vector4;
  134682. backUVs?: Vector4;
  134683. updatable?: boolean;
  134684. }, scene?: Nullable<Scene>): Mesh;
  134685. /**
  134686. * Creates a plane mesh
  134687. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134688. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134689. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134693. * @param name defines the name of the mesh
  134694. * @param options defines the options used to create the mesh
  134695. * @param scene defines the hosting scene
  134696. * @returns the plane mesh
  134697. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134698. */
  134699. static CreatePlane(name: string, options: {
  134700. size?: number;
  134701. width?: number;
  134702. height?: number;
  134703. sideOrientation?: number;
  134704. frontUVs?: Vector4;
  134705. backUVs?: Vector4;
  134706. updatable?: boolean;
  134707. sourcePlane?: Plane;
  134708. }, scene?: Nullable<Scene>): Mesh;
  134709. /**
  134710. * Creates a ground mesh
  134711. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134712. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134714. * @param name defines the name of the mesh
  134715. * @param options defines the options used to create the mesh
  134716. * @param scene defines the hosting scene
  134717. * @returns the ground mesh
  134718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134719. */
  134720. static CreateGround(name: string, options: {
  134721. width?: number;
  134722. height?: number;
  134723. subdivisions?: number;
  134724. subdivisionsX?: number;
  134725. subdivisionsY?: number;
  134726. updatable?: boolean;
  134727. }, scene?: Nullable<Scene>): Mesh;
  134728. /**
  134729. * Creates a tiled ground mesh
  134730. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134731. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134732. * * 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
  134733. * * 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
  134734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134735. * @param name defines the name of the mesh
  134736. * @param options defines the options used to create the mesh
  134737. * @param scene defines the hosting scene
  134738. * @returns the tiled ground mesh
  134739. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134740. */
  134741. static CreateTiledGround(name: string, options: {
  134742. xmin: number;
  134743. zmin: number;
  134744. xmax: number;
  134745. zmax: number;
  134746. subdivisions?: {
  134747. w: number;
  134748. h: number;
  134749. };
  134750. precision?: {
  134751. w: number;
  134752. h: number;
  134753. };
  134754. updatable?: boolean;
  134755. }, scene?: Nullable<Scene>): Mesh;
  134756. /**
  134757. * Creates a ground mesh from a height map
  134758. * * The parameter `url` sets the URL of the height map image resource.
  134759. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134760. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134761. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134762. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134763. * * 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.
  134764. * * 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).
  134765. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134767. * @param name defines the name of the mesh
  134768. * @param url defines the url to the height map
  134769. * @param options defines the options used to create the mesh
  134770. * @param scene defines the hosting scene
  134771. * @returns the ground mesh
  134772. * @see https://doc.babylonjs.com/babylon101/height_map
  134773. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134774. */
  134775. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134776. width?: number;
  134777. height?: number;
  134778. subdivisions?: number;
  134779. minHeight?: number;
  134780. maxHeight?: number;
  134781. colorFilter?: Color3;
  134782. alphaFilter?: number;
  134783. updatable?: boolean;
  134784. onReady?: (mesh: GroundMesh) => void;
  134785. }, scene?: Nullable<Scene>): GroundMesh;
  134786. /**
  134787. * Creates a polygon mesh
  134788. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134789. * * 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
  134790. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134793. * * Remember you can only change the shape positions, not their number when updating a polygon
  134794. * @param name defines the name of the mesh
  134795. * @param options defines the options used to create the mesh
  134796. * @param scene defines the hosting scene
  134797. * @param earcutInjection can be used to inject your own earcut reference
  134798. * @returns the polygon mesh
  134799. */
  134800. static CreatePolygon(name: string, options: {
  134801. shape: Vector3[];
  134802. holes?: Vector3[][];
  134803. depth?: number;
  134804. faceUV?: Vector4[];
  134805. faceColors?: Color4[];
  134806. updatable?: boolean;
  134807. sideOrientation?: number;
  134808. frontUVs?: Vector4;
  134809. backUVs?: Vector4;
  134810. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134811. /**
  134812. * Creates an extruded polygon mesh, with depth in the Y direction.
  134813. * * 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)
  134814. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134815. * @param name defines the name of the mesh
  134816. * @param options defines the options used to create the mesh
  134817. * @param scene defines the hosting scene
  134818. * @param earcutInjection can be used to inject your own earcut reference
  134819. * @returns the polygon mesh
  134820. */
  134821. static ExtrudePolygon(name: string, options: {
  134822. shape: Vector3[];
  134823. holes?: Vector3[][];
  134824. depth?: number;
  134825. faceUV?: Vector4[];
  134826. faceColors?: Color4[];
  134827. updatable?: boolean;
  134828. sideOrientation?: number;
  134829. frontUVs?: Vector4;
  134830. backUVs?: Vector4;
  134831. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134832. /**
  134833. * Creates a tube mesh.
  134834. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134835. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134836. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134837. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134838. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134839. * * 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)
  134840. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134841. * * 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
  134842. * * 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
  134843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134847. * @param name defines the name of the mesh
  134848. * @param options defines the options used to create the mesh
  134849. * @param scene defines the hosting scene
  134850. * @returns the tube mesh
  134851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134852. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134853. */
  134854. static CreateTube(name: string, options: {
  134855. path: Vector3[];
  134856. radius?: number;
  134857. tessellation?: number;
  134858. radiusFunction?: {
  134859. (i: number, distance: number): number;
  134860. };
  134861. cap?: number;
  134862. arc?: number;
  134863. updatable?: boolean;
  134864. sideOrientation?: number;
  134865. frontUVs?: Vector4;
  134866. backUVs?: Vector4;
  134867. instance?: Mesh;
  134868. invertUV?: boolean;
  134869. }, scene?: Nullable<Scene>): Mesh;
  134870. /**
  134871. * Creates a polyhedron mesh
  134872. * * 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
  134873. * * The parameter `size` (positive float, default 1) sets the polygon size
  134874. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134875. * * 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`
  134876. * * 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
  134877. * * 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)`)
  134878. * * 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
  134879. * * 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
  134880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134881. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134883. * @param name defines the name of the mesh
  134884. * @param options defines the options used to create the mesh
  134885. * @param scene defines the hosting scene
  134886. * @returns the polyhedron mesh
  134887. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134888. */
  134889. static CreatePolyhedron(name: string, options: {
  134890. type?: number;
  134891. size?: number;
  134892. sizeX?: number;
  134893. sizeY?: number;
  134894. sizeZ?: number;
  134895. custom?: any;
  134896. faceUV?: Vector4[];
  134897. faceColors?: Color4[];
  134898. flat?: boolean;
  134899. updatable?: boolean;
  134900. sideOrientation?: number;
  134901. frontUVs?: Vector4;
  134902. backUVs?: Vector4;
  134903. }, scene?: Nullable<Scene>): Mesh;
  134904. /**
  134905. * Creates a decal mesh.
  134906. * 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
  134907. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134908. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134909. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134910. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134911. * @param name defines the name of the mesh
  134912. * @param sourceMesh defines the mesh where the decal must be applied
  134913. * @param options defines the options used to create the mesh
  134914. * @param scene defines the hosting scene
  134915. * @returns the decal mesh
  134916. * @see https://doc.babylonjs.com/how_to/decals
  134917. */
  134918. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134919. position?: Vector3;
  134920. normal?: Vector3;
  134921. size?: Vector3;
  134922. angle?: number;
  134923. }): Mesh;
  134924. }
  134925. }
  134926. declare module BABYLON {
  134927. /**
  134928. * A simplifier interface for future simplification implementations
  134929. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134930. */
  134931. export interface ISimplifier {
  134932. /**
  134933. * Simplification of a given mesh according to the given settings.
  134934. * Since this requires computation, it is assumed that the function runs async.
  134935. * @param settings The settings of the simplification, including quality and distance
  134936. * @param successCallback A callback that will be called after the mesh was simplified.
  134937. * @param errorCallback in case of an error, this callback will be called. optional.
  134938. */
  134939. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134940. }
  134941. /**
  134942. * Expected simplification settings.
  134943. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134944. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134945. */
  134946. export interface ISimplificationSettings {
  134947. /**
  134948. * Gets or sets the expected quality
  134949. */
  134950. quality: number;
  134951. /**
  134952. * Gets or sets the distance when this optimized version should be used
  134953. */
  134954. distance: number;
  134955. /**
  134956. * Gets an already optimized mesh
  134957. */
  134958. optimizeMesh?: boolean;
  134959. }
  134960. /**
  134961. * Class used to specify simplification options
  134962. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134963. */
  134964. export class SimplificationSettings implements ISimplificationSettings {
  134965. /** expected quality */
  134966. quality: number;
  134967. /** distance when this optimized version should be used */
  134968. distance: number;
  134969. /** already optimized mesh */
  134970. optimizeMesh?: boolean | undefined;
  134971. /**
  134972. * Creates a SimplificationSettings
  134973. * @param quality expected quality
  134974. * @param distance distance when this optimized version should be used
  134975. * @param optimizeMesh already optimized mesh
  134976. */
  134977. constructor(
  134978. /** expected quality */
  134979. quality: number,
  134980. /** distance when this optimized version should be used */
  134981. distance: number,
  134982. /** already optimized mesh */
  134983. optimizeMesh?: boolean | undefined);
  134984. }
  134985. /**
  134986. * Interface used to define a simplification task
  134987. */
  134988. export interface ISimplificationTask {
  134989. /**
  134990. * Array of settings
  134991. */
  134992. settings: Array<ISimplificationSettings>;
  134993. /**
  134994. * Simplification type
  134995. */
  134996. simplificationType: SimplificationType;
  134997. /**
  134998. * Mesh to simplify
  134999. */
  135000. mesh: Mesh;
  135001. /**
  135002. * Callback called on success
  135003. */
  135004. successCallback?: () => void;
  135005. /**
  135006. * Defines if parallel processing can be used
  135007. */
  135008. parallelProcessing: boolean;
  135009. }
  135010. /**
  135011. * Queue used to order the simplification tasks
  135012. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135013. */
  135014. export class SimplificationQueue {
  135015. private _simplificationArray;
  135016. /**
  135017. * Gets a boolean indicating that the process is still running
  135018. */
  135019. running: boolean;
  135020. /**
  135021. * Creates a new queue
  135022. */
  135023. constructor();
  135024. /**
  135025. * Adds a new simplification task
  135026. * @param task defines a task to add
  135027. */
  135028. addTask(task: ISimplificationTask): void;
  135029. /**
  135030. * Execute next task
  135031. */
  135032. executeNext(): void;
  135033. /**
  135034. * Execute a simplification task
  135035. * @param task defines the task to run
  135036. */
  135037. runSimplification(task: ISimplificationTask): void;
  135038. private getSimplifier;
  135039. }
  135040. /**
  135041. * The implemented types of simplification
  135042. * At the moment only Quadratic Error Decimation is implemented
  135043. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135044. */
  135045. export enum SimplificationType {
  135046. /** Quadratic error decimation */
  135047. QUADRATIC = 0
  135048. }
  135049. }
  135050. declare module BABYLON {
  135051. interface Scene {
  135052. /** @hidden (Backing field) */
  135053. _simplificationQueue: SimplificationQueue;
  135054. /**
  135055. * Gets or sets the simplification queue attached to the scene
  135056. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135057. */
  135058. simplificationQueue: SimplificationQueue;
  135059. }
  135060. interface Mesh {
  135061. /**
  135062. * Simplify the mesh according to the given array of settings.
  135063. * Function will return immediately and will simplify async
  135064. * @param settings a collection of simplification settings
  135065. * @param parallelProcessing should all levels calculate parallel or one after the other
  135066. * @param simplificationType the type of simplification to run
  135067. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135068. * @returns the current mesh
  135069. */
  135070. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135071. }
  135072. /**
  135073. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135074. * created in a scene
  135075. */
  135076. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135077. /**
  135078. * The component name helpfull to identify the component in the list of scene components.
  135079. */
  135080. readonly name: string;
  135081. /**
  135082. * The scene the component belongs to.
  135083. */
  135084. scene: Scene;
  135085. /**
  135086. * Creates a new instance of the component for the given scene
  135087. * @param scene Defines the scene to register the component in
  135088. */
  135089. constructor(scene: Scene);
  135090. /**
  135091. * Registers the component in a given scene
  135092. */
  135093. register(): void;
  135094. /**
  135095. * Rebuilds the elements related to this component in case of
  135096. * context lost for instance.
  135097. */
  135098. rebuild(): void;
  135099. /**
  135100. * Disposes the component and the associated ressources
  135101. */
  135102. dispose(): void;
  135103. private _beforeCameraUpdate;
  135104. }
  135105. }
  135106. declare module BABYLON {
  135107. /**
  135108. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135109. */
  135110. export interface INavigationEnginePlugin {
  135111. /**
  135112. * plugin name
  135113. */
  135114. name: string;
  135115. /**
  135116. * Creates a navigation mesh
  135117. * @param meshes array of all the geometry used to compute the navigatio mesh
  135118. * @param parameters bunch of parameters used to filter geometry
  135119. */
  135120. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135121. /**
  135122. * Create a navigation mesh debug mesh
  135123. * @param scene is where the mesh will be added
  135124. * @returns debug display mesh
  135125. */
  135126. createDebugNavMesh(scene: Scene): Mesh;
  135127. /**
  135128. * Get a navigation mesh constrained position, closest to the parameter position
  135129. * @param position world position
  135130. * @returns the closest point to position constrained by the navigation mesh
  135131. */
  135132. getClosestPoint(position: Vector3): Vector3;
  135133. /**
  135134. * Get a navigation mesh constrained position, within a particular radius
  135135. * @param position world position
  135136. * @param maxRadius the maximum distance to the constrained world position
  135137. * @returns the closest point to position constrained by the navigation mesh
  135138. */
  135139. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135140. /**
  135141. * Compute the final position from a segment made of destination-position
  135142. * @param position world position
  135143. * @param destination world position
  135144. * @returns the resulting point along the navmesh
  135145. */
  135146. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135147. /**
  135148. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135149. * @param start world position
  135150. * @param end world position
  135151. * @returns array containing world position composing the path
  135152. */
  135153. computePath(start: Vector3, end: Vector3): Vector3[];
  135154. /**
  135155. * If this plugin is supported
  135156. * @returns true if plugin is supported
  135157. */
  135158. isSupported(): boolean;
  135159. /**
  135160. * Create a new Crowd so you can add agents
  135161. * @param maxAgents the maximum agent count in the crowd
  135162. * @param maxAgentRadius the maximum radius an agent can have
  135163. * @param scene to attach the crowd to
  135164. * @returns the crowd you can add agents to
  135165. */
  135166. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135167. /**
  135168. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135169. * The queries will try to find a solution within those bounds
  135170. * default is (1,1,1)
  135171. * @param extent x,y,z value that define the extent around the queries point of reference
  135172. */
  135173. setDefaultQueryExtent(extent: Vector3): void;
  135174. /**
  135175. * Get the Bounding box extent specified by setDefaultQueryExtent
  135176. * @returns the box extent values
  135177. */
  135178. getDefaultQueryExtent(): Vector3;
  135179. /**
  135180. * Release all resources
  135181. */
  135182. dispose(): void;
  135183. }
  135184. /**
  135185. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135186. */
  135187. export interface ICrowd {
  135188. /**
  135189. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135190. * You can attach anything to that node. The node position is updated in the scene update tick.
  135191. * @param pos world position that will be constrained by the navigation mesh
  135192. * @param parameters agent parameters
  135193. * @param transform hooked to the agent that will be update by the scene
  135194. * @returns agent index
  135195. */
  135196. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135197. /**
  135198. * Returns the agent position in world space
  135199. * @param index agent index returned by addAgent
  135200. * @returns world space position
  135201. */
  135202. getAgentPosition(index: number): Vector3;
  135203. /**
  135204. * Gets the agent velocity in world space
  135205. * @param index agent index returned by addAgent
  135206. * @returns world space velocity
  135207. */
  135208. getAgentVelocity(index: number): Vector3;
  135209. /**
  135210. * remove a particular agent previously created
  135211. * @param index agent index returned by addAgent
  135212. */
  135213. removeAgent(index: number): void;
  135214. /**
  135215. * get the list of all agents attached to this crowd
  135216. * @returns list of agent indices
  135217. */
  135218. getAgents(): number[];
  135219. /**
  135220. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135221. * @param deltaTime in seconds
  135222. */
  135223. update(deltaTime: number): void;
  135224. /**
  135225. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135226. * @param index agent index returned by addAgent
  135227. * @param destination targeted world position
  135228. */
  135229. agentGoto(index: number, destination: Vector3): void;
  135230. /**
  135231. * Teleport the agent to a new position
  135232. * @param index agent index returned by addAgent
  135233. * @param destination targeted world position
  135234. */
  135235. agentTeleport(index: number, destination: Vector3): void;
  135236. /**
  135237. * Update agent parameters
  135238. * @param index agent index returned by addAgent
  135239. * @param parameters agent parameters
  135240. */
  135241. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135242. /**
  135243. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135244. * The queries will try to find a solution within those bounds
  135245. * default is (1,1,1)
  135246. * @param extent x,y,z value that define the extent around the queries point of reference
  135247. */
  135248. setDefaultQueryExtent(extent: Vector3): void;
  135249. /**
  135250. * Get the Bounding box extent specified by setDefaultQueryExtent
  135251. * @returns the box extent values
  135252. */
  135253. getDefaultQueryExtent(): Vector3;
  135254. /**
  135255. * Release all resources
  135256. */
  135257. dispose(): void;
  135258. }
  135259. /**
  135260. * Configures an agent
  135261. */
  135262. export interface IAgentParameters {
  135263. /**
  135264. * Agent radius. [Limit: >= 0]
  135265. */
  135266. radius: number;
  135267. /**
  135268. * Agent height. [Limit: > 0]
  135269. */
  135270. height: number;
  135271. /**
  135272. * Maximum allowed acceleration. [Limit: >= 0]
  135273. */
  135274. maxAcceleration: number;
  135275. /**
  135276. * Maximum allowed speed. [Limit: >= 0]
  135277. */
  135278. maxSpeed: number;
  135279. /**
  135280. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135281. */
  135282. collisionQueryRange: number;
  135283. /**
  135284. * The path visibility optimization range. [Limit: > 0]
  135285. */
  135286. pathOptimizationRange: number;
  135287. /**
  135288. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135289. */
  135290. separationWeight: number;
  135291. }
  135292. /**
  135293. * Configures the navigation mesh creation
  135294. */
  135295. export interface INavMeshParameters {
  135296. /**
  135297. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135298. */
  135299. cs: number;
  135300. /**
  135301. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135302. */
  135303. ch: number;
  135304. /**
  135305. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135306. */
  135307. walkableSlopeAngle: number;
  135308. /**
  135309. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135310. * be considered walkable. [Limit: >= 3] [Units: vx]
  135311. */
  135312. walkableHeight: number;
  135313. /**
  135314. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135315. */
  135316. walkableClimb: number;
  135317. /**
  135318. * The distance to erode/shrink the walkable area of the heightfield away from
  135319. * obstructions. [Limit: >=0] [Units: vx]
  135320. */
  135321. walkableRadius: number;
  135322. /**
  135323. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135324. */
  135325. maxEdgeLen: number;
  135326. /**
  135327. * The maximum distance a simplfied contour's border edges should deviate
  135328. * the original raw contour. [Limit: >=0] [Units: vx]
  135329. */
  135330. maxSimplificationError: number;
  135331. /**
  135332. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135333. */
  135334. minRegionArea: number;
  135335. /**
  135336. * Any regions with a span count smaller than this value will, if possible,
  135337. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135338. */
  135339. mergeRegionArea: number;
  135340. /**
  135341. * The maximum number of vertices allowed for polygons generated during the
  135342. * contour to polygon conversion process. [Limit: >= 3]
  135343. */
  135344. maxVertsPerPoly: number;
  135345. /**
  135346. * Sets the sampling distance to use when generating the detail mesh.
  135347. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135348. */
  135349. detailSampleDist: number;
  135350. /**
  135351. * The maximum distance the detail mesh surface should deviate from heightfield
  135352. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135353. */
  135354. detailSampleMaxError: number;
  135355. }
  135356. }
  135357. declare module BABYLON {
  135358. /**
  135359. * RecastJS navigation plugin
  135360. */
  135361. export class RecastJSPlugin implements INavigationEnginePlugin {
  135362. /**
  135363. * Reference to the Recast library
  135364. */
  135365. bjsRECAST: any;
  135366. /**
  135367. * plugin name
  135368. */
  135369. name: string;
  135370. /**
  135371. * the first navmesh created. We might extend this to support multiple navmeshes
  135372. */
  135373. navMesh: any;
  135374. /**
  135375. * Initializes the recastJS plugin
  135376. * @param recastInjection can be used to inject your own recast reference
  135377. */
  135378. constructor(recastInjection?: any);
  135379. /**
  135380. * Creates a navigation mesh
  135381. * @param meshes array of all the geometry used to compute the navigatio mesh
  135382. * @param parameters bunch of parameters used to filter geometry
  135383. */
  135384. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135385. /**
  135386. * Create a navigation mesh debug mesh
  135387. * @param scene is where the mesh will be added
  135388. * @returns debug display mesh
  135389. */
  135390. createDebugNavMesh(scene: Scene): Mesh;
  135391. /**
  135392. * Get a navigation mesh constrained position, closest to the parameter position
  135393. * @param position world position
  135394. * @returns the closest point to position constrained by the navigation mesh
  135395. */
  135396. getClosestPoint(position: Vector3): Vector3;
  135397. /**
  135398. * Get a navigation mesh constrained position, within a particular radius
  135399. * @param position world position
  135400. * @param maxRadius the maximum distance to the constrained world position
  135401. * @returns the closest point to position constrained by the navigation mesh
  135402. */
  135403. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135404. /**
  135405. * Compute the final position from a segment made of destination-position
  135406. * @param position world position
  135407. * @param destination world position
  135408. * @returns the resulting point along the navmesh
  135409. */
  135410. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135411. /**
  135412. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135413. * @param start world position
  135414. * @param end world position
  135415. * @returns array containing world position composing the path
  135416. */
  135417. computePath(start: Vector3, end: Vector3): Vector3[];
  135418. /**
  135419. * Create a new Crowd so you can add agents
  135420. * @param maxAgents the maximum agent count in the crowd
  135421. * @param maxAgentRadius the maximum radius an agent can have
  135422. * @param scene to attach the crowd to
  135423. * @returns the crowd you can add agents to
  135424. */
  135425. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135426. /**
  135427. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135428. * The queries will try to find a solution within those bounds
  135429. * default is (1,1,1)
  135430. * @param extent x,y,z value that define the extent around the queries point of reference
  135431. */
  135432. setDefaultQueryExtent(extent: Vector3): void;
  135433. /**
  135434. * Get the Bounding box extent specified by setDefaultQueryExtent
  135435. * @returns the box extent values
  135436. */
  135437. getDefaultQueryExtent(): Vector3;
  135438. /**
  135439. * Disposes
  135440. */
  135441. dispose(): void;
  135442. /**
  135443. * If this plugin is supported
  135444. * @returns true if plugin is supported
  135445. */
  135446. isSupported(): boolean;
  135447. }
  135448. /**
  135449. * Recast detour crowd implementation
  135450. */
  135451. export class RecastJSCrowd implements ICrowd {
  135452. /**
  135453. * Recast/detour plugin
  135454. */
  135455. bjsRECASTPlugin: RecastJSPlugin;
  135456. /**
  135457. * Link to the detour crowd
  135458. */
  135459. recastCrowd: any;
  135460. /**
  135461. * One transform per agent
  135462. */
  135463. transforms: TransformNode[];
  135464. /**
  135465. * All agents created
  135466. */
  135467. agents: number[];
  135468. /**
  135469. * Link to the scene is kept to unregister the crowd from the scene
  135470. */
  135471. private _scene;
  135472. /**
  135473. * Observer for crowd updates
  135474. */
  135475. private _onBeforeAnimationsObserver;
  135476. /**
  135477. * Constructor
  135478. * @param plugin recastJS plugin
  135479. * @param maxAgents the maximum agent count in the crowd
  135480. * @param maxAgentRadius the maximum radius an agent can have
  135481. * @param scene to attach the crowd to
  135482. * @returns the crowd you can add agents to
  135483. */
  135484. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135485. /**
  135486. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135487. * You can attach anything to that node. The node position is updated in the scene update tick.
  135488. * @param pos world position that will be constrained by the navigation mesh
  135489. * @param parameters agent parameters
  135490. * @param transform hooked to the agent that will be update by the scene
  135491. * @returns agent index
  135492. */
  135493. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135494. /**
  135495. * Returns the agent position in world space
  135496. * @param index agent index returned by addAgent
  135497. * @returns world space position
  135498. */
  135499. getAgentPosition(index: number): Vector3;
  135500. /**
  135501. * Returns the agent velocity in world space
  135502. * @param index agent index returned by addAgent
  135503. * @returns world space velocity
  135504. */
  135505. getAgentVelocity(index: number): Vector3;
  135506. /**
  135507. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135508. * @param index agent index returned by addAgent
  135509. * @param destination targeted world position
  135510. */
  135511. agentGoto(index: number, destination: Vector3): void;
  135512. /**
  135513. * Teleport the agent to a new position
  135514. * @param index agent index returned by addAgent
  135515. * @param destination targeted world position
  135516. */
  135517. agentTeleport(index: number, destination: Vector3): void;
  135518. /**
  135519. * Update agent parameters
  135520. * @param index agent index returned by addAgent
  135521. * @param parameters agent parameters
  135522. */
  135523. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135524. /**
  135525. * remove a particular agent previously created
  135526. * @param index agent index returned by addAgent
  135527. */
  135528. removeAgent(index: number): void;
  135529. /**
  135530. * get the list of all agents attached to this crowd
  135531. * @returns list of agent indices
  135532. */
  135533. getAgents(): number[];
  135534. /**
  135535. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135536. * @param deltaTime in seconds
  135537. */
  135538. update(deltaTime: number): void;
  135539. /**
  135540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135541. * The queries will try to find a solution within those bounds
  135542. * default is (1,1,1)
  135543. * @param extent x,y,z value that define the extent around the queries point of reference
  135544. */
  135545. setDefaultQueryExtent(extent: Vector3): void;
  135546. /**
  135547. * Get the Bounding box extent specified by setDefaultQueryExtent
  135548. * @returns the box extent values
  135549. */
  135550. getDefaultQueryExtent(): Vector3;
  135551. /**
  135552. * Release all resources
  135553. */
  135554. dispose(): void;
  135555. }
  135556. }
  135557. declare module BABYLON {
  135558. /**
  135559. * Class used to enable access to IndexedDB
  135560. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135561. */
  135562. export class Database implements IOfflineProvider {
  135563. private _callbackManifestChecked;
  135564. private _currentSceneUrl;
  135565. private _db;
  135566. private _enableSceneOffline;
  135567. private _enableTexturesOffline;
  135568. private _manifestVersionFound;
  135569. private _mustUpdateRessources;
  135570. private _hasReachedQuota;
  135571. private _isSupported;
  135572. private _idbFactory;
  135573. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135574. private static IsUASupportingBlobStorage;
  135575. /**
  135576. * Gets a boolean indicating if Database storate is enabled (off by default)
  135577. */
  135578. static IDBStorageEnabled: boolean;
  135579. /**
  135580. * Gets a boolean indicating if scene must be saved in the database
  135581. */
  135582. get enableSceneOffline(): boolean;
  135583. /**
  135584. * Gets a boolean indicating if textures must be saved in the database
  135585. */
  135586. get enableTexturesOffline(): boolean;
  135587. /**
  135588. * Creates a new Database
  135589. * @param urlToScene defines the url to load the scene
  135590. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135591. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135592. */
  135593. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135594. private static _ParseURL;
  135595. private static _ReturnFullUrlLocation;
  135596. private _checkManifestFile;
  135597. /**
  135598. * Open the database and make it available
  135599. * @param successCallback defines the callback to call on success
  135600. * @param errorCallback defines the callback to call on error
  135601. */
  135602. open(successCallback: () => void, errorCallback: () => void): void;
  135603. /**
  135604. * Loads an image from the database
  135605. * @param url defines the url to load from
  135606. * @param image defines the target DOM image
  135607. */
  135608. loadImage(url: string, image: HTMLImageElement): void;
  135609. private _loadImageFromDBAsync;
  135610. private _saveImageIntoDBAsync;
  135611. private _checkVersionFromDB;
  135612. private _loadVersionFromDBAsync;
  135613. private _saveVersionIntoDBAsync;
  135614. /**
  135615. * Loads a file from database
  135616. * @param url defines the URL to load from
  135617. * @param sceneLoaded defines a callback to call on success
  135618. * @param progressCallBack defines a callback to call when progress changed
  135619. * @param errorCallback defines a callback to call on error
  135620. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135621. */
  135622. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135623. private _loadFileAsync;
  135624. private _saveFileAsync;
  135625. /**
  135626. * Validates if xhr data is correct
  135627. * @param xhr defines the request to validate
  135628. * @param dataType defines the expected data type
  135629. * @returns true if data is correct
  135630. */
  135631. private static _ValidateXHRData;
  135632. }
  135633. }
  135634. declare module BABYLON {
  135635. /** @hidden */
  135636. export var gpuUpdateParticlesPixelShader: {
  135637. name: string;
  135638. shader: string;
  135639. };
  135640. }
  135641. declare module BABYLON {
  135642. /** @hidden */
  135643. export var gpuUpdateParticlesVertexShader: {
  135644. name: string;
  135645. shader: string;
  135646. };
  135647. }
  135648. declare module BABYLON {
  135649. /** @hidden */
  135650. export var clipPlaneFragmentDeclaration2: {
  135651. name: string;
  135652. shader: string;
  135653. };
  135654. }
  135655. declare module BABYLON {
  135656. /** @hidden */
  135657. export var gpuRenderParticlesPixelShader: {
  135658. name: string;
  135659. shader: string;
  135660. };
  135661. }
  135662. declare module BABYLON {
  135663. /** @hidden */
  135664. export var clipPlaneVertexDeclaration2: {
  135665. name: string;
  135666. shader: string;
  135667. };
  135668. }
  135669. declare module BABYLON {
  135670. /** @hidden */
  135671. export var gpuRenderParticlesVertexShader: {
  135672. name: string;
  135673. shader: string;
  135674. };
  135675. }
  135676. declare module BABYLON {
  135677. /**
  135678. * This represents a GPU particle system in Babylon
  135679. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135680. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135681. */
  135682. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135683. /**
  135684. * The layer mask we are rendering the particles through.
  135685. */
  135686. layerMask: number;
  135687. private _capacity;
  135688. private _activeCount;
  135689. private _currentActiveCount;
  135690. private _accumulatedCount;
  135691. private _renderEffect;
  135692. private _updateEffect;
  135693. private _buffer0;
  135694. private _buffer1;
  135695. private _spriteBuffer;
  135696. private _updateVAO;
  135697. private _renderVAO;
  135698. private _targetIndex;
  135699. private _sourceBuffer;
  135700. private _targetBuffer;
  135701. private _engine;
  135702. private _currentRenderId;
  135703. private _started;
  135704. private _stopped;
  135705. private _timeDelta;
  135706. private _randomTexture;
  135707. private _randomTexture2;
  135708. private _attributesStrideSize;
  135709. private _updateEffectOptions;
  135710. private _randomTextureSize;
  135711. private _actualFrame;
  135712. private readonly _rawTextureWidth;
  135713. /**
  135714. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135715. */
  135716. static get IsSupported(): boolean;
  135717. /**
  135718. * An event triggered when the system is disposed.
  135719. */
  135720. onDisposeObservable: Observable<GPUParticleSystem>;
  135721. /**
  135722. * Gets the maximum number of particles active at the same time.
  135723. * @returns The max number of active particles.
  135724. */
  135725. getCapacity(): number;
  135726. /**
  135727. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135728. * to override the particles.
  135729. */
  135730. forceDepthWrite: boolean;
  135731. /**
  135732. * Gets or set the number of active particles
  135733. */
  135734. get activeParticleCount(): number;
  135735. set activeParticleCount(value: number);
  135736. private _preWarmDone;
  135737. /**
  135738. * Is this system ready to be used/rendered
  135739. * @return true if the system is ready
  135740. */
  135741. isReady(): boolean;
  135742. /**
  135743. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135744. * @returns True if it has been started, otherwise false.
  135745. */
  135746. isStarted(): boolean;
  135747. /**
  135748. * Starts the particle system and begins to emit
  135749. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135750. */
  135751. start(delay?: number): void;
  135752. /**
  135753. * Stops the particle system.
  135754. */
  135755. stop(): void;
  135756. /**
  135757. * Remove all active particles
  135758. */
  135759. reset(): void;
  135760. /**
  135761. * Returns the string "GPUParticleSystem"
  135762. * @returns a string containing the class name
  135763. */
  135764. getClassName(): string;
  135765. private _colorGradientsTexture;
  135766. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135767. /**
  135768. * Adds a new color gradient
  135769. * @param gradient defines the gradient to use (between 0 and 1)
  135770. * @param color1 defines the color to affect to the specified gradient
  135771. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135772. * @returns the current particle system
  135773. */
  135774. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135775. /**
  135776. * Remove a specific color gradient
  135777. * @param gradient defines the gradient to remove
  135778. * @returns the current particle system
  135779. */
  135780. removeColorGradient(gradient: number): GPUParticleSystem;
  135781. private _angularSpeedGradientsTexture;
  135782. private _sizeGradientsTexture;
  135783. private _velocityGradientsTexture;
  135784. private _limitVelocityGradientsTexture;
  135785. private _dragGradientsTexture;
  135786. private _addFactorGradient;
  135787. /**
  135788. * Adds a new size gradient
  135789. * @param gradient defines the gradient to use (between 0 and 1)
  135790. * @param factor defines the size factor to affect to the specified gradient
  135791. * @returns the current particle system
  135792. */
  135793. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135794. /**
  135795. * Remove a specific size gradient
  135796. * @param gradient defines the gradient to remove
  135797. * @returns the current particle system
  135798. */
  135799. removeSizeGradient(gradient: number): GPUParticleSystem;
  135800. /**
  135801. * Adds a new angular speed gradient
  135802. * @param gradient defines the gradient to use (between 0 and 1)
  135803. * @param factor defines the angular speed to affect to the specified gradient
  135804. * @returns the current particle system
  135805. */
  135806. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135807. /**
  135808. * Remove a specific angular speed gradient
  135809. * @param gradient defines the gradient to remove
  135810. * @returns the current particle system
  135811. */
  135812. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135813. /**
  135814. * Adds a new velocity gradient
  135815. * @param gradient defines the gradient to use (between 0 and 1)
  135816. * @param factor defines the velocity to affect to the specified gradient
  135817. * @returns the current particle system
  135818. */
  135819. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135820. /**
  135821. * Remove a specific velocity gradient
  135822. * @param gradient defines the gradient to remove
  135823. * @returns the current particle system
  135824. */
  135825. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135826. /**
  135827. * Adds a new limit velocity gradient
  135828. * @param gradient defines the gradient to use (between 0 and 1)
  135829. * @param factor defines the limit velocity value to affect to the specified gradient
  135830. * @returns the current particle system
  135831. */
  135832. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135833. /**
  135834. * Remove a specific limit velocity gradient
  135835. * @param gradient defines the gradient to remove
  135836. * @returns the current particle system
  135837. */
  135838. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135839. /**
  135840. * Adds a new drag gradient
  135841. * @param gradient defines the gradient to use (between 0 and 1)
  135842. * @param factor defines the drag value to affect to the specified gradient
  135843. * @returns the current particle system
  135844. */
  135845. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135846. /**
  135847. * Remove a specific drag gradient
  135848. * @param gradient defines the gradient to remove
  135849. * @returns the current particle system
  135850. */
  135851. removeDragGradient(gradient: number): GPUParticleSystem;
  135852. /**
  135853. * Not supported by GPUParticleSystem
  135854. * @param gradient defines the gradient to use (between 0 and 1)
  135855. * @param factor defines the emit rate value to affect to the specified gradient
  135856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135857. * @returns the current particle system
  135858. */
  135859. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135860. /**
  135861. * Not supported by GPUParticleSystem
  135862. * @param gradient defines the gradient to remove
  135863. * @returns the current particle system
  135864. */
  135865. removeEmitRateGradient(gradient: number): IParticleSystem;
  135866. /**
  135867. * Not supported by GPUParticleSystem
  135868. * @param gradient defines the gradient to use (between 0 and 1)
  135869. * @param factor defines the start size value to affect to the specified gradient
  135870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135871. * @returns the current particle system
  135872. */
  135873. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135874. /**
  135875. * Not supported by GPUParticleSystem
  135876. * @param gradient defines the gradient to remove
  135877. * @returns the current particle system
  135878. */
  135879. removeStartSizeGradient(gradient: number): IParticleSystem;
  135880. /**
  135881. * Not supported by GPUParticleSystem
  135882. * @param gradient defines the gradient to use (between 0 and 1)
  135883. * @param min defines the color remap minimal range
  135884. * @param max defines the color remap maximal range
  135885. * @returns the current particle system
  135886. */
  135887. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135888. /**
  135889. * Not supported by GPUParticleSystem
  135890. * @param gradient defines the gradient to remove
  135891. * @returns the current particle system
  135892. */
  135893. removeColorRemapGradient(): IParticleSystem;
  135894. /**
  135895. * Not supported by GPUParticleSystem
  135896. * @param gradient defines the gradient to use (between 0 and 1)
  135897. * @param min defines the alpha remap minimal range
  135898. * @param max defines the alpha remap maximal range
  135899. * @returns the current particle system
  135900. */
  135901. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135902. /**
  135903. * Not supported by GPUParticleSystem
  135904. * @param gradient defines the gradient to remove
  135905. * @returns the current particle system
  135906. */
  135907. removeAlphaRemapGradient(): IParticleSystem;
  135908. /**
  135909. * Not supported by GPUParticleSystem
  135910. * @param gradient defines the gradient to use (between 0 and 1)
  135911. * @param color defines the color to affect to the specified gradient
  135912. * @returns the current particle system
  135913. */
  135914. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135915. /**
  135916. * Not supported by GPUParticleSystem
  135917. * @param gradient defines the gradient to remove
  135918. * @returns the current particle system
  135919. */
  135920. removeRampGradient(): IParticleSystem;
  135921. /**
  135922. * Not supported by GPUParticleSystem
  135923. * @returns the list of ramp gradients
  135924. */
  135925. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135926. /**
  135927. * Not supported by GPUParticleSystem
  135928. * Gets or sets a boolean indicating that ramp gradients must be used
  135929. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135930. */
  135931. get useRampGradients(): boolean;
  135932. set useRampGradients(value: boolean);
  135933. /**
  135934. * Not supported by GPUParticleSystem
  135935. * @param gradient defines the gradient to use (between 0 and 1)
  135936. * @param factor defines the life time factor to affect to the specified gradient
  135937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135938. * @returns the current particle system
  135939. */
  135940. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135941. /**
  135942. * Not supported by GPUParticleSystem
  135943. * @param gradient defines the gradient to remove
  135944. * @returns the current particle system
  135945. */
  135946. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135947. /**
  135948. * Instantiates a GPU particle system.
  135949. * 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.
  135950. * @param name The name of the particle system
  135951. * @param options The options used to create the system
  135952. * @param scene The scene the particle system belongs to
  135953. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135954. */
  135955. constructor(name: string, options: Partial<{
  135956. capacity: number;
  135957. randomTextureSize: number;
  135958. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135959. protected _reset(): void;
  135960. private _createUpdateVAO;
  135961. private _createRenderVAO;
  135962. private _initialize;
  135963. /** @hidden */
  135964. _recreateUpdateEffect(): void;
  135965. /** @hidden */
  135966. _recreateRenderEffect(): void;
  135967. /**
  135968. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135969. * @param preWarm defines if we are in the pre-warmimg phase
  135970. */
  135971. animate(preWarm?: boolean): void;
  135972. private _createFactorGradientTexture;
  135973. private _createSizeGradientTexture;
  135974. private _createAngularSpeedGradientTexture;
  135975. private _createVelocityGradientTexture;
  135976. private _createLimitVelocityGradientTexture;
  135977. private _createDragGradientTexture;
  135978. private _createColorGradientTexture;
  135979. /**
  135980. * Renders the particle system in its current state
  135981. * @param preWarm defines if the system should only update the particles but not render them
  135982. * @returns the current number of particles
  135983. */
  135984. render(preWarm?: boolean): number;
  135985. /**
  135986. * Rebuilds the particle system
  135987. */
  135988. rebuild(): void;
  135989. private _releaseBuffers;
  135990. private _releaseVAOs;
  135991. /**
  135992. * Disposes the particle system and free the associated resources
  135993. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135994. */
  135995. dispose(disposeTexture?: boolean): void;
  135996. /**
  135997. * Clones the particle system.
  135998. * @param name The name of the cloned object
  135999. * @param newEmitter The new emitter to use
  136000. * @returns the cloned particle system
  136001. */
  136002. clone(name: string, newEmitter: any): GPUParticleSystem;
  136003. /**
  136004. * Serializes the particle system to a JSON object.
  136005. * @returns the JSON object
  136006. */
  136007. serialize(): any;
  136008. /**
  136009. * Parses a JSON object to create a GPU particle system.
  136010. * @param parsedParticleSystem The JSON object to parse
  136011. * @param scene The scene to create the particle system in
  136012. * @param rootUrl The root url to use to load external dependencies like texture
  136013. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136014. * @returns the parsed GPU particle system
  136015. */
  136016. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136017. }
  136018. }
  136019. declare module BABYLON {
  136020. /**
  136021. * Represents a set of particle systems working together to create a specific effect
  136022. */
  136023. export class ParticleSystemSet implements IDisposable {
  136024. /**
  136025. * Gets or sets base Assets URL
  136026. */
  136027. static BaseAssetsUrl: string;
  136028. private _emitterCreationOptions;
  136029. private _emitterNode;
  136030. /**
  136031. * Gets the particle system list
  136032. */
  136033. systems: IParticleSystem[];
  136034. /**
  136035. * Gets the emitter node used with this set
  136036. */
  136037. get emitterNode(): Nullable<TransformNode>;
  136038. /**
  136039. * Creates a new emitter mesh as a sphere
  136040. * @param options defines the options used to create the sphere
  136041. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136042. * @param scene defines the hosting scene
  136043. */
  136044. setEmitterAsSphere(options: {
  136045. diameter: number;
  136046. segments: number;
  136047. color: Color3;
  136048. }, renderingGroupId: number, scene: Scene): void;
  136049. /**
  136050. * Starts all particle systems of the set
  136051. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136052. */
  136053. start(emitter?: AbstractMesh): void;
  136054. /**
  136055. * Release all associated resources
  136056. */
  136057. dispose(): void;
  136058. /**
  136059. * Serialize the set into a JSON compatible object
  136060. * @returns a JSON compatible representation of the set
  136061. */
  136062. serialize(): any;
  136063. /**
  136064. * Parse a new ParticleSystemSet from a serialized source
  136065. * @param data defines a JSON compatible representation of the set
  136066. * @param scene defines the hosting scene
  136067. * @param gpu defines if we want GPU particles or CPU particles
  136068. * @returns a new ParticleSystemSet
  136069. */
  136070. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136071. }
  136072. }
  136073. declare module BABYLON {
  136074. /**
  136075. * This class is made for on one-liner static method to help creating particle system set.
  136076. */
  136077. export class ParticleHelper {
  136078. /**
  136079. * Gets or sets base Assets URL
  136080. */
  136081. static BaseAssetsUrl: string;
  136082. /**
  136083. * Create a default particle system that you can tweak
  136084. * @param emitter defines the emitter to use
  136085. * @param capacity defines the system capacity (default is 500 particles)
  136086. * @param scene defines the hosting scene
  136087. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136088. * @returns the new Particle system
  136089. */
  136090. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136091. /**
  136092. * This is the main static method (one-liner) of this helper to create different particle systems
  136093. * @param type This string represents the type to the particle system to create
  136094. * @param scene The scene where the particle system should live
  136095. * @param gpu If the system will use gpu
  136096. * @returns the ParticleSystemSet created
  136097. */
  136098. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136099. /**
  136100. * Static function used to export a particle system to a ParticleSystemSet variable.
  136101. * Please note that the emitter shape is not exported
  136102. * @param systems defines the particle systems to export
  136103. * @returns the created particle system set
  136104. */
  136105. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136106. }
  136107. }
  136108. declare module BABYLON {
  136109. interface Engine {
  136110. /**
  136111. * Create an effect to use with particle systems.
  136112. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136113. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136114. * @param uniformsNames defines a list of attribute names
  136115. * @param samplers defines an array of string used to represent textures
  136116. * @param defines defines the string containing the defines to use to compile the shaders
  136117. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136118. * @param onCompiled defines a function to call when the effect creation is successful
  136119. * @param onError defines a function to call when the effect creation has failed
  136120. * @returns the new Effect
  136121. */
  136122. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136123. }
  136124. interface Mesh {
  136125. /**
  136126. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136127. * @returns an array of IParticleSystem
  136128. */
  136129. getEmittedParticleSystems(): IParticleSystem[];
  136130. /**
  136131. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136132. * @returns an array of IParticleSystem
  136133. */
  136134. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136135. }
  136136. /**
  136137. * @hidden
  136138. */
  136139. export var _IDoNeedToBeInTheBuild: number;
  136140. }
  136141. declare module BABYLON {
  136142. /** Defines the 4 color options */
  136143. export enum PointColor {
  136144. /** color value */
  136145. Color = 2,
  136146. /** uv value */
  136147. UV = 1,
  136148. /** random value */
  136149. Random = 0,
  136150. /** stated value */
  136151. Stated = 3
  136152. }
  136153. /**
  136154. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136155. * 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.
  136156. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136157. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136158. *
  136159. * Full documentation here : TO BE ENTERED
  136160. */
  136161. export class PointsCloudSystem implements IDisposable {
  136162. /**
  136163. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136164. * Example : var p = SPS.particles[i];
  136165. */
  136166. particles: CloudPoint[];
  136167. /**
  136168. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136169. */
  136170. nbParticles: number;
  136171. /**
  136172. * This a counter for your own usage. It's not set by any SPS functions.
  136173. */
  136174. counter: number;
  136175. /**
  136176. * The PCS name. This name is also given to the underlying mesh.
  136177. */
  136178. name: string;
  136179. /**
  136180. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136181. */
  136182. mesh: Mesh;
  136183. /**
  136184. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136185. * Please read :
  136186. */
  136187. vars: any;
  136188. /**
  136189. * @hidden
  136190. */
  136191. _size: number;
  136192. private _scene;
  136193. private _promises;
  136194. private _positions;
  136195. private _indices;
  136196. private _normals;
  136197. private _colors;
  136198. private _uvs;
  136199. private _indices32;
  136200. private _positions32;
  136201. private _colors32;
  136202. private _uvs32;
  136203. private _updatable;
  136204. private _isVisibilityBoxLocked;
  136205. private _alwaysVisible;
  136206. private _groups;
  136207. private _groupCounter;
  136208. private _computeParticleColor;
  136209. private _computeParticleTexture;
  136210. private _computeParticleRotation;
  136211. private _computeBoundingBox;
  136212. private _isReady;
  136213. /**
  136214. * Creates a PCS (Points Cloud System) object
  136215. * @param name (String) is the PCS name, this will be the underlying mesh name
  136216. * @param pointSize (number) is the size for each point
  136217. * @param scene (Scene) is the scene in which the PCS is added
  136218. * @param options defines the options of the PCS e.g.
  136219. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136220. */
  136221. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136222. updatable?: boolean;
  136223. });
  136224. /**
  136225. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136226. * If no points were added to the PCS, the returned mesh is just a single point.
  136227. * @returns a promise for the created mesh
  136228. */
  136229. buildMeshAsync(): Promise<Mesh>;
  136230. /**
  136231. * @hidden
  136232. */
  136233. private _buildMesh;
  136234. private _addParticle;
  136235. private _randomUnitVector;
  136236. private _getColorIndicesForCoord;
  136237. private _setPointsColorOrUV;
  136238. private _colorFromTexture;
  136239. private _calculateDensity;
  136240. /**
  136241. * Adds points to the PCS in random positions within a unit sphere
  136242. * @param nb (positive integer) the number of particles to be created from this model
  136243. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136244. * @returns the number of groups in the system
  136245. */
  136246. addPoints(nb: number, pointFunction?: any): number;
  136247. /**
  136248. * Adds points to the PCS from the surface of the model shape
  136249. * @param mesh is any Mesh object that will be used as a surface model for the points
  136250. * @param nb (positive integer) the number of particles to be created from this model
  136251. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136252. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136253. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136254. * @returns the number of groups in the system
  136255. */
  136256. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136257. /**
  136258. * Adds points to the PCS inside the model shape
  136259. * @param mesh is any Mesh object that will be used as a surface model for the points
  136260. * @param nb (positive integer) the number of particles to be created from this model
  136261. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136262. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136263. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136264. * @returns the number of groups in the system
  136265. */
  136266. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136267. /**
  136268. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136269. * This method calls `updateParticle()` for each particle of the SPS.
  136270. * For an animated SPS, it is usually called within the render loop.
  136271. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136272. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136273. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136274. * @returns the PCS.
  136275. */
  136276. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136277. /**
  136278. * Disposes the PCS.
  136279. */
  136280. dispose(): void;
  136281. /**
  136282. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136283. * doc :
  136284. * @returns the PCS.
  136285. */
  136286. refreshVisibleSize(): PointsCloudSystem;
  136287. /**
  136288. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136289. * @param size the size (float) of the visibility box
  136290. * note : this doesn't lock the PCS mesh bounding box.
  136291. * doc :
  136292. */
  136293. setVisibilityBox(size: number): void;
  136294. /**
  136295. * Gets whether the PCS is always visible or not
  136296. * doc :
  136297. */
  136298. get isAlwaysVisible(): boolean;
  136299. /**
  136300. * Sets the PCS as always visible or not
  136301. * doc :
  136302. */
  136303. set isAlwaysVisible(val: boolean);
  136304. /**
  136305. * Tells to `setParticles()` to compute the particle rotations or not
  136306. * Default value : false. The PCS is faster when it's set to false
  136307. * Note : particle rotations are only applied to parent particles
  136308. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136309. */
  136310. set computeParticleRotation(val: boolean);
  136311. /**
  136312. * Tells to `setParticles()` to compute the particle colors or not.
  136313. * Default value : true. The PCS is faster when it's set to false.
  136314. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136315. */
  136316. set computeParticleColor(val: boolean);
  136317. set computeParticleTexture(val: boolean);
  136318. /**
  136319. * Gets if `setParticles()` computes the particle colors or not.
  136320. * Default value : false. The PCS is faster when it's set to false.
  136321. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136322. */
  136323. get computeParticleColor(): boolean;
  136324. /**
  136325. * Gets if `setParticles()` computes the particle textures or not.
  136326. * Default value : false. The PCS is faster when it's set to false.
  136327. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136328. */
  136329. get computeParticleTexture(): boolean;
  136330. /**
  136331. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136332. */
  136333. set computeBoundingBox(val: boolean);
  136334. /**
  136335. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136336. */
  136337. get computeBoundingBox(): boolean;
  136338. /**
  136339. * This function does nothing. It may be overwritten to set all the particle first values.
  136340. * The PCS doesn't call this function, you may have to call it by your own.
  136341. * doc :
  136342. */
  136343. initParticles(): void;
  136344. /**
  136345. * This function does nothing. It may be overwritten to recycle a particle
  136346. * The PCS doesn't call this function, you can to call it
  136347. * doc :
  136348. * @param particle The particle to recycle
  136349. * @returns the recycled particle
  136350. */
  136351. recycleParticle(particle: CloudPoint): CloudPoint;
  136352. /**
  136353. * Updates a particle : this function should be overwritten by the user.
  136354. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136355. * doc :
  136356. * @example : just set a particle position or velocity and recycle conditions
  136357. * @param particle The particle to update
  136358. * @returns the updated particle
  136359. */
  136360. updateParticle(particle: CloudPoint): CloudPoint;
  136361. /**
  136362. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136363. * This does nothing and may be overwritten by the user.
  136364. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136365. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136366. * @param update the boolean update value actually passed to setParticles()
  136367. */
  136368. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136369. /**
  136370. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136371. * This will be passed three parameters.
  136372. * This does nothing and may be overwritten by the user.
  136373. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136374. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136375. * @param update the boolean update value actually passed to setParticles()
  136376. */
  136377. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136378. }
  136379. }
  136380. declare module BABYLON {
  136381. /**
  136382. * Represents one particle of a points cloud system.
  136383. */
  136384. export class CloudPoint {
  136385. /**
  136386. * particle global index
  136387. */
  136388. idx: number;
  136389. /**
  136390. * The color of the particle
  136391. */
  136392. color: Nullable<Color4>;
  136393. /**
  136394. * The world space position of the particle.
  136395. */
  136396. position: Vector3;
  136397. /**
  136398. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136399. */
  136400. rotation: Vector3;
  136401. /**
  136402. * The world space rotation quaternion of the particle.
  136403. */
  136404. rotationQuaternion: Nullable<Quaternion>;
  136405. /**
  136406. * The uv of the particle.
  136407. */
  136408. uv: Nullable<Vector2>;
  136409. /**
  136410. * The current speed of the particle.
  136411. */
  136412. velocity: Vector3;
  136413. /**
  136414. * The pivot point in the particle local space.
  136415. */
  136416. pivot: Vector3;
  136417. /**
  136418. * Must the particle be translated from its pivot point in its local space ?
  136419. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136420. * Default : false
  136421. */
  136422. translateFromPivot: boolean;
  136423. /**
  136424. * Index of this particle in the global "positions" array (Internal use)
  136425. * @hidden
  136426. */
  136427. _pos: number;
  136428. /**
  136429. * @hidden Index of this particle in the global "indices" array (Internal use)
  136430. */
  136431. _ind: number;
  136432. /**
  136433. * Group this particle belongs to
  136434. */
  136435. _group: PointsGroup;
  136436. /**
  136437. * Group id of this particle
  136438. */
  136439. groupId: number;
  136440. /**
  136441. * Index of the particle in its group id (Internal use)
  136442. */
  136443. idxInGroup: number;
  136444. /**
  136445. * @hidden Particle BoundingInfo object (Internal use)
  136446. */
  136447. _boundingInfo: BoundingInfo;
  136448. /**
  136449. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136450. */
  136451. _pcs: PointsCloudSystem;
  136452. /**
  136453. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136454. */
  136455. _stillInvisible: boolean;
  136456. /**
  136457. * @hidden Last computed particle rotation matrix
  136458. */
  136459. _rotationMatrix: number[];
  136460. /**
  136461. * Parent particle Id, if any.
  136462. * Default null.
  136463. */
  136464. parentId: Nullable<number>;
  136465. /**
  136466. * @hidden Internal global position in the PCS.
  136467. */
  136468. _globalPosition: Vector3;
  136469. /**
  136470. * Creates a Point Cloud object.
  136471. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136472. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136473. * @param group (PointsGroup) is the group the particle belongs to
  136474. * @param groupId (integer) is the group identifier in the PCS.
  136475. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136476. * @param pcs defines the PCS it is associated to
  136477. */
  136478. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136479. /**
  136480. * get point size
  136481. */
  136482. get size(): Vector3;
  136483. /**
  136484. * Set point size
  136485. */
  136486. set size(scale: Vector3);
  136487. /**
  136488. * Legacy support, changed quaternion to rotationQuaternion
  136489. */
  136490. get quaternion(): Nullable<Quaternion>;
  136491. /**
  136492. * Legacy support, changed quaternion to rotationQuaternion
  136493. */
  136494. set quaternion(q: Nullable<Quaternion>);
  136495. /**
  136496. * Returns a boolean. True if the particle intersects a mesh, else false
  136497. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136498. * @param target is the object (point or mesh) what the intersection is computed against
  136499. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136500. * @returns true if it intersects
  136501. */
  136502. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136503. /**
  136504. * get the rotation matrix of the particle
  136505. * @hidden
  136506. */
  136507. getRotationMatrix(m: Matrix): void;
  136508. }
  136509. /**
  136510. * Represents a group of points in a points cloud system
  136511. * * PCS internal tool, don't use it manually.
  136512. */
  136513. export class PointsGroup {
  136514. /**
  136515. * The group id
  136516. * @hidden
  136517. */
  136518. groupID: number;
  136519. /**
  136520. * image data for group (internal use)
  136521. * @hidden
  136522. */
  136523. _groupImageData: Nullable<ArrayBufferView>;
  136524. /**
  136525. * Image Width (internal use)
  136526. * @hidden
  136527. */
  136528. _groupImgWidth: number;
  136529. /**
  136530. * Image Height (internal use)
  136531. * @hidden
  136532. */
  136533. _groupImgHeight: number;
  136534. /**
  136535. * Custom position function (internal use)
  136536. * @hidden
  136537. */
  136538. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136539. /**
  136540. * density per facet for surface points
  136541. * @hidden
  136542. */
  136543. _groupDensity: number[];
  136544. /**
  136545. * Only when points are colored by texture carries pointer to texture list array
  136546. * @hidden
  136547. */
  136548. _textureNb: number;
  136549. /**
  136550. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136551. * PCS internal tool, don't use it manually.
  136552. * @hidden
  136553. */
  136554. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136555. }
  136556. }
  136557. declare module BABYLON {
  136558. interface Scene {
  136559. /** @hidden (Backing field) */
  136560. _physicsEngine: Nullable<IPhysicsEngine>;
  136561. /** @hidden */
  136562. _physicsTimeAccumulator: number;
  136563. /**
  136564. * Gets the current physics engine
  136565. * @returns a IPhysicsEngine or null if none attached
  136566. */
  136567. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136568. /**
  136569. * Enables physics to the current scene
  136570. * @param gravity defines the scene's gravity for the physics engine
  136571. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136572. * @return a boolean indicating if the physics engine was initialized
  136573. */
  136574. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136575. /**
  136576. * Disables and disposes the physics engine associated with the scene
  136577. */
  136578. disablePhysicsEngine(): void;
  136579. /**
  136580. * Gets a boolean indicating if there is an active physics engine
  136581. * @returns a boolean indicating if there is an active physics engine
  136582. */
  136583. isPhysicsEnabled(): boolean;
  136584. /**
  136585. * Deletes a physics compound impostor
  136586. * @param compound defines the compound to delete
  136587. */
  136588. deleteCompoundImpostor(compound: any): void;
  136589. /**
  136590. * An event triggered when physic simulation is about to be run
  136591. */
  136592. onBeforePhysicsObservable: Observable<Scene>;
  136593. /**
  136594. * An event triggered when physic simulation has been done
  136595. */
  136596. onAfterPhysicsObservable: Observable<Scene>;
  136597. }
  136598. interface AbstractMesh {
  136599. /** @hidden */
  136600. _physicsImpostor: Nullable<PhysicsImpostor>;
  136601. /**
  136602. * Gets or sets impostor used for physic simulation
  136603. * @see http://doc.babylonjs.com/features/physics_engine
  136604. */
  136605. physicsImpostor: Nullable<PhysicsImpostor>;
  136606. /**
  136607. * Gets the current physics impostor
  136608. * @see http://doc.babylonjs.com/features/physics_engine
  136609. * @returns a physics impostor or null
  136610. */
  136611. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136612. /** Apply a physic impulse to the mesh
  136613. * @param force defines the force to apply
  136614. * @param contactPoint defines where to apply the force
  136615. * @returns the current mesh
  136616. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136617. */
  136618. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136619. /**
  136620. * Creates a physic joint between two meshes
  136621. * @param otherMesh defines the other mesh to use
  136622. * @param pivot1 defines the pivot to use on this mesh
  136623. * @param pivot2 defines the pivot to use on the other mesh
  136624. * @param options defines additional options (can be plugin dependent)
  136625. * @returns the current mesh
  136626. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136627. */
  136628. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136629. /** @hidden */
  136630. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136631. }
  136632. /**
  136633. * Defines the physics engine scene component responsible to manage a physics engine
  136634. */
  136635. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136636. /**
  136637. * The component name helpful to identify the component in the list of scene components.
  136638. */
  136639. readonly name: string;
  136640. /**
  136641. * The scene the component belongs to.
  136642. */
  136643. scene: Scene;
  136644. /**
  136645. * Creates a new instance of the component for the given scene
  136646. * @param scene Defines the scene to register the component in
  136647. */
  136648. constructor(scene: Scene);
  136649. /**
  136650. * Registers the component in a given scene
  136651. */
  136652. register(): void;
  136653. /**
  136654. * Rebuilds the elements related to this component in case of
  136655. * context lost for instance.
  136656. */
  136657. rebuild(): void;
  136658. /**
  136659. * Disposes the component and the associated ressources
  136660. */
  136661. dispose(): void;
  136662. }
  136663. }
  136664. declare module BABYLON {
  136665. /**
  136666. * A helper for physics simulations
  136667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136668. */
  136669. export class PhysicsHelper {
  136670. private _scene;
  136671. private _physicsEngine;
  136672. /**
  136673. * Initializes the Physics helper
  136674. * @param scene Babylon.js scene
  136675. */
  136676. constructor(scene: Scene);
  136677. /**
  136678. * Applies a radial explosion impulse
  136679. * @param origin the origin of the explosion
  136680. * @param radiusOrEventOptions the radius or the options of radial explosion
  136681. * @param strength the explosion strength
  136682. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136683. * @returns A physics radial explosion event, or null
  136684. */
  136685. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136686. /**
  136687. * Applies a radial explosion force
  136688. * @param origin the origin of the explosion
  136689. * @param radiusOrEventOptions the radius or the options of radial explosion
  136690. * @param strength the explosion strength
  136691. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136692. * @returns A physics radial explosion event, or null
  136693. */
  136694. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136695. /**
  136696. * Creates a gravitational field
  136697. * @param origin the origin of the explosion
  136698. * @param radiusOrEventOptions the radius or the options of radial explosion
  136699. * @param strength the explosion strength
  136700. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136701. * @returns A physics gravitational field event, or null
  136702. */
  136703. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136704. /**
  136705. * Creates a physics updraft event
  136706. * @param origin the origin of the updraft
  136707. * @param radiusOrEventOptions the radius or the options of the updraft
  136708. * @param strength the strength of the updraft
  136709. * @param height the height of the updraft
  136710. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136711. * @returns A physics updraft event, or null
  136712. */
  136713. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136714. /**
  136715. * Creates a physics vortex event
  136716. * @param origin the of the vortex
  136717. * @param radiusOrEventOptions the radius or the options of the vortex
  136718. * @param strength the strength of the vortex
  136719. * @param height the height of the vortex
  136720. * @returns a Physics vortex event, or null
  136721. * A physics vortex event or null
  136722. */
  136723. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136724. }
  136725. /**
  136726. * Represents a physics radial explosion event
  136727. */
  136728. class PhysicsRadialExplosionEvent {
  136729. private _scene;
  136730. private _options;
  136731. private _sphere;
  136732. private _dataFetched;
  136733. /**
  136734. * Initializes a radial explosioin event
  136735. * @param _scene BabylonJS scene
  136736. * @param _options The options for the vortex event
  136737. */
  136738. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136739. /**
  136740. * Returns the data related to the radial explosion event (sphere).
  136741. * @returns The radial explosion event data
  136742. */
  136743. getData(): PhysicsRadialExplosionEventData;
  136744. /**
  136745. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136746. * @param impostor A physics imposter
  136747. * @param origin the origin of the explosion
  136748. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136749. */
  136750. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136751. /**
  136752. * Triggers affecterd impostors callbacks
  136753. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136754. */
  136755. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136756. /**
  136757. * Disposes the sphere.
  136758. * @param force Specifies if the sphere should be disposed by force
  136759. */
  136760. dispose(force?: boolean): void;
  136761. /*** Helpers ***/
  136762. private _prepareSphere;
  136763. private _intersectsWithSphere;
  136764. }
  136765. /**
  136766. * Represents a gravitational field event
  136767. */
  136768. class PhysicsGravitationalFieldEvent {
  136769. private _physicsHelper;
  136770. private _scene;
  136771. private _origin;
  136772. private _options;
  136773. private _tickCallback;
  136774. private _sphere;
  136775. private _dataFetched;
  136776. /**
  136777. * Initializes the physics gravitational field event
  136778. * @param _physicsHelper A physics helper
  136779. * @param _scene BabylonJS scene
  136780. * @param _origin The origin position of the gravitational field event
  136781. * @param _options The options for the vortex event
  136782. */
  136783. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136784. /**
  136785. * Returns the data related to the gravitational field event (sphere).
  136786. * @returns A gravitational field event
  136787. */
  136788. getData(): PhysicsGravitationalFieldEventData;
  136789. /**
  136790. * Enables the gravitational field.
  136791. */
  136792. enable(): void;
  136793. /**
  136794. * Disables the gravitational field.
  136795. */
  136796. disable(): void;
  136797. /**
  136798. * Disposes the sphere.
  136799. * @param force The force to dispose from the gravitational field event
  136800. */
  136801. dispose(force?: boolean): void;
  136802. private _tick;
  136803. }
  136804. /**
  136805. * Represents a physics updraft event
  136806. */
  136807. class PhysicsUpdraftEvent {
  136808. private _scene;
  136809. private _origin;
  136810. private _options;
  136811. private _physicsEngine;
  136812. private _originTop;
  136813. private _originDirection;
  136814. private _tickCallback;
  136815. private _cylinder;
  136816. private _cylinderPosition;
  136817. private _dataFetched;
  136818. /**
  136819. * Initializes the physics updraft event
  136820. * @param _scene BabylonJS scene
  136821. * @param _origin The origin position of the updraft
  136822. * @param _options The options for the updraft event
  136823. */
  136824. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136825. /**
  136826. * Returns the data related to the updraft event (cylinder).
  136827. * @returns A physics updraft event
  136828. */
  136829. getData(): PhysicsUpdraftEventData;
  136830. /**
  136831. * Enables the updraft.
  136832. */
  136833. enable(): void;
  136834. /**
  136835. * Disables the updraft.
  136836. */
  136837. disable(): void;
  136838. /**
  136839. * Disposes the cylinder.
  136840. * @param force Specifies if the updraft should be disposed by force
  136841. */
  136842. dispose(force?: boolean): void;
  136843. private getImpostorHitData;
  136844. private _tick;
  136845. /*** Helpers ***/
  136846. private _prepareCylinder;
  136847. private _intersectsWithCylinder;
  136848. }
  136849. /**
  136850. * Represents a physics vortex event
  136851. */
  136852. class PhysicsVortexEvent {
  136853. private _scene;
  136854. private _origin;
  136855. private _options;
  136856. private _physicsEngine;
  136857. private _originTop;
  136858. private _tickCallback;
  136859. private _cylinder;
  136860. private _cylinderPosition;
  136861. private _dataFetched;
  136862. /**
  136863. * Initializes the physics vortex event
  136864. * @param _scene The BabylonJS scene
  136865. * @param _origin The origin position of the vortex
  136866. * @param _options The options for the vortex event
  136867. */
  136868. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136869. /**
  136870. * Returns the data related to the vortex event (cylinder).
  136871. * @returns The physics vortex event data
  136872. */
  136873. getData(): PhysicsVortexEventData;
  136874. /**
  136875. * Enables the vortex.
  136876. */
  136877. enable(): void;
  136878. /**
  136879. * Disables the cortex.
  136880. */
  136881. disable(): void;
  136882. /**
  136883. * Disposes the sphere.
  136884. * @param force
  136885. */
  136886. dispose(force?: boolean): void;
  136887. private getImpostorHitData;
  136888. private _tick;
  136889. /*** Helpers ***/
  136890. private _prepareCylinder;
  136891. private _intersectsWithCylinder;
  136892. }
  136893. /**
  136894. * Options fot the radial explosion event
  136895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136896. */
  136897. export class PhysicsRadialExplosionEventOptions {
  136898. /**
  136899. * The radius of the sphere for the radial explosion.
  136900. */
  136901. radius: number;
  136902. /**
  136903. * The strenth of the explosion.
  136904. */
  136905. strength: number;
  136906. /**
  136907. * The strenght of the force in correspondence to the distance of the affected object
  136908. */
  136909. falloff: PhysicsRadialImpulseFalloff;
  136910. /**
  136911. * Sphere options for the radial explosion.
  136912. */
  136913. sphere: {
  136914. segments: number;
  136915. diameter: number;
  136916. };
  136917. /**
  136918. * Sphere options for the radial explosion.
  136919. */
  136920. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136921. }
  136922. /**
  136923. * Options fot the updraft event
  136924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136925. */
  136926. export class PhysicsUpdraftEventOptions {
  136927. /**
  136928. * The radius of the cylinder for the vortex
  136929. */
  136930. radius: number;
  136931. /**
  136932. * The strenth of the updraft.
  136933. */
  136934. strength: number;
  136935. /**
  136936. * The height of the cylinder for the updraft.
  136937. */
  136938. height: number;
  136939. /**
  136940. * The mode for the the updraft.
  136941. */
  136942. updraftMode: PhysicsUpdraftMode;
  136943. }
  136944. /**
  136945. * Options fot the vortex event
  136946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136947. */
  136948. export class PhysicsVortexEventOptions {
  136949. /**
  136950. * The radius of the cylinder for the vortex
  136951. */
  136952. radius: number;
  136953. /**
  136954. * The strenth of the vortex.
  136955. */
  136956. strength: number;
  136957. /**
  136958. * The height of the cylinder for the vortex.
  136959. */
  136960. height: number;
  136961. /**
  136962. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136963. */
  136964. centripetalForceThreshold: number;
  136965. /**
  136966. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136967. */
  136968. centripetalForceMultiplier: number;
  136969. /**
  136970. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136971. */
  136972. centrifugalForceMultiplier: number;
  136973. /**
  136974. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136975. */
  136976. updraftForceMultiplier: number;
  136977. }
  136978. /**
  136979. * The strenght of the force in correspondence to the distance of the affected object
  136980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136981. */
  136982. export enum PhysicsRadialImpulseFalloff {
  136983. /** Defines that impulse is constant in strength across it's whole radius */
  136984. Constant = 0,
  136985. /** Defines that impulse gets weaker if it's further from the origin */
  136986. Linear = 1
  136987. }
  136988. /**
  136989. * The strength of the force in correspondence to the distance of the affected object
  136990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136991. */
  136992. export enum PhysicsUpdraftMode {
  136993. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136994. Center = 0,
  136995. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136996. Perpendicular = 1
  136997. }
  136998. /**
  136999. * Interface for a physics hit data
  137000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137001. */
  137002. export interface PhysicsHitData {
  137003. /**
  137004. * The force applied at the contact point
  137005. */
  137006. force: Vector3;
  137007. /**
  137008. * The contact point
  137009. */
  137010. contactPoint: Vector3;
  137011. /**
  137012. * The distance from the origin to the contact point
  137013. */
  137014. distanceFromOrigin: number;
  137015. }
  137016. /**
  137017. * Interface for radial explosion event data
  137018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137019. */
  137020. export interface PhysicsRadialExplosionEventData {
  137021. /**
  137022. * A sphere used for the radial explosion event
  137023. */
  137024. sphere: Mesh;
  137025. }
  137026. /**
  137027. * Interface for gravitational field event data
  137028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137029. */
  137030. export interface PhysicsGravitationalFieldEventData {
  137031. /**
  137032. * A sphere mesh used for the gravitational field event
  137033. */
  137034. sphere: Mesh;
  137035. }
  137036. /**
  137037. * Interface for updraft event data
  137038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137039. */
  137040. export interface PhysicsUpdraftEventData {
  137041. /**
  137042. * A cylinder used for the updraft event
  137043. */
  137044. cylinder: Mesh;
  137045. }
  137046. /**
  137047. * Interface for vortex event data
  137048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137049. */
  137050. export interface PhysicsVortexEventData {
  137051. /**
  137052. * A cylinder used for the vortex event
  137053. */
  137054. cylinder: Mesh;
  137055. }
  137056. /**
  137057. * Interface for an affected physics impostor
  137058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137059. */
  137060. export interface PhysicsAffectedImpostorWithData {
  137061. /**
  137062. * The impostor affected by the effect
  137063. */
  137064. impostor: PhysicsImpostor;
  137065. /**
  137066. * The data about the hit/horce from the explosion
  137067. */
  137068. hitData: PhysicsHitData;
  137069. }
  137070. }
  137071. declare module BABYLON {
  137072. /** @hidden */
  137073. export var blackAndWhitePixelShader: {
  137074. name: string;
  137075. shader: string;
  137076. };
  137077. }
  137078. declare module BABYLON {
  137079. /**
  137080. * Post process used to render in black and white
  137081. */
  137082. export class BlackAndWhitePostProcess extends PostProcess {
  137083. /**
  137084. * Linear about to convert he result to black and white (default: 1)
  137085. */
  137086. degree: number;
  137087. /**
  137088. * Creates a black and white post process
  137089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137090. * @param name The name of the effect.
  137091. * @param options The required width/height ratio to downsize to before computing the render pass.
  137092. * @param camera The camera to apply the render pass to.
  137093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137094. * @param engine The engine which the post process will be applied. (default: current engine)
  137095. * @param reusable If the post process can be reused on the same frame. (default: false)
  137096. */
  137097. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137098. }
  137099. }
  137100. declare module BABYLON {
  137101. /**
  137102. * This represents a set of one or more post processes in Babylon.
  137103. * A post process can be used to apply a shader to a texture after it is rendered.
  137104. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137105. */
  137106. export class PostProcessRenderEffect {
  137107. private _postProcesses;
  137108. private _getPostProcesses;
  137109. private _singleInstance;
  137110. private _cameras;
  137111. private _indicesForCamera;
  137112. /**
  137113. * Name of the effect
  137114. * @hidden
  137115. */
  137116. _name: string;
  137117. /**
  137118. * Instantiates a post process render effect.
  137119. * A post process can be used to apply a shader to a texture after it is rendered.
  137120. * @param engine The engine the effect is tied to
  137121. * @param name The name of the effect
  137122. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137123. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137124. */
  137125. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137126. /**
  137127. * Checks if all the post processes in the effect are supported.
  137128. */
  137129. get isSupported(): boolean;
  137130. /**
  137131. * Updates the current state of the effect
  137132. * @hidden
  137133. */
  137134. _update(): void;
  137135. /**
  137136. * Attaches the effect on cameras
  137137. * @param cameras The camera to attach to.
  137138. * @hidden
  137139. */
  137140. _attachCameras(cameras: Camera): void;
  137141. /**
  137142. * Attaches the effect on cameras
  137143. * @param cameras The camera to attach to.
  137144. * @hidden
  137145. */
  137146. _attachCameras(cameras: Camera[]): void;
  137147. /**
  137148. * Detaches the effect on cameras
  137149. * @param cameras The camera to detatch from.
  137150. * @hidden
  137151. */
  137152. _detachCameras(cameras: Camera): void;
  137153. /**
  137154. * Detatches the effect on cameras
  137155. * @param cameras The camera to detatch from.
  137156. * @hidden
  137157. */
  137158. _detachCameras(cameras: Camera[]): void;
  137159. /**
  137160. * Enables the effect on given cameras
  137161. * @param cameras The camera to enable.
  137162. * @hidden
  137163. */
  137164. _enable(cameras: Camera): void;
  137165. /**
  137166. * Enables the effect on given cameras
  137167. * @param cameras The camera to enable.
  137168. * @hidden
  137169. */
  137170. _enable(cameras: Nullable<Camera[]>): void;
  137171. /**
  137172. * Disables the effect on the given cameras
  137173. * @param cameras The camera to disable.
  137174. * @hidden
  137175. */
  137176. _disable(cameras: Camera): void;
  137177. /**
  137178. * Disables the effect on the given cameras
  137179. * @param cameras The camera to disable.
  137180. * @hidden
  137181. */
  137182. _disable(cameras: Nullable<Camera[]>): void;
  137183. /**
  137184. * Gets a list of the post processes contained in the effect.
  137185. * @param camera The camera to get the post processes on.
  137186. * @returns The list of the post processes in the effect.
  137187. */
  137188. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137189. }
  137190. }
  137191. declare module BABYLON {
  137192. /** @hidden */
  137193. export var extractHighlightsPixelShader: {
  137194. name: string;
  137195. shader: string;
  137196. };
  137197. }
  137198. declare module BABYLON {
  137199. /**
  137200. * 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.
  137201. */
  137202. export class ExtractHighlightsPostProcess extends PostProcess {
  137203. /**
  137204. * The luminance threshold, pixels below this value will be set to black.
  137205. */
  137206. threshold: number;
  137207. /** @hidden */
  137208. _exposure: number;
  137209. /**
  137210. * Post process which has the input texture to be used when performing highlight extraction
  137211. * @hidden
  137212. */
  137213. _inputPostProcess: Nullable<PostProcess>;
  137214. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137215. }
  137216. }
  137217. declare module BABYLON {
  137218. /** @hidden */
  137219. export var bloomMergePixelShader: {
  137220. name: string;
  137221. shader: string;
  137222. };
  137223. }
  137224. declare module BABYLON {
  137225. /**
  137226. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137227. */
  137228. export class BloomMergePostProcess extends PostProcess {
  137229. /** Weight of the bloom to be added to the original input. */
  137230. weight: number;
  137231. /**
  137232. * Creates a new instance of @see BloomMergePostProcess
  137233. * @param name The name of the effect.
  137234. * @param originalFromInput Post process which's input will be used for the merge.
  137235. * @param blurred Blurred highlights post process which's output will be used.
  137236. * @param weight Weight of the bloom to be added to the original input.
  137237. * @param options The required width/height ratio to downsize to before computing the render pass.
  137238. * @param camera The camera to apply the render pass to.
  137239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137240. * @param engine The engine which the post process will be applied. (default: current engine)
  137241. * @param reusable If the post process can be reused on the same frame. (default: false)
  137242. * @param textureType Type of textures used when performing the post process. (default: 0)
  137243. * @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)
  137244. */
  137245. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137246. /** Weight of the bloom to be added to the original input. */
  137247. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137248. }
  137249. }
  137250. declare module BABYLON {
  137251. /**
  137252. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137253. */
  137254. export class BloomEffect extends PostProcessRenderEffect {
  137255. private bloomScale;
  137256. /**
  137257. * @hidden Internal
  137258. */
  137259. _effects: Array<PostProcess>;
  137260. /**
  137261. * @hidden Internal
  137262. */
  137263. _downscale: ExtractHighlightsPostProcess;
  137264. private _blurX;
  137265. private _blurY;
  137266. private _merge;
  137267. /**
  137268. * The luminance threshold to find bright areas of the image to bloom.
  137269. */
  137270. get threshold(): number;
  137271. set threshold(value: number);
  137272. /**
  137273. * The strength of the bloom.
  137274. */
  137275. get weight(): number;
  137276. set weight(value: number);
  137277. /**
  137278. * Specifies the size of the bloom blur kernel, relative to the final output size
  137279. */
  137280. get kernel(): number;
  137281. set kernel(value: number);
  137282. /**
  137283. * Creates a new instance of @see BloomEffect
  137284. * @param scene The scene the effect belongs to.
  137285. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137286. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137287. * @param bloomWeight The the strength of bloom.
  137288. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137289. * @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)
  137290. */
  137291. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137292. /**
  137293. * Disposes each of the internal effects for a given camera.
  137294. * @param camera The camera to dispose the effect on.
  137295. */
  137296. disposeEffects(camera: Camera): void;
  137297. /**
  137298. * @hidden Internal
  137299. */
  137300. _updateEffects(): void;
  137301. /**
  137302. * Internal
  137303. * @returns if all the contained post processes are ready.
  137304. * @hidden
  137305. */
  137306. _isReady(): boolean;
  137307. }
  137308. }
  137309. declare module BABYLON {
  137310. /** @hidden */
  137311. export var chromaticAberrationPixelShader: {
  137312. name: string;
  137313. shader: string;
  137314. };
  137315. }
  137316. declare module BABYLON {
  137317. /**
  137318. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137319. */
  137320. export class ChromaticAberrationPostProcess extends PostProcess {
  137321. /**
  137322. * The amount of seperation of rgb channels (default: 30)
  137323. */
  137324. aberrationAmount: number;
  137325. /**
  137326. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137327. */
  137328. radialIntensity: number;
  137329. /**
  137330. * 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))
  137331. */
  137332. direction: Vector2;
  137333. /**
  137334. * 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))
  137335. */
  137336. centerPosition: Vector2;
  137337. /**
  137338. * Creates a new instance ChromaticAberrationPostProcess
  137339. * @param name The name of the effect.
  137340. * @param screenWidth The width of the screen to apply the effect on.
  137341. * @param screenHeight The height of the screen to apply the effect on.
  137342. * @param options The required width/height ratio to downsize to before computing the render pass.
  137343. * @param camera The camera to apply the render pass to.
  137344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137345. * @param engine The engine which the post process will be applied. (default: current engine)
  137346. * @param reusable If the post process can be reused on the same frame. (default: false)
  137347. * @param textureType Type of textures used when performing the post process. (default: 0)
  137348. * @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)
  137349. */
  137350. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137351. }
  137352. }
  137353. declare module BABYLON {
  137354. /** @hidden */
  137355. export var circleOfConfusionPixelShader: {
  137356. name: string;
  137357. shader: string;
  137358. };
  137359. }
  137360. declare module BABYLON {
  137361. /**
  137362. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137363. */
  137364. export class CircleOfConfusionPostProcess extends PostProcess {
  137365. /**
  137366. * 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.
  137367. */
  137368. lensSize: number;
  137369. /**
  137370. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137371. */
  137372. fStop: number;
  137373. /**
  137374. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137375. */
  137376. focusDistance: number;
  137377. /**
  137378. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137379. */
  137380. focalLength: number;
  137381. private _depthTexture;
  137382. /**
  137383. * Creates a new instance CircleOfConfusionPostProcess
  137384. * @param name The name of the effect.
  137385. * @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.
  137386. * @param options The required width/height ratio to downsize to before computing the render pass.
  137387. * @param camera The camera to apply the render pass to.
  137388. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137389. * @param engine The engine which the post process will be applied. (default: current engine)
  137390. * @param reusable If the post process can be reused on the same frame. (default: false)
  137391. * @param textureType Type of textures used when performing the post process. (default: 0)
  137392. * @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)
  137393. */
  137394. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137395. /**
  137396. * 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.
  137397. */
  137398. set depthTexture(value: RenderTargetTexture);
  137399. }
  137400. }
  137401. declare module BABYLON {
  137402. /** @hidden */
  137403. export var colorCorrectionPixelShader: {
  137404. name: string;
  137405. shader: string;
  137406. };
  137407. }
  137408. declare module BABYLON {
  137409. /**
  137410. *
  137411. * This post-process allows the modification of rendered colors by using
  137412. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137413. *
  137414. * The object needs to be provided an url to a texture containing the color
  137415. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137416. * Use an image editing software to tweak the LUT to match your needs.
  137417. *
  137418. * For an example of a color LUT, see here:
  137419. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137420. * For explanations on color grading, see here:
  137421. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137422. *
  137423. */
  137424. export class ColorCorrectionPostProcess extends PostProcess {
  137425. private _colorTableTexture;
  137426. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137427. }
  137428. }
  137429. declare module BABYLON {
  137430. /** @hidden */
  137431. export var convolutionPixelShader: {
  137432. name: string;
  137433. shader: string;
  137434. };
  137435. }
  137436. declare module BABYLON {
  137437. /**
  137438. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137439. * input texture to perform effects such as edge detection or sharpening
  137440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137441. */
  137442. export class ConvolutionPostProcess extends PostProcess {
  137443. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137444. kernel: number[];
  137445. /**
  137446. * Creates a new instance ConvolutionPostProcess
  137447. * @param name The name of the effect.
  137448. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137449. * @param options The required width/height ratio to downsize to before computing the render pass.
  137450. * @param camera The camera to apply the render pass to.
  137451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137452. * @param engine The engine which the post process will be applied. (default: current engine)
  137453. * @param reusable If the post process can be reused on the same frame. (default: false)
  137454. * @param textureType Type of textures used when performing the post process. (default: 0)
  137455. */
  137456. constructor(name: string,
  137457. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137458. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137459. /**
  137460. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137461. */
  137462. static EdgeDetect0Kernel: number[];
  137463. /**
  137464. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137465. */
  137466. static EdgeDetect1Kernel: number[];
  137467. /**
  137468. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137469. */
  137470. static EdgeDetect2Kernel: number[];
  137471. /**
  137472. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137473. */
  137474. static SharpenKernel: number[];
  137475. /**
  137476. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137477. */
  137478. static EmbossKernel: number[];
  137479. /**
  137480. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137481. */
  137482. static GaussianKernel: number[];
  137483. }
  137484. }
  137485. declare module BABYLON {
  137486. /**
  137487. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137488. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137489. * based on samples that have a large difference in distance than the center pixel.
  137490. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137491. */
  137492. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137493. direction: Vector2;
  137494. /**
  137495. * Creates a new instance CircleOfConfusionPostProcess
  137496. * @param name The name of the effect.
  137497. * @param scene The scene the effect belongs to.
  137498. * @param direction The direction the blur should be applied.
  137499. * @param kernel The size of the kernel used to blur.
  137500. * @param options The required width/height ratio to downsize to before computing the render pass.
  137501. * @param camera The camera to apply the render pass to.
  137502. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137503. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137505. * @param engine The engine which the post process will be applied. (default: current engine)
  137506. * @param reusable If the post process can be reused on the same frame. (default: false)
  137507. * @param textureType Type of textures used when performing the post process. (default: 0)
  137508. * @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)
  137509. */
  137510. 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);
  137511. }
  137512. }
  137513. declare module BABYLON {
  137514. /** @hidden */
  137515. export var depthOfFieldMergePixelShader: {
  137516. name: string;
  137517. shader: string;
  137518. };
  137519. }
  137520. declare module BABYLON {
  137521. /**
  137522. * Options to be set when merging outputs from the default pipeline.
  137523. */
  137524. export class DepthOfFieldMergePostProcessOptions {
  137525. /**
  137526. * The original image to merge on top of
  137527. */
  137528. originalFromInput: PostProcess;
  137529. /**
  137530. * Parameters to perform the merge of the depth of field effect
  137531. */
  137532. depthOfField?: {
  137533. circleOfConfusion: PostProcess;
  137534. blurSteps: Array<PostProcess>;
  137535. };
  137536. /**
  137537. * Parameters to perform the merge of bloom effect
  137538. */
  137539. bloom?: {
  137540. blurred: PostProcess;
  137541. weight: number;
  137542. };
  137543. }
  137544. /**
  137545. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137546. */
  137547. export class DepthOfFieldMergePostProcess extends PostProcess {
  137548. private blurSteps;
  137549. /**
  137550. * Creates a new instance of DepthOfFieldMergePostProcess
  137551. * @param name The name of the effect.
  137552. * @param originalFromInput Post process which's input will be used for the merge.
  137553. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137554. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137555. * @param options The required width/height ratio to downsize to before computing the render pass.
  137556. * @param camera The camera to apply the render pass to.
  137557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137558. * @param engine The engine which the post process will be applied. (default: current engine)
  137559. * @param reusable If the post process can be reused on the same frame. (default: false)
  137560. * @param textureType Type of textures used when performing the post process. (default: 0)
  137561. * @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)
  137562. */
  137563. 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);
  137564. /**
  137565. * Updates the effect with the current post process compile time values and recompiles the shader.
  137566. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137567. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137568. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137569. * @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
  137570. * @param onCompiled Called when the shader has been compiled.
  137571. * @param onError Called if there is an error when compiling a shader.
  137572. */
  137573. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137574. }
  137575. }
  137576. declare module BABYLON {
  137577. /**
  137578. * Specifies the level of max blur that should be applied when using the depth of field effect
  137579. */
  137580. export enum DepthOfFieldEffectBlurLevel {
  137581. /**
  137582. * Subtle blur
  137583. */
  137584. Low = 0,
  137585. /**
  137586. * Medium blur
  137587. */
  137588. Medium = 1,
  137589. /**
  137590. * Large blur
  137591. */
  137592. High = 2
  137593. }
  137594. /**
  137595. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137596. */
  137597. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137598. private _circleOfConfusion;
  137599. /**
  137600. * @hidden Internal, blurs from high to low
  137601. */
  137602. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137603. private _depthOfFieldBlurY;
  137604. private _dofMerge;
  137605. /**
  137606. * @hidden Internal post processes in depth of field effect
  137607. */
  137608. _effects: Array<PostProcess>;
  137609. /**
  137610. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137611. */
  137612. set focalLength(value: number);
  137613. get focalLength(): number;
  137614. /**
  137615. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137616. */
  137617. set fStop(value: number);
  137618. get fStop(): number;
  137619. /**
  137620. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137621. */
  137622. set focusDistance(value: number);
  137623. get focusDistance(): number;
  137624. /**
  137625. * 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.
  137626. */
  137627. set lensSize(value: number);
  137628. get lensSize(): number;
  137629. /**
  137630. * Creates a new instance DepthOfFieldEffect
  137631. * @param scene The scene the effect belongs to.
  137632. * @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.
  137633. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137634. * @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)
  137635. */
  137636. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137637. /**
  137638. * Get the current class name of the current effet
  137639. * @returns "DepthOfFieldEffect"
  137640. */
  137641. getClassName(): string;
  137642. /**
  137643. * 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.
  137644. */
  137645. set depthTexture(value: RenderTargetTexture);
  137646. /**
  137647. * Disposes each of the internal effects for a given camera.
  137648. * @param camera The camera to dispose the effect on.
  137649. */
  137650. disposeEffects(camera: Camera): void;
  137651. /**
  137652. * @hidden Internal
  137653. */
  137654. _updateEffects(): void;
  137655. /**
  137656. * Internal
  137657. * @returns if all the contained post processes are ready.
  137658. * @hidden
  137659. */
  137660. _isReady(): boolean;
  137661. }
  137662. }
  137663. declare module BABYLON {
  137664. /** @hidden */
  137665. export var displayPassPixelShader: {
  137666. name: string;
  137667. shader: string;
  137668. };
  137669. }
  137670. declare module BABYLON {
  137671. /**
  137672. * DisplayPassPostProcess which produces an output the same as it's input
  137673. */
  137674. export class DisplayPassPostProcess extends PostProcess {
  137675. /**
  137676. * Creates the DisplayPassPostProcess
  137677. * @param name The name of the effect.
  137678. * @param options The required width/height ratio to downsize to before computing the render pass.
  137679. * @param camera The camera to apply the render pass to.
  137680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137681. * @param engine The engine which the post process will be applied. (default: current engine)
  137682. * @param reusable If the post process can be reused on the same frame. (default: false)
  137683. */
  137684. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137685. }
  137686. }
  137687. declare module BABYLON {
  137688. /** @hidden */
  137689. export var filterPixelShader: {
  137690. name: string;
  137691. shader: string;
  137692. };
  137693. }
  137694. declare module BABYLON {
  137695. /**
  137696. * Applies a kernel filter to the image
  137697. */
  137698. export class FilterPostProcess extends PostProcess {
  137699. /** The matrix to be applied to the image */
  137700. kernelMatrix: Matrix;
  137701. /**
  137702. *
  137703. * @param name The name of the effect.
  137704. * @param kernelMatrix The matrix to be applied to the image
  137705. * @param options The required width/height ratio to downsize to before computing the render pass.
  137706. * @param camera The camera to apply the render pass to.
  137707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137708. * @param engine The engine which the post process will be applied. (default: current engine)
  137709. * @param reusable If the post process can be reused on the same frame. (default: false)
  137710. */
  137711. constructor(name: string,
  137712. /** The matrix to be applied to the image */
  137713. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137714. }
  137715. }
  137716. declare module BABYLON {
  137717. /** @hidden */
  137718. export var fxaaPixelShader: {
  137719. name: string;
  137720. shader: string;
  137721. };
  137722. }
  137723. declare module BABYLON {
  137724. /** @hidden */
  137725. export var fxaaVertexShader: {
  137726. name: string;
  137727. shader: string;
  137728. };
  137729. }
  137730. declare module BABYLON {
  137731. /**
  137732. * Fxaa post process
  137733. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137734. */
  137735. export class FxaaPostProcess extends PostProcess {
  137736. /** @hidden */
  137737. texelWidth: number;
  137738. /** @hidden */
  137739. texelHeight: number;
  137740. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137741. private _getDefines;
  137742. }
  137743. }
  137744. declare module BABYLON {
  137745. /** @hidden */
  137746. export var grainPixelShader: {
  137747. name: string;
  137748. shader: string;
  137749. };
  137750. }
  137751. declare module BABYLON {
  137752. /**
  137753. * The GrainPostProcess adds noise to the image at mid luminance levels
  137754. */
  137755. export class GrainPostProcess extends PostProcess {
  137756. /**
  137757. * The intensity of the grain added (default: 30)
  137758. */
  137759. intensity: number;
  137760. /**
  137761. * If the grain should be randomized on every frame
  137762. */
  137763. animated: boolean;
  137764. /**
  137765. * Creates a new instance of @see GrainPostProcess
  137766. * @param name The name of the effect.
  137767. * @param options The required width/height ratio to downsize to before computing the render pass.
  137768. * @param camera The camera to apply the render pass to.
  137769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137770. * @param engine The engine which the post process will be applied. (default: current engine)
  137771. * @param reusable If the post process can be reused on the same frame. (default: false)
  137772. * @param textureType Type of textures used when performing the post process. (default: 0)
  137773. * @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)
  137774. */
  137775. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137776. }
  137777. }
  137778. declare module BABYLON {
  137779. /** @hidden */
  137780. export var highlightsPixelShader: {
  137781. name: string;
  137782. shader: string;
  137783. };
  137784. }
  137785. declare module BABYLON {
  137786. /**
  137787. * Extracts highlights from the image
  137788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137789. */
  137790. export class HighlightsPostProcess extends PostProcess {
  137791. /**
  137792. * Extracts highlights from the image
  137793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137794. * @param name The name of the effect.
  137795. * @param options The required width/height ratio to downsize to before computing the render pass.
  137796. * @param camera The camera to apply the render pass to.
  137797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137798. * @param engine The engine which the post process will be applied. (default: current engine)
  137799. * @param reusable If the post process can be reused on the same frame. (default: false)
  137800. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137801. */
  137802. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137803. }
  137804. }
  137805. declare module BABYLON {
  137806. /** @hidden */
  137807. export var mrtFragmentDeclaration: {
  137808. name: string;
  137809. shader: string;
  137810. };
  137811. }
  137812. declare module BABYLON {
  137813. /** @hidden */
  137814. export var geometryPixelShader: {
  137815. name: string;
  137816. shader: string;
  137817. };
  137818. }
  137819. declare module BABYLON {
  137820. /** @hidden */
  137821. export var geometryVertexShader: {
  137822. name: string;
  137823. shader: string;
  137824. };
  137825. }
  137826. declare module BABYLON {
  137827. /** @hidden */
  137828. interface ISavedTransformationMatrix {
  137829. world: Matrix;
  137830. viewProjection: Matrix;
  137831. }
  137832. /**
  137833. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137834. */
  137835. export class GeometryBufferRenderer {
  137836. /**
  137837. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137838. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137839. */
  137840. static readonly POSITION_TEXTURE_TYPE: number;
  137841. /**
  137842. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137843. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137844. */
  137845. static readonly VELOCITY_TEXTURE_TYPE: number;
  137846. /**
  137847. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137848. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137849. */
  137850. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137851. /**
  137852. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137853. * in order to compute objects velocities when enableVelocity is set to "true"
  137854. * @hidden
  137855. */
  137856. _previousTransformationMatrices: {
  137857. [index: number]: ISavedTransformationMatrix;
  137858. };
  137859. /**
  137860. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137861. * in order to compute objects velocities when enableVelocity is set to "true"
  137862. * @hidden
  137863. */
  137864. _previousBonesTransformationMatrices: {
  137865. [index: number]: Float32Array;
  137866. };
  137867. /**
  137868. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137869. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137870. */
  137871. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137872. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137873. renderTransparentMeshes: boolean;
  137874. private _scene;
  137875. private _multiRenderTarget;
  137876. private _ratio;
  137877. private _enablePosition;
  137878. private _enableVelocity;
  137879. private _enableReflectivity;
  137880. private _positionIndex;
  137881. private _velocityIndex;
  137882. private _reflectivityIndex;
  137883. protected _effect: Effect;
  137884. protected _cachedDefines: string;
  137885. /**
  137886. * Set the render list (meshes to be rendered) used in the G buffer.
  137887. */
  137888. set renderList(meshes: Mesh[]);
  137889. /**
  137890. * Gets wether or not G buffer are supported by the running hardware.
  137891. * This requires draw buffer supports
  137892. */
  137893. get isSupported(): boolean;
  137894. /**
  137895. * Returns the index of the given texture type in the G-Buffer textures array
  137896. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137897. * @returns the index of the given texture type in the G-Buffer textures array
  137898. */
  137899. getTextureIndex(textureType: number): number;
  137900. /**
  137901. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137902. */
  137903. get enablePosition(): boolean;
  137904. /**
  137905. * Sets whether or not objects positions are enabled for the G buffer.
  137906. */
  137907. set enablePosition(enable: boolean);
  137908. /**
  137909. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137910. */
  137911. get enableVelocity(): boolean;
  137912. /**
  137913. * Sets wether or not objects velocities are enabled for the G buffer.
  137914. */
  137915. set enableVelocity(enable: boolean);
  137916. /**
  137917. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137918. */
  137919. get enableReflectivity(): boolean;
  137920. /**
  137921. * Sets wether or not objects roughness are enabled for the G buffer.
  137922. */
  137923. set enableReflectivity(enable: boolean);
  137924. /**
  137925. * Gets the scene associated with the buffer.
  137926. */
  137927. get scene(): Scene;
  137928. /**
  137929. * Gets the ratio used by the buffer during its creation.
  137930. * How big is the buffer related to the main canvas.
  137931. */
  137932. get ratio(): number;
  137933. /** @hidden */
  137934. static _SceneComponentInitialization: (scene: Scene) => void;
  137935. /**
  137936. * Creates a new G Buffer for the scene
  137937. * @param scene The scene the buffer belongs to
  137938. * @param ratio How big is the buffer related to the main canvas.
  137939. */
  137940. constructor(scene: Scene, ratio?: number);
  137941. /**
  137942. * Checks wether everything is ready to render a submesh to the G buffer.
  137943. * @param subMesh the submesh to check readiness for
  137944. * @param useInstances is the mesh drawn using instance or not
  137945. * @returns true if ready otherwise false
  137946. */
  137947. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137948. /**
  137949. * Gets the current underlying G Buffer.
  137950. * @returns the buffer
  137951. */
  137952. getGBuffer(): MultiRenderTarget;
  137953. /**
  137954. * Gets the number of samples used to render the buffer (anti aliasing).
  137955. */
  137956. get samples(): number;
  137957. /**
  137958. * Sets the number of samples used to render the buffer (anti aliasing).
  137959. */
  137960. set samples(value: number);
  137961. /**
  137962. * Disposes the renderer and frees up associated resources.
  137963. */
  137964. dispose(): void;
  137965. protected _createRenderTargets(): void;
  137966. private _copyBonesTransformationMatrices;
  137967. }
  137968. }
  137969. declare module BABYLON {
  137970. interface Scene {
  137971. /** @hidden (Backing field) */
  137972. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137973. /**
  137974. * Gets or Sets the current geometry buffer associated to the scene.
  137975. */
  137976. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137977. /**
  137978. * Enables a GeometryBufferRender and associates it with the scene
  137979. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137980. * @returns the GeometryBufferRenderer
  137981. */
  137982. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137983. /**
  137984. * Disables the GeometryBufferRender associated with the scene
  137985. */
  137986. disableGeometryBufferRenderer(): void;
  137987. }
  137988. /**
  137989. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137990. * in several rendering techniques.
  137991. */
  137992. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137993. /**
  137994. * The component name helpful to identify the component in the list of scene components.
  137995. */
  137996. readonly name: string;
  137997. /**
  137998. * The scene the component belongs to.
  137999. */
  138000. scene: Scene;
  138001. /**
  138002. * Creates a new instance of the component for the given scene
  138003. * @param scene Defines the scene to register the component in
  138004. */
  138005. constructor(scene: Scene);
  138006. /**
  138007. * Registers the component in a given scene
  138008. */
  138009. register(): void;
  138010. /**
  138011. * Rebuilds the elements related to this component in case of
  138012. * context lost for instance.
  138013. */
  138014. rebuild(): void;
  138015. /**
  138016. * Disposes the component and the associated ressources
  138017. */
  138018. dispose(): void;
  138019. private _gatherRenderTargets;
  138020. }
  138021. }
  138022. declare module BABYLON {
  138023. /** @hidden */
  138024. export var motionBlurPixelShader: {
  138025. name: string;
  138026. shader: string;
  138027. };
  138028. }
  138029. declare module BABYLON {
  138030. /**
  138031. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138032. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138033. * As an example, all you have to do is to create the post-process:
  138034. * var mb = new BABYLON.MotionBlurPostProcess(
  138035. * 'mb', // The name of the effect.
  138036. * scene, // The scene containing the objects to blur according to their velocity.
  138037. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138038. * camera // The camera to apply the render pass to.
  138039. * );
  138040. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138041. */
  138042. export class MotionBlurPostProcess extends PostProcess {
  138043. /**
  138044. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138045. */
  138046. motionStrength: number;
  138047. /**
  138048. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138049. */
  138050. get motionBlurSamples(): number;
  138051. /**
  138052. * Sets the number of iterations to be used for motion blur quality
  138053. */
  138054. set motionBlurSamples(samples: number);
  138055. private _motionBlurSamples;
  138056. private _geometryBufferRenderer;
  138057. /**
  138058. * Creates a new instance MotionBlurPostProcess
  138059. * @param name The name of the effect.
  138060. * @param scene The scene containing the objects to blur according to their velocity.
  138061. * @param options The required width/height ratio to downsize to before computing the render pass.
  138062. * @param camera The camera to apply the render pass to.
  138063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138064. * @param engine The engine which the post process will be applied. (default: current engine)
  138065. * @param reusable If the post process can be reused on the same frame. (default: false)
  138066. * @param textureType Type of textures used when performing the post process. (default: 0)
  138067. * @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)
  138068. */
  138069. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138070. /**
  138071. * Excludes the given skinned mesh from computing bones velocities.
  138072. * 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.
  138073. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138074. */
  138075. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138076. /**
  138077. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138078. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138079. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138080. */
  138081. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138082. /**
  138083. * Disposes the post process.
  138084. * @param camera The camera to dispose the post process on.
  138085. */
  138086. dispose(camera?: Camera): void;
  138087. }
  138088. }
  138089. declare module BABYLON {
  138090. /** @hidden */
  138091. export var refractionPixelShader: {
  138092. name: string;
  138093. shader: string;
  138094. };
  138095. }
  138096. declare module BABYLON {
  138097. /**
  138098. * Post process which applies a refractin texture
  138099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138100. */
  138101. export class RefractionPostProcess extends PostProcess {
  138102. /** the base color of the refraction (used to taint the rendering) */
  138103. color: Color3;
  138104. /** simulated refraction depth */
  138105. depth: number;
  138106. /** the coefficient of the base color (0 to remove base color tainting) */
  138107. colorLevel: number;
  138108. private _refTexture;
  138109. private _ownRefractionTexture;
  138110. /**
  138111. * Gets or sets the refraction texture
  138112. * Please note that you are responsible for disposing the texture if you set it manually
  138113. */
  138114. get refractionTexture(): Texture;
  138115. set refractionTexture(value: Texture);
  138116. /**
  138117. * Initializes the RefractionPostProcess
  138118. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138119. * @param name The name of the effect.
  138120. * @param refractionTextureUrl Url of the refraction texture to use
  138121. * @param color the base color of the refraction (used to taint the rendering)
  138122. * @param depth simulated refraction depth
  138123. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138124. * @param camera The camera to apply the render pass to.
  138125. * @param options The required width/height ratio to downsize to before computing the render pass.
  138126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138127. * @param engine The engine which the post process will be applied. (default: current engine)
  138128. * @param reusable If the post process can be reused on the same frame. (default: false)
  138129. */
  138130. constructor(name: string, refractionTextureUrl: string,
  138131. /** the base color of the refraction (used to taint the rendering) */
  138132. color: Color3,
  138133. /** simulated refraction depth */
  138134. depth: number,
  138135. /** the coefficient of the base color (0 to remove base color tainting) */
  138136. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138137. /**
  138138. * Disposes of the post process
  138139. * @param camera Camera to dispose post process on
  138140. */
  138141. dispose(camera: Camera): void;
  138142. }
  138143. }
  138144. declare module BABYLON {
  138145. /** @hidden */
  138146. export var sharpenPixelShader: {
  138147. name: string;
  138148. shader: string;
  138149. };
  138150. }
  138151. declare module BABYLON {
  138152. /**
  138153. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138154. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138155. */
  138156. export class SharpenPostProcess extends PostProcess {
  138157. /**
  138158. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138159. */
  138160. colorAmount: number;
  138161. /**
  138162. * How much sharpness should be applied (default: 0.3)
  138163. */
  138164. edgeAmount: number;
  138165. /**
  138166. * Creates a new instance ConvolutionPostProcess
  138167. * @param name The name of the effect.
  138168. * @param options The required width/height ratio to downsize to before computing the render pass.
  138169. * @param camera The camera to apply the render pass to.
  138170. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138171. * @param engine The engine which the post process will be applied. (default: current engine)
  138172. * @param reusable If the post process can be reused on the same frame. (default: false)
  138173. * @param textureType Type of textures used when performing the post process. (default: 0)
  138174. * @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)
  138175. */
  138176. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138177. }
  138178. }
  138179. declare module BABYLON {
  138180. /**
  138181. * PostProcessRenderPipeline
  138182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138183. */
  138184. export class PostProcessRenderPipeline {
  138185. private engine;
  138186. private _renderEffects;
  138187. private _renderEffectsForIsolatedPass;
  138188. /**
  138189. * List of inspectable custom properties (used by the Inspector)
  138190. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138191. */
  138192. inspectableCustomProperties: IInspectable[];
  138193. /**
  138194. * @hidden
  138195. */
  138196. protected _cameras: Camera[];
  138197. /** @hidden */
  138198. _name: string;
  138199. /**
  138200. * Gets pipeline name
  138201. */
  138202. get name(): string;
  138203. /** Gets the list of attached cameras */
  138204. get cameras(): Camera[];
  138205. /**
  138206. * Initializes a PostProcessRenderPipeline
  138207. * @param engine engine to add the pipeline to
  138208. * @param name name of the pipeline
  138209. */
  138210. constructor(engine: Engine, name: string);
  138211. /**
  138212. * Gets the class name
  138213. * @returns "PostProcessRenderPipeline"
  138214. */
  138215. getClassName(): string;
  138216. /**
  138217. * If all the render effects in the pipeline are supported
  138218. */
  138219. get isSupported(): boolean;
  138220. /**
  138221. * Adds an effect to the pipeline
  138222. * @param renderEffect the effect to add
  138223. */
  138224. addEffect(renderEffect: PostProcessRenderEffect): void;
  138225. /** @hidden */
  138226. _rebuild(): void;
  138227. /** @hidden */
  138228. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138229. /** @hidden */
  138230. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138231. /** @hidden */
  138232. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138233. /** @hidden */
  138234. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138235. /** @hidden */
  138236. _attachCameras(cameras: Camera, unique: boolean): void;
  138237. /** @hidden */
  138238. _attachCameras(cameras: Camera[], unique: boolean): void;
  138239. /** @hidden */
  138240. _detachCameras(cameras: Camera): void;
  138241. /** @hidden */
  138242. _detachCameras(cameras: Nullable<Camera[]>): void;
  138243. /** @hidden */
  138244. _update(): void;
  138245. /** @hidden */
  138246. _reset(): void;
  138247. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138248. /**
  138249. * Disposes of the pipeline
  138250. */
  138251. dispose(): void;
  138252. }
  138253. }
  138254. declare module BABYLON {
  138255. /**
  138256. * PostProcessRenderPipelineManager class
  138257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138258. */
  138259. export class PostProcessRenderPipelineManager {
  138260. private _renderPipelines;
  138261. /**
  138262. * Initializes a PostProcessRenderPipelineManager
  138263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138264. */
  138265. constructor();
  138266. /**
  138267. * Gets the list of supported render pipelines
  138268. */
  138269. get supportedPipelines(): PostProcessRenderPipeline[];
  138270. /**
  138271. * Adds a pipeline to the manager
  138272. * @param renderPipeline The pipeline to add
  138273. */
  138274. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138275. /**
  138276. * Attaches a camera to the pipeline
  138277. * @param renderPipelineName The name of the pipeline to attach to
  138278. * @param cameras the camera to attach
  138279. * @param unique if the camera can be attached multiple times to the pipeline
  138280. */
  138281. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138282. /**
  138283. * Detaches a camera from the pipeline
  138284. * @param renderPipelineName The name of the pipeline to detach from
  138285. * @param cameras the camera to detach
  138286. */
  138287. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138288. /**
  138289. * Enables an effect by name on a pipeline
  138290. * @param renderPipelineName the name of the pipeline to enable the effect in
  138291. * @param renderEffectName the name of the effect to enable
  138292. * @param cameras the cameras that the effect should be enabled on
  138293. */
  138294. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138295. /**
  138296. * Disables an effect by name on a pipeline
  138297. * @param renderPipelineName the name of the pipeline to disable the effect in
  138298. * @param renderEffectName the name of the effect to disable
  138299. * @param cameras the cameras that the effect should be disabled on
  138300. */
  138301. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138302. /**
  138303. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138304. */
  138305. update(): void;
  138306. /** @hidden */
  138307. _rebuild(): void;
  138308. /**
  138309. * Disposes of the manager and pipelines
  138310. */
  138311. dispose(): void;
  138312. }
  138313. }
  138314. declare module BABYLON {
  138315. interface Scene {
  138316. /** @hidden (Backing field) */
  138317. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138318. /**
  138319. * Gets the postprocess render pipeline manager
  138320. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138321. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138322. */
  138323. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138324. }
  138325. /**
  138326. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138327. */
  138328. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138329. /**
  138330. * The component name helpfull to identify the component in the list of scene components.
  138331. */
  138332. readonly name: string;
  138333. /**
  138334. * The scene the component belongs to.
  138335. */
  138336. scene: Scene;
  138337. /**
  138338. * Creates a new instance of the component for the given scene
  138339. * @param scene Defines the scene to register the component in
  138340. */
  138341. constructor(scene: Scene);
  138342. /**
  138343. * Registers the component in a given scene
  138344. */
  138345. register(): void;
  138346. /**
  138347. * Rebuilds the elements related to this component in case of
  138348. * context lost for instance.
  138349. */
  138350. rebuild(): void;
  138351. /**
  138352. * Disposes the component and the associated ressources
  138353. */
  138354. dispose(): void;
  138355. private _gatherRenderTargets;
  138356. }
  138357. }
  138358. declare module BABYLON {
  138359. /**
  138360. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138361. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138362. */
  138363. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138364. private _scene;
  138365. private _camerasToBeAttached;
  138366. /**
  138367. * ID of the sharpen post process,
  138368. */
  138369. private readonly SharpenPostProcessId;
  138370. /**
  138371. * @ignore
  138372. * ID of the image processing post process;
  138373. */
  138374. readonly ImageProcessingPostProcessId: string;
  138375. /**
  138376. * @ignore
  138377. * ID of the Fast Approximate Anti-Aliasing post process;
  138378. */
  138379. readonly FxaaPostProcessId: string;
  138380. /**
  138381. * ID of the chromatic aberration post process,
  138382. */
  138383. private readonly ChromaticAberrationPostProcessId;
  138384. /**
  138385. * ID of the grain post process
  138386. */
  138387. private readonly GrainPostProcessId;
  138388. /**
  138389. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138390. */
  138391. sharpen: SharpenPostProcess;
  138392. private _sharpenEffect;
  138393. private bloom;
  138394. /**
  138395. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138396. */
  138397. depthOfField: DepthOfFieldEffect;
  138398. /**
  138399. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138400. */
  138401. fxaa: FxaaPostProcess;
  138402. /**
  138403. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138404. */
  138405. imageProcessing: ImageProcessingPostProcess;
  138406. /**
  138407. * Chromatic aberration post process which will shift rgb colors in the image
  138408. */
  138409. chromaticAberration: ChromaticAberrationPostProcess;
  138410. private _chromaticAberrationEffect;
  138411. /**
  138412. * Grain post process which add noise to the image
  138413. */
  138414. grain: GrainPostProcess;
  138415. private _grainEffect;
  138416. /**
  138417. * Glow post process which adds a glow to emissive areas of the image
  138418. */
  138419. private _glowLayer;
  138420. /**
  138421. * Animations which can be used to tweak settings over a period of time
  138422. */
  138423. animations: Animation[];
  138424. private _imageProcessingConfigurationObserver;
  138425. private _sharpenEnabled;
  138426. private _bloomEnabled;
  138427. private _depthOfFieldEnabled;
  138428. private _depthOfFieldBlurLevel;
  138429. private _fxaaEnabled;
  138430. private _imageProcessingEnabled;
  138431. private _defaultPipelineTextureType;
  138432. private _bloomScale;
  138433. private _chromaticAberrationEnabled;
  138434. private _grainEnabled;
  138435. private _buildAllowed;
  138436. /**
  138437. * Gets active scene
  138438. */
  138439. get scene(): Scene;
  138440. /**
  138441. * Enable or disable the sharpen process from the pipeline
  138442. */
  138443. set sharpenEnabled(enabled: boolean);
  138444. get sharpenEnabled(): boolean;
  138445. private _resizeObserver;
  138446. private _hardwareScaleLevel;
  138447. private _bloomKernel;
  138448. /**
  138449. * Specifies the size of the bloom blur kernel, relative to the final output size
  138450. */
  138451. get bloomKernel(): number;
  138452. set bloomKernel(value: number);
  138453. /**
  138454. * Specifies the weight of the bloom in the final rendering
  138455. */
  138456. private _bloomWeight;
  138457. /**
  138458. * Specifies the luma threshold for the area that will be blurred by the bloom
  138459. */
  138460. private _bloomThreshold;
  138461. private _hdr;
  138462. /**
  138463. * The strength of the bloom.
  138464. */
  138465. set bloomWeight(value: number);
  138466. get bloomWeight(): number;
  138467. /**
  138468. * The strength of the bloom.
  138469. */
  138470. set bloomThreshold(value: number);
  138471. get bloomThreshold(): number;
  138472. /**
  138473. * The scale of the bloom, lower value will provide better performance.
  138474. */
  138475. set bloomScale(value: number);
  138476. get bloomScale(): number;
  138477. /**
  138478. * Enable or disable the bloom from the pipeline
  138479. */
  138480. set bloomEnabled(enabled: boolean);
  138481. get bloomEnabled(): boolean;
  138482. private _rebuildBloom;
  138483. /**
  138484. * If the depth of field is enabled.
  138485. */
  138486. get depthOfFieldEnabled(): boolean;
  138487. set depthOfFieldEnabled(enabled: boolean);
  138488. /**
  138489. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138490. */
  138491. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138492. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138493. /**
  138494. * If the anti aliasing is enabled.
  138495. */
  138496. set fxaaEnabled(enabled: boolean);
  138497. get fxaaEnabled(): boolean;
  138498. private _samples;
  138499. /**
  138500. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138501. */
  138502. set samples(sampleCount: number);
  138503. get samples(): number;
  138504. /**
  138505. * If image processing is enabled.
  138506. */
  138507. set imageProcessingEnabled(enabled: boolean);
  138508. get imageProcessingEnabled(): boolean;
  138509. /**
  138510. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138511. */
  138512. set glowLayerEnabled(enabled: boolean);
  138513. get glowLayerEnabled(): boolean;
  138514. /**
  138515. * Gets the glow layer (or null if not defined)
  138516. */
  138517. get glowLayer(): Nullable<GlowLayer>;
  138518. /**
  138519. * Enable or disable the chromaticAberration process from the pipeline
  138520. */
  138521. set chromaticAberrationEnabled(enabled: boolean);
  138522. get chromaticAberrationEnabled(): boolean;
  138523. /**
  138524. * Enable or disable the grain process from the pipeline
  138525. */
  138526. set grainEnabled(enabled: boolean);
  138527. get grainEnabled(): boolean;
  138528. /**
  138529. * @constructor
  138530. * @param name - The rendering pipeline name (default: "")
  138531. * @param hdr - If high dynamic range textures should be used (default: true)
  138532. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138533. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138534. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138535. */
  138536. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138537. /**
  138538. * Get the class name
  138539. * @returns "DefaultRenderingPipeline"
  138540. */
  138541. getClassName(): string;
  138542. /**
  138543. * Force the compilation of the entire pipeline.
  138544. */
  138545. prepare(): void;
  138546. private _hasCleared;
  138547. private _prevPostProcess;
  138548. private _prevPrevPostProcess;
  138549. private _setAutoClearAndTextureSharing;
  138550. private _depthOfFieldSceneObserver;
  138551. private _buildPipeline;
  138552. private _disposePostProcesses;
  138553. /**
  138554. * Adds a camera to the pipeline
  138555. * @param camera the camera to be added
  138556. */
  138557. addCamera(camera: Camera): void;
  138558. /**
  138559. * Removes a camera from the pipeline
  138560. * @param camera the camera to remove
  138561. */
  138562. removeCamera(camera: Camera): void;
  138563. /**
  138564. * Dispose of the pipeline and stop all post processes
  138565. */
  138566. dispose(): void;
  138567. /**
  138568. * Serialize the rendering pipeline (Used when exporting)
  138569. * @returns the serialized object
  138570. */
  138571. serialize(): any;
  138572. /**
  138573. * Parse the serialized pipeline
  138574. * @param source Source pipeline.
  138575. * @param scene The scene to load the pipeline to.
  138576. * @param rootUrl The URL of the serialized pipeline.
  138577. * @returns An instantiated pipeline from the serialized object.
  138578. */
  138579. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138580. }
  138581. }
  138582. declare module BABYLON {
  138583. /** @hidden */
  138584. export var lensHighlightsPixelShader: {
  138585. name: string;
  138586. shader: string;
  138587. };
  138588. }
  138589. declare module BABYLON {
  138590. /** @hidden */
  138591. export var depthOfFieldPixelShader: {
  138592. name: string;
  138593. shader: string;
  138594. };
  138595. }
  138596. declare module BABYLON {
  138597. /**
  138598. * BABYLON.JS Chromatic Aberration GLSL Shader
  138599. * Author: Olivier Guyot
  138600. * Separates very slightly R, G and B colors on the edges of the screen
  138601. * Inspired by Francois Tarlier & Martins Upitis
  138602. */
  138603. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138604. /**
  138605. * @ignore
  138606. * The chromatic aberration PostProcess id in the pipeline
  138607. */
  138608. LensChromaticAberrationEffect: string;
  138609. /**
  138610. * @ignore
  138611. * The highlights enhancing PostProcess id in the pipeline
  138612. */
  138613. HighlightsEnhancingEffect: string;
  138614. /**
  138615. * @ignore
  138616. * The depth-of-field PostProcess id in the pipeline
  138617. */
  138618. LensDepthOfFieldEffect: string;
  138619. private _scene;
  138620. private _depthTexture;
  138621. private _grainTexture;
  138622. private _chromaticAberrationPostProcess;
  138623. private _highlightsPostProcess;
  138624. private _depthOfFieldPostProcess;
  138625. private _edgeBlur;
  138626. private _grainAmount;
  138627. private _chromaticAberration;
  138628. private _distortion;
  138629. private _highlightsGain;
  138630. private _highlightsThreshold;
  138631. private _dofDistance;
  138632. private _dofAperture;
  138633. private _dofDarken;
  138634. private _dofPentagon;
  138635. private _blurNoise;
  138636. /**
  138637. * @constructor
  138638. *
  138639. * Effect parameters are as follow:
  138640. * {
  138641. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138642. * edge_blur: number; // from 0 to x (1 for realism)
  138643. * distortion: number; // from 0 to x (1 for realism)
  138644. * grain_amount: number; // from 0 to 1
  138645. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138646. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138647. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138648. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138649. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138650. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138651. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138652. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138653. * }
  138654. * Note: if an effect parameter is unset, effect is disabled
  138655. *
  138656. * @param name The rendering pipeline name
  138657. * @param parameters - An object containing all parameters (see above)
  138658. * @param scene The scene linked to this pipeline
  138659. * @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)
  138660. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138661. */
  138662. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138663. /**
  138664. * Get the class name
  138665. * @returns "LensRenderingPipeline"
  138666. */
  138667. getClassName(): string;
  138668. /**
  138669. * Gets associated scene
  138670. */
  138671. get scene(): Scene;
  138672. /**
  138673. * Gets or sets the edge blur
  138674. */
  138675. get edgeBlur(): number;
  138676. set edgeBlur(value: number);
  138677. /**
  138678. * Gets or sets the grain amount
  138679. */
  138680. get grainAmount(): number;
  138681. set grainAmount(value: number);
  138682. /**
  138683. * Gets or sets the chromatic aberration amount
  138684. */
  138685. get chromaticAberration(): number;
  138686. set chromaticAberration(value: number);
  138687. /**
  138688. * Gets or sets the depth of field aperture
  138689. */
  138690. get dofAperture(): number;
  138691. set dofAperture(value: number);
  138692. /**
  138693. * Gets or sets the edge distortion
  138694. */
  138695. get edgeDistortion(): number;
  138696. set edgeDistortion(value: number);
  138697. /**
  138698. * Gets or sets the depth of field distortion
  138699. */
  138700. get dofDistortion(): number;
  138701. set dofDistortion(value: number);
  138702. /**
  138703. * Gets or sets the darken out of focus amount
  138704. */
  138705. get darkenOutOfFocus(): number;
  138706. set darkenOutOfFocus(value: number);
  138707. /**
  138708. * Gets or sets a boolean indicating if blur noise is enabled
  138709. */
  138710. get blurNoise(): boolean;
  138711. set blurNoise(value: boolean);
  138712. /**
  138713. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138714. */
  138715. get pentagonBokeh(): boolean;
  138716. set pentagonBokeh(value: boolean);
  138717. /**
  138718. * Gets or sets the highlight grain amount
  138719. */
  138720. get highlightsGain(): number;
  138721. set highlightsGain(value: number);
  138722. /**
  138723. * Gets or sets the highlight threshold
  138724. */
  138725. get highlightsThreshold(): number;
  138726. set highlightsThreshold(value: number);
  138727. /**
  138728. * Sets the amount of blur at the edges
  138729. * @param amount blur amount
  138730. */
  138731. setEdgeBlur(amount: number): void;
  138732. /**
  138733. * Sets edge blur to 0
  138734. */
  138735. disableEdgeBlur(): void;
  138736. /**
  138737. * Sets the amout of grain
  138738. * @param amount Amount of grain
  138739. */
  138740. setGrainAmount(amount: number): void;
  138741. /**
  138742. * Set grain amount to 0
  138743. */
  138744. disableGrain(): void;
  138745. /**
  138746. * Sets the chromatic aberration amount
  138747. * @param amount amount of chromatic aberration
  138748. */
  138749. setChromaticAberration(amount: number): void;
  138750. /**
  138751. * Sets chromatic aberration amount to 0
  138752. */
  138753. disableChromaticAberration(): void;
  138754. /**
  138755. * Sets the EdgeDistortion amount
  138756. * @param amount amount of EdgeDistortion
  138757. */
  138758. setEdgeDistortion(amount: number): void;
  138759. /**
  138760. * Sets edge distortion to 0
  138761. */
  138762. disableEdgeDistortion(): void;
  138763. /**
  138764. * Sets the FocusDistance amount
  138765. * @param amount amount of FocusDistance
  138766. */
  138767. setFocusDistance(amount: number): void;
  138768. /**
  138769. * Disables depth of field
  138770. */
  138771. disableDepthOfField(): void;
  138772. /**
  138773. * Sets the Aperture amount
  138774. * @param amount amount of Aperture
  138775. */
  138776. setAperture(amount: number): void;
  138777. /**
  138778. * Sets the DarkenOutOfFocus amount
  138779. * @param amount amount of DarkenOutOfFocus
  138780. */
  138781. setDarkenOutOfFocus(amount: number): void;
  138782. private _pentagonBokehIsEnabled;
  138783. /**
  138784. * Creates a pentagon bokeh effect
  138785. */
  138786. enablePentagonBokeh(): void;
  138787. /**
  138788. * Disables the pentagon bokeh effect
  138789. */
  138790. disablePentagonBokeh(): void;
  138791. /**
  138792. * Enables noise blur
  138793. */
  138794. enableNoiseBlur(): void;
  138795. /**
  138796. * Disables noise blur
  138797. */
  138798. disableNoiseBlur(): void;
  138799. /**
  138800. * Sets the HighlightsGain amount
  138801. * @param amount amount of HighlightsGain
  138802. */
  138803. setHighlightsGain(amount: number): void;
  138804. /**
  138805. * Sets the HighlightsThreshold amount
  138806. * @param amount amount of HighlightsThreshold
  138807. */
  138808. setHighlightsThreshold(amount: number): void;
  138809. /**
  138810. * Disables highlights
  138811. */
  138812. disableHighlights(): void;
  138813. /**
  138814. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138815. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138816. */
  138817. dispose(disableDepthRender?: boolean): void;
  138818. private _createChromaticAberrationPostProcess;
  138819. private _createHighlightsPostProcess;
  138820. private _createDepthOfFieldPostProcess;
  138821. private _createGrainTexture;
  138822. }
  138823. }
  138824. declare module BABYLON {
  138825. /** @hidden */
  138826. export var ssao2PixelShader: {
  138827. name: string;
  138828. shader: string;
  138829. };
  138830. }
  138831. declare module BABYLON {
  138832. /** @hidden */
  138833. export var ssaoCombinePixelShader: {
  138834. name: string;
  138835. shader: string;
  138836. };
  138837. }
  138838. declare module BABYLON {
  138839. /**
  138840. * Render pipeline to produce ssao effect
  138841. */
  138842. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138843. /**
  138844. * @ignore
  138845. * The PassPostProcess id in the pipeline that contains the original scene color
  138846. */
  138847. SSAOOriginalSceneColorEffect: string;
  138848. /**
  138849. * @ignore
  138850. * The SSAO PostProcess id in the pipeline
  138851. */
  138852. SSAORenderEffect: string;
  138853. /**
  138854. * @ignore
  138855. * The horizontal blur PostProcess id in the pipeline
  138856. */
  138857. SSAOBlurHRenderEffect: string;
  138858. /**
  138859. * @ignore
  138860. * The vertical blur PostProcess id in the pipeline
  138861. */
  138862. SSAOBlurVRenderEffect: string;
  138863. /**
  138864. * @ignore
  138865. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138866. */
  138867. SSAOCombineRenderEffect: string;
  138868. /**
  138869. * The output strength of the SSAO post-process. Default value is 1.0.
  138870. */
  138871. totalStrength: number;
  138872. /**
  138873. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138874. */
  138875. maxZ: number;
  138876. /**
  138877. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138878. */
  138879. minZAspect: number;
  138880. private _samples;
  138881. /**
  138882. * Number of samples used for the SSAO calculations. Default value is 8
  138883. */
  138884. set samples(n: number);
  138885. get samples(): number;
  138886. private _textureSamples;
  138887. /**
  138888. * Number of samples to use for antialiasing
  138889. */
  138890. set textureSamples(n: number);
  138891. get textureSamples(): number;
  138892. /**
  138893. * Ratio object used for SSAO ratio and blur ratio
  138894. */
  138895. private _ratio;
  138896. /**
  138897. * Dynamically generated sphere sampler.
  138898. */
  138899. private _sampleSphere;
  138900. /**
  138901. * Blur filter offsets
  138902. */
  138903. private _samplerOffsets;
  138904. private _expensiveBlur;
  138905. /**
  138906. * If bilateral blur should be used
  138907. */
  138908. set expensiveBlur(b: boolean);
  138909. get expensiveBlur(): boolean;
  138910. /**
  138911. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138912. */
  138913. radius: number;
  138914. /**
  138915. * The base color of the SSAO post-process
  138916. * The final result is "base + ssao" between [0, 1]
  138917. */
  138918. base: number;
  138919. /**
  138920. * Support test.
  138921. */
  138922. static get IsSupported(): boolean;
  138923. private _scene;
  138924. private _depthTexture;
  138925. private _normalTexture;
  138926. private _randomTexture;
  138927. private _originalColorPostProcess;
  138928. private _ssaoPostProcess;
  138929. private _blurHPostProcess;
  138930. private _blurVPostProcess;
  138931. private _ssaoCombinePostProcess;
  138932. /**
  138933. * Gets active scene
  138934. */
  138935. get scene(): Scene;
  138936. /**
  138937. * @constructor
  138938. * @param name The rendering pipeline name
  138939. * @param scene The scene linked to this pipeline
  138940. * @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 }
  138941. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138942. */
  138943. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138944. /**
  138945. * Get the class name
  138946. * @returns "SSAO2RenderingPipeline"
  138947. */
  138948. getClassName(): string;
  138949. /**
  138950. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138951. */
  138952. dispose(disableGeometryBufferRenderer?: boolean): void;
  138953. private _createBlurPostProcess;
  138954. /** @hidden */
  138955. _rebuild(): void;
  138956. private _bits;
  138957. private _radicalInverse_VdC;
  138958. private _hammersley;
  138959. private _hemisphereSample_uniform;
  138960. private _generateHemisphere;
  138961. private _createSSAOPostProcess;
  138962. private _createSSAOCombinePostProcess;
  138963. private _createRandomTexture;
  138964. /**
  138965. * Serialize the rendering pipeline (Used when exporting)
  138966. * @returns the serialized object
  138967. */
  138968. serialize(): any;
  138969. /**
  138970. * Parse the serialized pipeline
  138971. * @param source Source pipeline.
  138972. * @param scene The scene to load the pipeline to.
  138973. * @param rootUrl The URL of the serialized pipeline.
  138974. * @returns An instantiated pipeline from the serialized object.
  138975. */
  138976. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138977. }
  138978. }
  138979. declare module BABYLON {
  138980. /** @hidden */
  138981. export var ssaoPixelShader: {
  138982. name: string;
  138983. shader: string;
  138984. };
  138985. }
  138986. declare module BABYLON {
  138987. /**
  138988. * Render pipeline to produce ssao effect
  138989. */
  138990. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138991. /**
  138992. * @ignore
  138993. * The PassPostProcess id in the pipeline that contains the original scene color
  138994. */
  138995. SSAOOriginalSceneColorEffect: string;
  138996. /**
  138997. * @ignore
  138998. * The SSAO PostProcess id in the pipeline
  138999. */
  139000. SSAORenderEffect: string;
  139001. /**
  139002. * @ignore
  139003. * The horizontal blur PostProcess id in the pipeline
  139004. */
  139005. SSAOBlurHRenderEffect: string;
  139006. /**
  139007. * @ignore
  139008. * The vertical blur PostProcess id in the pipeline
  139009. */
  139010. SSAOBlurVRenderEffect: string;
  139011. /**
  139012. * @ignore
  139013. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139014. */
  139015. SSAOCombineRenderEffect: string;
  139016. /**
  139017. * The output strength of the SSAO post-process. Default value is 1.0.
  139018. */
  139019. totalStrength: number;
  139020. /**
  139021. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139022. */
  139023. radius: number;
  139024. /**
  139025. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139026. * Must not be equal to fallOff and superior to fallOff.
  139027. * Default value is 0.0075
  139028. */
  139029. area: number;
  139030. /**
  139031. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139032. * Must not be equal to area and inferior to area.
  139033. * Default value is 0.000001
  139034. */
  139035. fallOff: number;
  139036. /**
  139037. * The base color of the SSAO post-process
  139038. * The final result is "base + ssao" between [0, 1]
  139039. */
  139040. base: number;
  139041. private _scene;
  139042. private _depthTexture;
  139043. private _randomTexture;
  139044. private _originalColorPostProcess;
  139045. private _ssaoPostProcess;
  139046. private _blurHPostProcess;
  139047. private _blurVPostProcess;
  139048. private _ssaoCombinePostProcess;
  139049. private _firstUpdate;
  139050. /**
  139051. * Gets active scene
  139052. */
  139053. get scene(): Scene;
  139054. /**
  139055. * @constructor
  139056. * @param name - The rendering pipeline name
  139057. * @param scene - The scene linked to this pipeline
  139058. * @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 }
  139059. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139060. */
  139061. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139062. /**
  139063. * Get the class name
  139064. * @returns "SSAORenderingPipeline"
  139065. */
  139066. getClassName(): string;
  139067. /**
  139068. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139069. */
  139070. dispose(disableDepthRender?: boolean): void;
  139071. private _createBlurPostProcess;
  139072. /** @hidden */
  139073. _rebuild(): void;
  139074. private _createSSAOPostProcess;
  139075. private _createSSAOCombinePostProcess;
  139076. private _createRandomTexture;
  139077. }
  139078. }
  139079. declare module BABYLON {
  139080. /** @hidden */
  139081. export var screenSpaceReflectionPixelShader: {
  139082. name: string;
  139083. shader: string;
  139084. };
  139085. }
  139086. declare module BABYLON {
  139087. /**
  139088. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139089. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139090. */
  139091. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139092. /**
  139093. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139094. */
  139095. threshold: number;
  139096. /**
  139097. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139098. */
  139099. strength: number;
  139100. /**
  139101. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139102. */
  139103. reflectionSpecularFalloffExponent: number;
  139104. /**
  139105. * 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]
  139106. */
  139107. step: number;
  139108. /**
  139109. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139110. */
  139111. roughnessFactor: number;
  139112. private _geometryBufferRenderer;
  139113. private _enableSmoothReflections;
  139114. private _reflectionSamples;
  139115. private _smoothSteps;
  139116. /**
  139117. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139118. * @param name The name of the effect.
  139119. * @param scene The scene containing the objects to calculate reflections.
  139120. * @param options The required width/height ratio to downsize to before computing the render pass.
  139121. * @param camera The camera to apply the render pass to.
  139122. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139123. * @param engine The engine which the post process will be applied. (default: current engine)
  139124. * @param reusable If the post process can be reused on the same frame. (default: false)
  139125. * @param textureType Type of textures used when performing the post process. (default: 0)
  139126. * @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)
  139127. */
  139128. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139129. /**
  139130. * Gets wether or not smoothing reflections is enabled.
  139131. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139132. */
  139133. get enableSmoothReflections(): boolean;
  139134. /**
  139135. * Sets wether or not smoothing reflections is enabled.
  139136. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139137. */
  139138. set enableSmoothReflections(enabled: boolean);
  139139. /**
  139140. * Gets the number of samples taken while computing reflections. More samples count is high,
  139141. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139142. */
  139143. get reflectionSamples(): number;
  139144. /**
  139145. * Sets the number of samples taken while computing reflections. More samples count is high,
  139146. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139147. */
  139148. set reflectionSamples(samples: number);
  139149. /**
  139150. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139151. * more the post-process will require GPU power and can generate a drop in FPS.
  139152. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139153. */
  139154. get smoothSteps(): number;
  139155. set smoothSteps(steps: number);
  139156. private _updateEffectDefines;
  139157. }
  139158. }
  139159. declare module BABYLON {
  139160. /** @hidden */
  139161. export var standardPixelShader: {
  139162. name: string;
  139163. shader: string;
  139164. };
  139165. }
  139166. declare module BABYLON {
  139167. /**
  139168. * Standard rendering pipeline
  139169. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139170. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139171. */
  139172. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139173. /**
  139174. * Public members
  139175. */
  139176. /**
  139177. * Post-process which contains the original scene color before the pipeline applies all the effects
  139178. */
  139179. originalPostProcess: Nullable<PostProcess>;
  139180. /**
  139181. * Post-process used to down scale an image x4
  139182. */
  139183. downSampleX4PostProcess: Nullable<PostProcess>;
  139184. /**
  139185. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139186. */
  139187. brightPassPostProcess: Nullable<PostProcess>;
  139188. /**
  139189. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139190. */
  139191. blurHPostProcesses: PostProcess[];
  139192. /**
  139193. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139194. */
  139195. blurVPostProcesses: PostProcess[];
  139196. /**
  139197. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139198. */
  139199. textureAdderPostProcess: Nullable<PostProcess>;
  139200. /**
  139201. * Post-process used to create volumetric lighting effect
  139202. */
  139203. volumetricLightPostProcess: Nullable<PostProcess>;
  139204. /**
  139205. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139206. */
  139207. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139208. /**
  139209. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139210. */
  139211. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139212. /**
  139213. * Post-process used to merge the volumetric light effect and the real scene color
  139214. */
  139215. volumetricLightMergePostProces: Nullable<PostProcess>;
  139216. /**
  139217. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139218. */
  139219. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139220. /**
  139221. * Base post-process used to calculate the average luminance of the final image for HDR
  139222. */
  139223. luminancePostProcess: Nullable<PostProcess>;
  139224. /**
  139225. * Post-processes used to create down sample post-processes in order to get
  139226. * the average luminance of the final image for HDR
  139227. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139228. */
  139229. luminanceDownSamplePostProcesses: PostProcess[];
  139230. /**
  139231. * Post-process used to create a HDR effect (light adaptation)
  139232. */
  139233. hdrPostProcess: Nullable<PostProcess>;
  139234. /**
  139235. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139236. */
  139237. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139238. /**
  139239. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139240. */
  139241. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139242. /**
  139243. * Post-process used to merge the final HDR post-process and the real scene color
  139244. */
  139245. hdrFinalPostProcess: Nullable<PostProcess>;
  139246. /**
  139247. * Post-process used to create a lens flare effect
  139248. */
  139249. lensFlarePostProcess: Nullable<PostProcess>;
  139250. /**
  139251. * Post-process that merges the result of the lens flare post-process and the real scene color
  139252. */
  139253. lensFlareComposePostProcess: Nullable<PostProcess>;
  139254. /**
  139255. * Post-process used to create a motion blur effect
  139256. */
  139257. motionBlurPostProcess: Nullable<PostProcess>;
  139258. /**
  139259. * Post-process used to create a depth of field effect
  139260. */
  139261. depthOfFieldPostProcess: Nullable<PostProcess>;
  139262. /**
  139263. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139264. */
  139265. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139266. /**
  139267. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139268. */
  139269. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139270. /**
  139271. * Represents the brightness threshold in order to configure the illuminated surfaces
  139272. */
  139273. brightThreshold: number;
  139274. /**
  139275. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139276. */
  139277. blurWidth: number;
  139278. /**
  139279. * Sets if the blur for highlighted surfaces must be only horizontal
  139280. */
  139281. horizontalBlur: boolean;
  139282. /**
  139283. * Gets the overall exposure used by the pipeline
  139284. */
  139285. get exposure(): number;
  139286. /**
  139287. * Sets the overall exposure used by the pipeline
  139288. */
  139289. set exposure(value: number);
  139290. /**
  139291. * Texture used typically to simulate "dirty" on camera lens
  139292. */
  139293. lensTexture: Nullable<Texture>;
  139294. /**
  139295. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139296. */
  139297. volumetricLightCoefficient: number;
  139298. /**
  139299. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139300. */
  139301. volumetricLightPower: number;
  139302. /**
  139303. * Used the set the blur intensity to smooth the volumetric lights
  139304. */
  139305. volumetricLightBlurScale: number;
  139306. /**
  139307. * Light (spot or directional) used to generate the volumetric lights rays
  139308. * The source light must have a shadow generate so the pipeline can get its
  139309. * depth map
  139310. */
  139311. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139312. /**
  139313. * For eye adaptation, represents the minimum luminance the eye can see
  139314. */
  139315. hdrMinimumLuminance: number;
  139316. /**
  139317. * For eye adaptation, represents the decrease luminance speed
  139318. */
  139319. hdrDecreaseRate: number;
  139320. /**
  139321. * For eye adaptation, represents the increase luminance speed
  139322. */
  139323. hdrIncreaseRate: number;
  139324. /**
  139325. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139326. */
  139327. get hdrAutoExposure(): boolean;
  139328. /**
  139329. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139330. */
  139331. set hdrAutoExposure(value: boolean);
  139332. /**
  139333. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139334. */
  139335. lensColorTexture: Nullable<Texture>;
  139336. /**
  139337. * The overall strengh for the lens flare effect
  139338. */
  139339. lensFlareStrength: number;
  139340. /**
  139341. * Dispersion coefficient for lens flare ghosts
  139342. */
  139343. lensFlareGhostDispersal: number;
  139344. /**
  139345. * Main lens flare halo width
  139346. */
  139347. lensFlareHaloWidth: number;
  139348. /**
  139349. * Based on the lens distortion effect, defines how much the lens flare result
  139350. * is distorted
  139351. */
  139352. lensFlareDistortionStrength: number;
  139353. /**
  139354. * Configures the blur intensity used for for lens flare (halo)
  139355. */
  139356. lensFlareBlurWidth: number;
  139357. /**
  139358. * Lens star texture must be used to simulate rays on the flares and is available
  139359. * in the documentation
  139360. */
  139361. lensStarTexture: Nullable<Texture>;
  139362. /**
  139363. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139364. * flare effect by taking account of the dirt texture
  139365. */
  139366. lensFlareDirtTexture: Nullable<Texture>;
  139367. /**
  139368. * Represents the focal length for the depth of field effect
  139369. */
  139370. depthOfFieldDistance: number;
  139371. /**
  139372. * Represents the blur intensity for the blurred part of the depth of field effect
  139373. */
  139374. depthOfFieldBlurWidth: number;
  139375. /**
  139376. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139377. */
  139378. get motionStrength(): number;
  139379. /**
  139380. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139381. */
  139382. set motionStrength(strength: number);
  139383. /**
  139384. * Gets wether or not the motion blur post-process is object based or screen based.
  139385. */
  139386. get objectBasedMotionBlur(): boolean;
  139387. /**
  139388. * Sets wether or not the motion blur post-process should be object based or screen based
  139389. */
  139390. set objectBasedMotionBlur(value: boolean);
  139391. /**
  139392. * List of animations for the pipeline (IAnimatable implementation)
  139393. */
  139394. animations: Animation[];
  139395. /**
  139396. * Private members
  139397. */
  139398. private _scene;
  139399. private _currentDepthOfFieldSource;
  139400. private _basePostProcess;
  139401. private _fixedExposure;
  139402. private _currentExposure;
  139403. private _hdrAutoExposure;
  139404. private _hdrCurrentLuminance;
  139405. private _motionStrength;
  139406. private _isObjectBasedMotionBlur;
  139407. private _floatTextureType;
  139408. private _camerasToBeAttached;
  139409. private _ratio;
  139410. private _bloomEnabled;
  139411. private _depthOfFieldEnabled;
  139412. private _vlsEnabled;
  139413. private _lensFlareEnabled;
  139414. private _hdrEnabled;
  139415. private _motionBlurEnabled;
  139416. private _fxaaEnabled;
  139417. private _screenSpaceReflectionsEnabled;
  139418. private _motionBlurSamples;
  139419. private _volumetricLightStepsCount;
  139420. private _samples;
  139421. /**
  139422. * @ignore
  139423. * Specifies if the bloom pipeline is enabled
  139424. */
  139425. get BloomEnabled(): boolean;
  139426. set BloomEnabled(enabled: boolean);
  139427. /**
  139428. * @ignore
  139429. * Specifies if the depth of field pipeline is enabed
  139430. */
  139431. get DepthOfFieldEnabled(): boolean;
  139432. set DepthOfFieldEnabled(enabled: boolean);
  139433. /**
  139434. * @ignore
  139435. * Specifies if the lens flare pipeline is enabed
  139436. */
  139437. get LensFlareEnabled(): boolean;
  139438. set LensFlareEnabled(enabled: boolean);
  139439. /**
  139440. * @ignore
  139441. * Specifies if the HDR pipeline is enabled
  139442. */
  139443. get HDREnabled(): boolean;
  139444. set HDREnabled(enabled: boolean);
  139445. /**
  139446. * @ignore
  139447. * Specifies if the volumetric lights scattering effect is enabled
  139448. */
  139449. get VLSEnabled(): boolean;
  139450. set VLSEnabled(enabled: boolean);
  139451. /**
  139452. * @ignore
  139453. * Specifies if the motion blur effect is enabled
  139454. */
  139455. get MotionBlurEnabled(): boolean;
  139456. set MotionBlurEnabled(enabled: boolean);
  139457. /**
  139458. * Specifies if anti-aliasing is enabled
  139459. */
  139460. get fxaaEnabled(): boolean;
  139461. set fxaaEnabled(enabled: boolean);
  139462. /**
  139463. * Specifies if screen space reflections are enabled.
  139464. */
  139465. get screenSpaceReflectionsEnabled(): boolean;
  139466. set screenSpaceReflectionsEnabled(enabled: boolean);
  139467. /**
  139468. * Specifies the number of steps used to calculate the volumetric lights
  139469. * Typically in interval [50, 200]
  139470. */
  139471. get volumetricLightStepsCount(): number;
  139472. set volumetricLightStepsCount(count: number);
  139473. /**
  139474. * Specifies the number of samples used for the motion blur effect
  139475. * Typically in interval [16, 64]
  139476. */
  139477. get motionBlurSamples(): number;
  139478. set motionBlurSamples(samples: number);
  139479. /**
  139480. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139481. */
  139482. get samples(): number;
  139483. set samples(sampleCount: number);
  139484. /**
  139485. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139486. * @constructor
  139487. * @param name The rendering pipeline name
  139488. * @param scene The scene linked to this pipeline
  139489. * @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)
  139490. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139491. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139492. */
  139493. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139494. private _buildPipeline;
  139495. private _createDownSampleX4PostProcess;
  139496. private _createBrightPassPostProcess;
  139497. private _createBlurPostProcesses;
  139498. private _createTextureAdderPostProcess;
  139499. private _createVolumetricLightPostProcess;
  139500. private _createLuminancePostProcesses;
  139501. private _createHdrPostProcess;
  139502. private _createLensFlarePostProcess;
  139503. private _createDepthOfFieldPostProcess;
  139504. private _createMotionBlurPostProcess;
  139505. private _getDepthTexture;
  139506. private _disposePostProcesses;
  139507. /**
  139508. * Dispose of the pipeline and stop all post processes
  139509. */
  139510. dispose(): void;
  139511. /**
  139512. * Serialize the rendering pipeline (Used when exporting)
  139513. * @returns the serialized object
  139514. */
  139515. serialize(): any;
  139516. /**
  139517. * Parse the serialized pipeline
  139518. * @param source Source pipeline.
  139519. * @param scene The scene to load the pipeline to.
  139520. * @param rootUrl The URL of the serialized pipeline.
  139521. * @returns An instantiated pipeline from the serialized object.
  139522. */
  139523. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139524. /**
  139525. * Luminance steps
  139526. */
  139527. static LuminanceSteps: number;
  139528. }
  139529. }
  139530. declare module BABYLON {
  139531. /** @hidden */
  139532. export var tonemapPixelShader: {
  139533. name: string;
  139534. shader: string;
  139535. };
  139536. }
  139537. declare module BABYLON {
  139538. /** Defines operator used for tonemapping */
  139539. export enum TonemappingOperator {
  139540. /** Hable */
  139541. Hable = 0,
  139542. /** Reinhard */
  139543. Reinhard = 1,
  139544. /** HejiDawson */
  139545. HejiDawson = 2,
  139546. /** Photographic */
  139547. Photographic = 3
  139548. }
  139549. /**
  139550. * Defines a post process to apply tone mapping
  139551. */
  139552. export class TonemapPostProcess extends PostProcess {
  139553. private _operator;
  139554. /** Defines the required exposure adjustement */
  139555. exposureAdjustment: number;
  139556. /**
  139557. * Creates a new TonemapPostProcess
  139558. * @param name defines the name of the postprocess
  139559. * @param _operator defines the operator to use
  139560. * @param exposureAdjustment defines the required exposure adjustement
  139561. * @param camera defines the camera to use (can be null)
  139562. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139563. * @param engine defines the hosting engine (can be ignore if camera is set)
  139564. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139565. */
  139566. constructor(name: string, _operator: TonemappingOperator,
  139567. /** Defines the required exposure adjustement */
  139568. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139569. }
  139570. }
  139571. declare module BABYLON {
  139572. /** @hidden */
  139573. export var volumetricLightScatteringPixelShader: {
  139574. name: string;
  139575. shader: string;
  139576. };
  139577. }
  139578. declare module BABYLON {
  139579. /** @hidden */
  139580. export var volumetricLightScatteringPassVertexShader: {
  139581. name: string;
  139582. shader: string;
  139583. };
  139584. }
  139585. declare module BABYLON {
  139586. /** @hidden */
  139587. export var volumetricLightScatteringPassPixelShader: {
  139588. name: string;
  139589. shader: string;
  139590. };
  139591. }
  139592. declare module BABYLON {
  139593. /**
  139594. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139595. */
  139596. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139597. private _volumetricLightScatteringPass;
  139598. private _volumetricLightScatteringRTT;
  139599. private _viewPort;
  139600. private _screenCoordinates;
  139601. private _cachedDefines;
  139602. /**
  139603. * If not undefined, the mesh position is computed from the attached node position
  139604. */
  139605. attachedNode: {
  139606. position: Vector3;
  139607. };
  139608. /**
  139609. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139610. */
  139611. customMeshPosition: Vector3;
  139612. /**
  139613. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139614. */
  139615. useCustomMeshPosition: boolean;
  139616. /**
  139617. * If the post-process should inverse the light scattering direction
  139618. */
  139619. invert: boolean;
  139620. /**
  139621. * The internal mesh used by the post-process
  139622. */
  139623. mesh: Mesh;
  139624. /**
  139625. * @hidden
  139626. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139627. */
  139628. get useDiffuseColor(): boolean;
  139629. set useDiffuseColor(useDiffuseColor: boolean);
  139630. /**
  139631. * Array containing the excluded meshes not rendered in the internal pass
  139632. */
  139633. excludedMeshes: AbstractMesh[];
  139634. /**
  139635. * Controls the overall intensity of the post-process
  139636. */
  139637. exposure: number;
  139638. /**
  139639. * Dissipates each sample's contribution in range [0, 1]
  139640. */
  139641. decay: number;
  139642. /**
  139643. * Controls the overall intensity of each sample
  139644. */
  139645. weight: number;
  139646. /**
  139647. * Controls the density of each sample
  139648. */
  139649. density: number;
  139650. /**
  139651. * @constructor
  139652. * @param name The post-process name
  139653. * @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)
  139654. * @param camera The camera that the post-process will be attached to
  139655. * @param mesh The mesh used to create the light scattering
  139656. * @param samples The post-process quality, default 100
  139657. * @param samplingModeThe post-process filtering mode
  139658. * @param engine The babylon engine
  139659. * @param reusable If the post-process is reusable
  139660. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139661. */
  139662. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139663. /**
  139664. * Returns the string "VolumetricLightScatteringPostProcess"
  139665. * @returns "VolumetricLightScatteringPostProcess"
  139666. */
  139667. getClassName(): string;
  139668. private _isReady;
  139669. /**
  139670. * Sets the new light position for light scattering effect
  139671. * @param position The new custom light position
  139672. */
  139673. setCustomMeshPosition(position: Vector3): void;
  139674. /**
  139675. * Returns the light position for light scattering effect
  139676. * @return Vector3 The custom light position
  139677. */
  139678. getCustomMeshPosition(): Vector3;
  139679. /**
  139680. * Disposes the internal assets and detaches the post-process from the camera
  139681. */
  139682. dispose(camera: Camera): void;
  139683. /**
  139684. * Returns the render target texture used by the post-process
  139685. * @return the render target texture used by the post-process
  139686. */
  139687. getPass(): RenderTargetTexture;
  139688. private _meshExcluded;
  139689. private _createPass;
  139690. private _updateMeshScreenCoordinates;
  139691. /**
  139692. * Creates a default mesh for the Volumeric Light Scattering post-process
  139693. * @param name The mesh name
  139694. * @param scene The scene where to create the mesh
  139695. * @return the default mesh
  139696. */
  139697. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139698. }
  139699. }
  139700. declare module BABYLON {
  139701. interface Scene {
  139702. /** @hidden (Backing field) */
  139703. _boundingBoxRenderer: BoundingBoxRenderer;
  139704. /** @hidden (Backing field) */
  139705. _forceShowBoundingBoxes: boolean;
  139706. /**
  139707. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139708. */
  139709. forceShowBoundingBoxes: boolean;
  139710. /**
  139711. * Gets the bounding box renderer associated with the scene
  139712. * @returns a BoundingBoxRenderer
  139713. */
  139714. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139715. }
  139716. interface AbstractMesh {
  139717. /** @hidden (Backing field) */
  139718. _showBoundingBox: boolean;
  139719. /**
  139720. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139721. */
  139722. showBoundingBox: boolean;
  139723. }
  139724. /**
  139725. * Component responsible of rendering the bounding box of the meshes in a scene.
  139726. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139727. */
  139728. export class BoundingBoxRenderer implements ISceneComponent {
  139729. /**
  139730. * The component name helpfull to identify the component in the list of scene components.
  139731. */
  139732. readonly name: string;
  139733. /**
  139734. * The scene the component belongs to.
  139735. */
  139736. scene: Scene;
  139737. /**
  139738. * Color of the bounding box lines placed in front of an object
  139739. */
  139740. frontColor: Color3;
  139741. /**
  139742. * Color of the bounding box lines placed behind an object
  139743. */
  139744. backColor: Color3;
  139745. /**
  139746. * Defines if the renderer should show the back lines or not
  139747. */
  139748. showBackLines: boolean;
  139749. /**
  139750. * @hidden
  139751. */
  139752. renderList: SmartArray<BoundingBox>;
  139753. private _colorShader;
  139754. private _vertexBuffers;
  139755. private _indexBuffer;
  139756. private _fillIndexBuffer;
  139757. private _fillIndexData;
  139758. /**
  139759. * Instantiates a new bounding box renderer in a scene.
  139760. * @param scene the scene the renderer renders in
  139761. */
  139762. constructor(scene: Scene);
  139763. /**
  139764. * Registers the component in a given scene
  139765. */
  139766. register(): void;
  139767. private _evaluateSubMesh;
  139768. private _activeMesh;
  139769. private _prepareRessources;
  139770. private _createIndexBuffer;
  139771. /**
  139772. * Rebuilds the elements related to this component in case of
  139773. * context lost for instance.
  139774. */
  139775. rebuild(): void;
  139776. /**
  139777. * @hidden
  139778. */
  139779. reset(): void;
  139780. /**
  139781. * Render the bounding boxes of a specific rendering group
  139782. * @param renderingGroupId defines the rendering group to render
  139783. */
  139784. render(renderingGroupId: number): void;
  139785. /**
  139786. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139787. * @param mesh Define the mesh to render the occlusion bounding box for
  139788. */
  139789. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139790. /**
  139791. * Dispose and release the resources attached to this renderer.
  139792. */
  139793. dispose(): void;
  139794. }
  139795. }
  139796. declare module BABYLON {
  139797. interface Scene {
  139798. /** @hidden (Backing field) */
  139799. _depthRenderer: {
  139800. [id: string]: DepthRenderer;
  139801. };
  139802. /**
  139803. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139804. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139805. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139806. * @returns the created depth renderer
  139807. */
  139808. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139809. /**
  139810. * Disables a depth renderer for a given camera
  139811. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139812. */
  139813. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139814. }
  139815. /**
  139816. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139817. * in several rendering techniques.
  139818. */
  139819. export class DepthRendererSceneComponent implements ISceneComponent {
  139820. /**
  139821. * The component name helpfull to identify the component in the list of scene components.
  139822. */
  139823. readonly name: string;
  139824. /**
  139825. * The scene the component belongs to.
  139826. */
  139827. scene: Scene;
  139828. /**
  139829. * Creates a new instance of the component for the given scene
  139830. * @param scene Defines the scene to register the component in
  139831. */
  139832. constructor(scene: Scene);
  139833. /**
  139834. * Registers the component in a given scene
  139835. */
  139836. register(): void;
  139837. /**
  139838. * Rebuilds the elements related to this component in case of
  139839. * context lost for instance.
  139840. */
  139841. rebuild(): void;
  139842. /**
  139843. * Disposes the component and the associated ressources
  139844. */
  139845. dispose(): void;
  139846. private _gatherRenderTargets;
  139847. private _gatherActiveCameraRenderTargets;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. /** @hidden */
  139852. export var outlinePixelShader: {
  139853. name: string;
  139854. shader: string;
  139855. };
  139856. }
  139857. declare module BABYLON {
  139858. /** @hidden */
  139859. export var outlineVertexShader: {
  139860. name: string;
  139861. shader: string;
  139862. };
  139863. }
  139864. declare module BABYLON {
  139865. interface Scene {
  139866. /** @hidden */
  139867. _outlineRenderer: OutlineRenderer;
  139868. /**
  139869. * Gets the outline renderer associated with the scene
  139870. * @returns a OutlineRenderer
  139871. */
  139872. getOutlineRenderer(): OutlineRenderer;
  139873. }
  139874. interface AbstractMesh {
  139875. /** @hidden (Backing field) */
  139876. _renderOutline: boolean;
  139877. /**
  139878. * Gets or sets a boolean indicating if the outline must be rendered as well
  139879. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139880. */
  139881. renderOutline: boolean;
  139882. /** @hidden (Backing field) */
  139883. _renderOverlay: boolean;
  139884. /**
  139885. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139886. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139887. */
  139888. renderOverlay: boolean;
  139889. }
  139890. /**
  139891. * This class is responsible to draw bothe outline/overlay of meshes.
  139892. * It should not be used directly but through the available method on mesh.
  139893. */
  139894. export class OutlineRenderer implements ISceneComponent {
  139895. /**
  139896. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139897. */
  139898. private static _StencilReference;
  139899. /**
  139900. * The name of the component. Each component must have a unique name.
  139901. */
  139902. name: string;
  139903. /**
  139904. * The scene the component belongs to.
  139905. */
  139906. scene: Scene;
  139907. /**
  139908. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139909. */
  139910. zOffset: number;
  139911. private _engine;
  139912. private _effect;
  139913. private _cachedDefines;
  139914. private _savedDepthWrite;
  139915. /**
  139916. * Instantiates a new outline renderer. (There could be only one per scene).
  139917. * @param scene Defines the scene it belongs to
  139918. */
  139919. constructor(scene: Scene);
  139920. /**
  139921. * Register the component to one instance of a scene.
  139922. */
  139923. register(): void;
  139924. /**
  139925. * Rebuilds the elements related to this component in case of
  139926. * context lost for instance.
  139927. */
  139928. rebuild(): void;
  139929. /**
  139930. * Disposes the component and the associated ressources.
  139931. */
  139932. dispose(): void;
  139933. /**
  139934. * Renders the outline in the canvas.
  139935. * @param subMesh Defines the sumesh to render
  139936. * @param batch Defines the batch of meshes in case of instances
  139937. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139938. */
  139939. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139940. /**
  139941. * Returns whether or not the outline renderer is ready for a given submesh.
  139942. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139943. * @param subMesh Defines the submesh to check readyness for
  139944. * @param useInstances Defines wheter wee are trying to render instances or not
  139945. * @returns true if ready otherwise false
  139946. */
  139947. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139948. private _beforeRenderingMesh;
  139949. private _afterRenderingMesh;
  139950. }
  139951. }
  139952. declare module BABYLON {
  139953. /**
  139954. * Defines the basic options interface of a Sprite Frame Source Size.
  139955. */
  139956. export interface ISpriteJSONSpriteSourceSize {
  139957. /**
  139958. * number of the original width of the Frame
  139959. */
  139960. w: number;
  139961. /**
  139962. * number of the original height of the Frame
  139963. */
  139964. h: number;
  139965. }
  139966. /**
  139967. * Defines the basic options interface of a Sprite Frame Data.
  139968. */
  139969. export interface ISpriteJSONSpriteFrameData {
  139970. /**
  139971. * number of the x offset of the Frame
  139972. */
  139973. x: number;
  139974. /**
  139975. * number of the y offset of the Frame
  139976. */
  139977. y: number;
  139978. /**
  139979. * number of the width of the Frame
  139980. */
  139981. w: number;
  139982. /**
  139983. * number of the height of the Frame
  139984. */
  139985. h: number;
  139986. }
  139987. /**
  139988. * Defines the basic options interface of a JSON Sprite.
  139989. */
  139990. export interface ISpriteJSONSprite {
  139991. /**
  139992. * string name of the Frame
  139993. */
  139994. filename: string;
  139995. /**
  139996. * ISpriteJSONSpriteFrame basic object of the frame data
  139997. */
  139998. frame: ISpriteJSONSpriteFrameData;
  139999. /**
  140000. * boolean to flag is the frame was rotated.
  140001. */
  140002. rotated: boolean;
  140003. /**
  140004. * boolean to flag is the frame was trimmed.
  140005. */
  140006. trimmed: boolean;
  140007. /**
  140008. * ISpriteJSONSpriteFrame basic object of the source data
  140009. */
  140010. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140011. /**
  140012. * ISpriteJSONSpriteFrame basic object of the source data
  140013. */
  140014. sourceSize: ISpriteJSONSpriteSourceSize;
  140015. }
  140016. /**
  140017. * Defines the basic options interface of a JSON atlas.
  140018. */
  140019. export interface ISpriteJSONAtlas {
  140020. /**
  140021. * Array of objects that contain the frame data.
  140022. */
  140023. frames: Array<ISpriteJSONSprite>;
  140024. /**
  140025. * object basic object containing the sprite meta data.
  140026. */
  140027. meta?: object;
  140028. }
  140029. }
  140030. declare module BABYLON {
  140031. /** @hidden */
  140032. export var spriteMapPixelShader: {
  140033. name: string;
  140034. shader: string;
  140035. };
  140036. }
  140037. declare module BABYLON {
  140038. /** @hidden */
  140039. export var spriteMapVertexShader: {
  140040. name: string;
  140041. shader: string;
  140042. };
  140043. }
  140044. declare module BABYLON {
  140045. /**
  140046. * Defines the basic options interface of a SpriteMap
  140047. */
  140048. export interface ISpriteMapOptions {
  140049. /**
  140050. * Vector2 of the number of cells in the grid.
  140051. */
  140052. stageSize?: Vector2;
  140053. /**
  140054. * Vector2 of the size of the output plane in World Units.
  140055. */
  140056. outputSize?: Vector2;
  140057. /**
  140058. * Vector3 of the position of the output plane in World Units.
  140059. */
  140060. outputPosition?: Vector3;
  140061. /**
  140062. * Vector3 of the rotation of the output plane.
  140063. */
  140064. outputRotation?: Vector3;
  140065. /**
  140066. * number of layers that the system will reserve in resources.
  140067. */
  140068. layerCount?: number;
  140069. /**
  140070. * number of max animation frames a single cell will reserve in resources.
  140071. */
  140072. maxAnimationFrames?: number;
  140073. /**
  140074. * number cell index of the base tile when the system compiles.
  140075. */
  140076. baseTile?: number;
  140077. /**
  140078. * boolean flip the sprite after its been repositioned by the framing data.
  140079. */
  140080. flipU?: boolean;
  140081. /**
  140082. * Vector3 scalar of the global RGB values of the SpriteMap.
  140083. */
  140084. colorMultiply?: Vector3;
  140085. }
  140086. /**
  140087. * Defines the IDisposable interface in order to be cleanable from resources.
  140088. */
  140089. export interface ISpriteMap extends IDisposable {
  140090. /**
  140091. * String name of the SpriteMap.
  140092. */
  140093. name: string;
  140094. /**
  140095. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140096. */
  140097. atlasJSON: ISpriteJSONAtlas;
  140098. /**
  140099. * Texture of the SpriteMap.
  140100. */
  140101. spriteSheet: Texture;
  140102. /**
  140103. * The parameters to initialize the SpriteMap with.
  140104. */
  140105. options: ISpriteMapOptions;
  140106. }
  140107. /**
  140108. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140109. */
  140110. export class SpriteMap implements ISpriteMap {
  140111. /** The Name of the spriteMap */
  140112. name: string;
  140113. /** The JSON file with the frame and meta data */
  140114. atlasJSON: ISpriteJSONAtlas;
  140115. /** The systems Sprite Sheet Texture */
  140116. spriteSheet: Texture;
  140117. /** Arguments passed with the Constructor */
  140118. options: ISpriteMapOptions;
  140119. /** Public Sprite Storage array, parsed from atlasJSON */
  140120. sprites: Array<ISpriteJSONSprite>;
  140121. /** Returns the Number of Sprites in the System */
  140122. get spriteCount(): number;
  140123. /** Returns the Position of Output Plane*/
  140124. get position(): Vector3;
  140125. /** Returns the Position of Output Plane*/
  140126. set position(v: Vector3);
  140127. /** Returns the Rotation of Output Plane*/
  140128. get rotation(): Vector3;
  140129. /** Returns the Rotation of Output Plane*/
  140130. set rotation(v: Vector3);
  140131. /** Sets the AnimationMap*/
  140132. get animationMap(): RawTexture;
  140133. /** Sets the AnimationMap*/
  140134. set animationMap(v: RawTexture);
  140135. /** Scene that the SpriteMap was created in */
  140136. private _scene;
  140137. /** Texture Buffer of Float32 that holds tile frame data*/
  140138. private _frameMap;
  140139. /** Texture Buffers of Float32 that holds tileMap data*/
  140140. private _tileMaps;
  140141. /** Texture Buffer of Float32 that holds Animation Data*/
  140142. private _animationMap;
  140143. /** Custom ShaderMaterial Central to the System*/
  140144. private _material;
  140145. /** Custom ShaderMaterial Central to the System*/
  140146. private _output;
  140147. /** Systems Time Ticker*/
  140148. private _time;
  140149. /**
  140150. * Creates a new SpriteMap
  140151. * @param name defines the SpriteMaps Name
  140152. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140153. * @param spriteSheet is the Texture that the Sprites are on.
  140154. * @param options a basic deployment configuration
  140155. * @param scene The Scene that the map is deployed on
  140156. */
  140157. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140158. /**
  140159. * Returns tileID location
  140160. * @returns Vector2 the cell position ID
  140161. */
  140162. getTileID(): Vector2;
  140163. /**
  140164. * Gets the UV location of the mouse over the SpriteMap.
  140165. * @returns Vector2 the UV position of the mouse interaction
  140166. */
  140167. getMousePosition(): Vector2;
  140168. /**
  140169. * Creates the "frame" texture Buffer
  140170. * -------------------------------------
  140171. * Structure of frames
  140172. * "filename": "Falling-Water-2.png",
  140173. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140174. * "rotated": true,
  140175. * "trimmed": true,
  140176. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140177. * "sourceSize": {"w":32,"h":32}
  140178. * @returns RawTexture of the frameMap
  140179. */
  140180. private _createFrameBuffer;
  140181. /**
  140182. * Creates the tileMap texture Buffer
  140183. * @param buffer normally and array of numbers, or a false to generate from scratch
  140184. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140185. * @returns RawTexture of the tileMap
  140186. */
  140187. private _createTileBuffer;
  140188. /**
  140189. * Modifies the data of the tileMaps
  140190. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140191. * @param pos is the iVector2 Coordinates of the Tile
  140192. * @param tile The SpriteIndex of the new Tile
  140193. */
  140194. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140195. /**
  140196. * Creates the animationMap texture Buffer
  140197. * @param buffer normally and array of numbers, or a false to generate from scratch
  140198. * @returns RawTexture of the animationMap
  140199. */
  140200. private _createTileAnimationBuffer;
  140201. /**
  140202. * Modifies the data of the animationMap
  140203. * @param cellID is the Index of the Sprite
  140204. * @param _frame is the target Animation frame
  140205. * @param toCell is the Target Index of the next frame of the animation
  140206. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140207. * @param speed is a global scalar of the time variable on the map.
  140208. */
  140209. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140210. /**
  140211. * Exports the .tilemaps file
  140212. */
  140213. saveTileMaps(): void;
  140214. /**
  140215. * Imports the .tilemaps file
  140216. * @param url of the .tilemaps file
  140217. */
  140218. loadTileMaps(url: string): void;
  140219. /**
  140220. * Release associated resources
  140221. */
  140222. dispose(): void;
  140223. }
  140224. }
  140225. declare module BABYLON {
  140226. /**
  140227. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140228. * @see http://doc.babylonjs.com/babylon101/sprites
  140229. */
  140230. export class SpritePackedManager extends SpriteManager {
  140231. /** defines the packed manager's name */
  140232. name: string;
  140233. /**
  140234. * Creates a new sprite manager from a packed sprite sheet
  140235. * @param name defines the manager's name
  140236. * @param imgUrl defines the sprite sheet url
  140237. * @param capacity defines the maximum allowed number of sprites
  140238. * @param scene defines the hosting scene
  140239. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140240. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140241. * @param samplingMode defines the smapling mode to use with spritesheet
  140242. * @param fromPacked set to true; do not alter
  140243. */
  140244. constructor(
  140245. /** defines the packed manager's name */
  140246. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140247. }
  140248. }
  140249. declare module BABYLON {
  140250. /**
  140251. * Defines the list of states available for a task inside a AssetsManager
  140252. */
  140253. export enum AssetTaskState {
  140254. /**
  140255. * Initialization
  140256. */
  140257. INIT = 0,
  140258. /**
  140259. * Running
  140260. */
  140261. RUNNING = 1,
  140262. /**
  140263. * Done
  140264. */
  140265. DONE = 2,
  140266. /**
  140267. * Error
  140268. */
  140269. ERROR = 3
  140270. }
  140271. /**
  140272. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140273. */
  140274. export abstract class AbstractAssetTask {
  140275. /**
  140276. * Task name
  140277. */ name: string;
  140278. /**
  140279. * Callback called when the task is successful
  140280. */
  140281. onSuccess: (task: any) => void;
  140282. /**
  140283. * Callback called when the task is not successful
  140284. */
  140285. onError: (task: any, message?: string, exception?: any) => void;
  140286. /**
  140287. * Creates a new AssetsManager
  140288. * @param name defines the name of the task
  140289. */
  140290. constructor(
  140291. /**
  140292. * Task name
  140293. */ name: string);
  140294. private _isCompleted;
  140295. private _taskState;
  140296. private _errorObject;
  140297. /**
  140298. * Get if the task is completed
  140299. */
  140300. get isCompleted(): boolean;
  140301. /**
  140302. * Gets the current state of the task
  140303. */
  140304. get taskState(): AssetTaskState;
  140305. /**
  140306. * Gets the current error object (if task is in error)
  140307. */
  140308. get errorObject(): {
  140309. message?: string;
  140310. exception?: any;
  140311. };
  140312. /**
  140313. * Internal only
  140314. * @hidden
  140315. */
  140316. _setErrorObject(message?: string, exception?: any): void;
  140317. /**
  140318. * Execute the current task
  140319. * @param scene defines the scene where you want your assets to be loaded
  140320. * @param onSuccess is a callback called when the task is successfully executed
  140321. * @param onError is a callback called if an error occurs
  140322. */
  140323. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140324. /**
  140325. * Execute the current task
  140326. * @param scene defines the scene where you want your assets to be loaded
  140327. * @param onSuccess is a callback called when the task is successfully executed
  140328. * @param onError is a callback called if an error occurs
  140329. */
  140330. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140331. /**
  140332. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140333. * This can be used with failed tasks that have the reason for failure fixed.
  140334. */
  140335. reset(): void;
  140336. private onErrorCallback;
  140337. private onDoneCallback;
  140338. }
  140339. /**
  140340. * Define the interface used by progress events raised during assets loading
  140341. */
  140342. export interface IAssetsProgressEvent {
  140343. /**
  140344. * Defines the number of remaining tasks to process
  140345. */
  140346. remainingCount: number;
  140347. /**
  140348. * Defines the total number of tasks
  140349. */
  140350. totalCount: number;
  140351. /**
  140352. * Defines the task that was just processed
  140353. */
  140354. task: AbstractAssetTask;
  140355. }
  140356. /**
  140357. * Class used to share progress information about assets loading
  140358. */
  140359. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140360. /**
  140361. * Defines the number of remaining tasks to process
  140362. */
  140363. remainingCount: number;
  140364. /**
  140365. * Defines the total number of tasks
  140366. */
  140367. totalCount: number;
  140368. /**
  140369. * Defines the task that was just processed
  140370. */
  140371. task: AbstractAssetTask;
  140372. /**
  140373. * Creates a AssetsProgressEvent
  140374. * @param remainingCount defines the number of remaining tasks to process
  140375. * @param totalCount defines the total number of tasks
  140376. * @param task defines the task that was just processed
  140377. */
  140378. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140379. }
  140380. /**
  140381. * Define a task used by AssetsManager to load meshes
  140382. */
  140383. export class MeshAssetTask extends AbstractAssetTask {
  140384. /**
  140385. * Defines the name of the task
  140386. */
  140387. name: string;
  140388. /**
  140389. * Defines the list of mesh's names you want to load
  140390. */
  140391. meshesNames: any;
  140392. /**
  140393. * Defines the root url to use as a base to load your meshes and associated resources
  140394. */
  140395. rootUrl: string;
  140396. /**
  140397. * Defines the filename of the scene to load from
  140398. */
  140399. sceneFilename: string;
  140400. /**
  140401. * Gets the list of loaded meshes
  140402. */
  140403. loadedMeshes: Array<AbstractMesh>;
  140404. /**
  140405. * Gets the list of loaded particle systems
  140406. */
  140407. loadedParticleSystems: Array<IParticleSystem>;
  140408. /**
  140409. * Gets the list of loaded skeletons
  140410. */
  140411. loadedSkeletons: Array<Skeleton>;
  140412. /**
  140413. * Gets the list of loaded animation groups
  140414. */
  140415. loadedAnimationGroups: Array<AnimationGroup>;
  140416. /**
  140417. * Callback called when the task is successful
  140418. */
  140419. onSuccess: (task: MeshAssetTask) => void;
  140420. /**
  140421. * Callback called when the task is successful
  140422. */
  140423. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140424. /**
  140425. * Creates a new MeshAssetTask
  140426. * @param name defines the name of the task
  140427. * @param meshesNames defines the list of mesh's names you want to load
  140428. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140429. * @param sceneFilename defines the filename of the scene to load from
  140430. */
  140431. constructor(
  140432. /**
  140433. * Defines the name of the task
  140434. */
  140435. name: string,
  140436. /**
  140437. * Defines the list of mesh's names you want to load
  140438. */
  140439. meshesNames: any,
  140440. /**
  140441. * Defines the root url to use as a base to load your meshes and associated resources
  140442. */
  140443. rootUrl: string,
  140444. /**
  140445. * Defines the filename of the scene to load from
  140446. */
  140447. sceneFilename: string);
  140448. /**
  140449. * Execute the current task
  140450. * @param scene defines the scene where you want your assets to be loaded
  140451. * @param onSuccess is a callback called when the task is successfully executed
  140452. * @param onError is a callback called if an error occurs
  140453. */
  140454. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140455. }
  140456. /**
  140457. * Define a task used by AssetsManager to load text content
  140458. */
  140459. export class TextFileAssetTask extends AbstractAssetTask {
  140460. /**
  140461. * Defines the name of the task
  140462. */
  140463. name: string;
  140464. /**
  140465. * Defines the location of the file to load
  140466. */
  140467. url: string;
  140468. /**
  140469. * Gets the loaded text string
  140470. */
  140471. text: string;
  140472. /**
  140473. * Callback called when the task is successful
  140474. */
  140475. onSuccess: (task: TextFileAssetTask) => void;
  140476. /**
  140477. * Callback called when the task is successful
  140478. */
  140479. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140480. /**
  140481. * Creates a new TextFileAssetTask object
  140482. * @param name defines the name of the task
  140483. * @param url defines the location of the file to load
  140484. */
  140485. constructor(
  140486. /**
  140487. * Defines the name of the task
  140488. */
  140489. name: string,
  140490. /**
  140491. * Defines the location of the file to load
  140492. */
  140493. url: string);
  140494. /**
  140495. * Execute the current task
  140496. * @param scene defines the scene where you want your assets to be loaded
  140497. * @param onSuccess is a callback called when the task is successfully executed
  140498. * @param onError is a callback called if an error occurs
  140499. */
  140500. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140501. }
  140502. /**
  140503. * Define a task used by AssetsManager to load binary data
  140504. */
  140505. export class BinaryFileAssetTask extends AbstractAssetTask {
  140506. /**
  140507. * Defines the name of the task
  140508. */
  140509. name: string;
  140510. /**
  140511. * Defines the location of the file to load
  140512. */
  140513. url: string;
  140514. /**
  140515. * Gets the lodaded data (as an array buffer)
  140516. */
  140517. data: ArrayBuffer;
  140518. /**
  140519. * Callback called when the task is successful
  140520. */
  140521. onSuccess: (task: BinaryFileAssetTask) => void;
  140522. /**
  140523. * Callback called when the task is successful
  140524. */
  140525. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140526. /**
  140527. * Creates a new BinaryFileAssetTask object
  140528. * @param name defines the name of the new task
  140529. * @param url defines the location of the file to load
  140530. */
  140531. constructor(
  140532. /**
  140533. * Defines the name of the task
  140534. */
  140535. name: string,
  140536. /**
  140537. * Defines the location of the file to load
  140538. */
  140539. url: string);
  140540. /**
  140541. * Execute the current task
  140542. * @param scene defines the scene where you want your assets to be loaded
  140543. * @param onSuccess is a callback called when the task is successfully executed
  140544. * @param onError is a callback called if an error occurs
  140545. */
  140546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140547. }
  140548. /**
  140549. * Define a task used by AssetsManager to load images
  140550. */
  140551. export class ImageAssetTask extends AbstractAssetTask {
  140552. /**
  140553. * Defines the name of the task
  140554. */
  140555. name: string;
  140556. /**
  140557. * Defines the location of the image to load
  140558. */
  140559. url: string;
  140560. /**
  140561. * Gets the loaded images
  140562. */
  140563. image: HTMLImageElement;
  140564. /**
  140565. * Callback called when the task is successful
  140566. */
  140567. onSuccess: (task: ImageAssetTask) => void;
  140568. /**
  140569. * Callback called when the task is successful
  140570. */
  140571. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140572. /**
  140573. * Creates a new ImageAssetTask
  140574. * @param name defines the name of the task
  140575. * @param url defines the location of the image to load
  140576. */
  140577. constructor(
  140578. /**
  140579. * Defines the name of the task
  140580. */
  140581. name: string,
  140582. /**
  140583. * Defines the location of the image to load
  140584. */
  140585. url: string);
  140586. /**
  140587. * Execute the current task
  140588. * @param scene defines the scene where you want your assets to be loaded
  140589. * @param onSuccess is a callback called when the task is successfully executed
  140590. * @param onError is a callback called if an error occurs
  140591. */
  140592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140593. }
  140594. /**
  140595. * Defines the interface used by texture loading tasks
  140596. */
  140597. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140598. /**
  140599. * Gets the loaded texture
  140600. */
  140601. texture: TEX;
  140602. }
  140603. /**
  140604. * Define a task used by AssetsManager to load 2D textures
  140605. */
  140606. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140607. /**
  140608. * Defines the name of the task
  140609. */
  140610. name: string;
  140611. /**
  140612. * Defines the location of the file to load
  140613. */
  140614. url: string;
  140615. /**
  140616. * Defines if mipmap should not be generated (default is false)
  140617. */
  140618. noMipmap?: boolean | undefined;
  140619. /**
  140620. * Defines if texture must be inverted on Y axis (default is false)
  140621. */
  140622. invertY?: boolean | undefined;
  140623. /**
  140624. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140625. */
  140626. samplingMode: number;
  140627. /**
  140628. * Gets the loaded texture
  140629. */
  140630. texture: Texture;
  140631. /**
  140632. * Callback called when the task is successful
  140633. */
  140634. onSuccess: (task: TextureAssetTask) => void;
  140635. /**
  140636. * Callback called when the task is successful
  140637. */
  140638. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140639. /**
  140640. * Creates a new TextureAssetTask object
  140641. * @param name defines the name of the task
  140642. * @param url defines the location of the file to load
  140643. * @param noMipmap defines if mipmap should not be generated (default is false)
  140644. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140645. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140646. */
  140647. constructor(
  140648. /**
  140649. * Defines the name of the task
  140650. */
  140651. name: string,
  140652. /**
  140653. * Defines the location of the file to load
  140654. */
  140655. url: string,
  140656. /**
  140657. * Defines if mipmap should not be generated (default is false)
  140658. */
  140659. noMipmap?: boolean | undefined,
  140660. /**
  140661. * Defines if texture must be inverted on Y axis (default is false)
  140662. */
  140663. invertY?: boolean | undefined,
  140664. /**
  140665. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140666. */
  140667. samplingMode?: number);
  140668. /**
  140669. * Execute the current task
  140670. * @param scene defines the scene where you want your assets to be loaded
  140671. * @param onSuccess is a callback called when the task is successfully executed
  140672. * @param onError is a callback called if an error occurs
  140673. */
  140674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140675. }
  140676. /**
  140677. * Define a task used by AssetsManager to load cube textures
  140678. */
  140679. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140680. /**
  140681. * Defines the name of the task
  140682. */
  140683. name: string;
  140684. /**
  140685. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140686. */
  140687. url: string;
  140688. /**
  140689. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140690. */
  140691. extensions?: string[] | undefined;
  140692. /**
  140693. * Defines if mipmaps should not be generated (default is false)
  140694. */
  140695. noMipmap?: boolean | undefined;
  140696. /**
  140697. * Defines the explicit list of files (undefined by default)
  140698. */
  140699. files?: string[] | undefined;
  140700. /**
  140701. * Gets the loaded texture
  140702. */
  140703. texture: CubeTexture;
  140704. /**
  140705. * Callback called when the task is successful
  140706. */
  140707. onSuccess: (task: CubeTextureAssetTask) => void;
  140708. /**
  140709. * Callback called when the task is successful
  140710. */
  140711. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140712. /**
  140713. * Creates a new CubeTextureAssetTask
  140714. * @param name defines the name of the task
  140715. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140716. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140717. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140718. * @param files defines the explicit list of files (undefined by default)
  140719. */
  140720. constructor(
  140721. /**
  140722. * Defines the name of the task
  140723. */
  140724. name: string,
  140725. /**
  140726. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140727. */
  140728. url: string,
  140729. /**
  140730. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140731. */
  140732. extensions?: string[] | undefined,
  140733. /**
  140734. * Defines if mipmaps should not be generated (default is false)
  140735. */
  140736. noMipmap?: boolean | undefined,
  140737. /**
  140738. * Defines the explicit list of files (undefined by default)
  140739. */
  140740. files?: string[] | undefined);
  140741. /**
  140742. * Execute the current task
  140743. * @param scene defines the scene where you want your assets to be loaded
  140744. * @param onSuccess is a callback called when the task is successfully executed
  140745. * @param onError is a callback called if an error occurs
  140746. */
  140747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140748. }
  140749. /**
  140750. * Define a task used by AssetsManager to load HDR cube textures
  140751. */
  140752. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140753. /**
  140754. * Defines the name of the task
  140755. */
  140756. name: string;
  140757. /**
  140758. * Defines the location of the file to load
  140759. */
  140760. url: string;
  140761. /**
  140762. * Defines the desired size (the more it increases the longer the generation will be)
  140763. */
  140764. size: number;
  140765. /**
  140766. * Defines if mipmaps should not be generated (default is false)
  140767. */
  140768. noMipmap: boolean;
  140769. /**
  140770. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140771. */
  140772. generateHarmonics: boolean;
  140773. /**
  140774. * 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)
  140775. */
  140776. gammaSpace: boolean;
  140777. /**
  140778. * Internal Use Only
  140779. */
  140780. reserved: boolean;
  140781. /**
  140782. * Gets the loaded texture
  140783. */
  140784. texture: HDRCubeTexture;
  140785. /**
  140786. * Callback called when the task is successful
  140787. */
  140788. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140789. /**
  140790. * Callback called when the task is successful
  140791. */
  140792. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140793. /**
  140794. * Creates a new HDRCubeTextureAssetTask object
  140795. * @param name defines the name of the task
  140796. * @param url defines the location of the file to load
  140797. * @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.
  140798. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140799. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140800. * @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)
  140801. * @param reserved Internal use only
  140802. */
  140803. constructor(
  140804. /**
  140805. * Defines the name of the task
  140806. */
  140807. name: string,
  140808. /**
  140809. * Defines the location of the file to load
  140810. */
  140811. url: string,
  140812. /**
  140813. * Defines the desired size (the more it increases the longer the generation will be)
  140814. */
  140815. size: number,
  140816. /**
  140817. * Defines if mipmaps should not be generated (default is false)
  140818. */
  140819. noMipmap?: boolean,
  140820. /**
  140821. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140822. */
  140823. generateHarmonics?: boolean,
  140824. /**
  140825. * 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)
  140826. */
  140827. gammaSpace?: boolean,
  140828. /**
  140829. * Internal Use Only
  140830. */
  140831. reserved?: boolean);
  140832. /**
  140833. * Execute the current task
  140834. * @param scene defines the scene where you want your assets to be loaded
  140835. * @param onSuccess is a callback called when the task is successfully executed
  140836. * @param onError is a callback called if an error occurs
  140837. */
  140838. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140839. }
  140840. /**
  140841. * Define a task used by AssetsManager to load Equirectangular cube textures
  140842. */
  140843. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140844. /**
  140845. * Defines the name of the task
  140846. */
  140847. name: string;
  140848. /**
  140849. * Defines the location of the file to load
  140850. */
  140851. url: string;
  140852. /**
  140853. * Defines the desired size (the more it increases the longer the generation will be)
  140854. */
  140855. size: number;
  140856. /**
  140857. * Defines if mipmaps should not be generated (default is false)
  140858. */
  140859. noMipmap: boolean;
  140860. /**
  140861. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140862. * but the standard material would require them in Gamma space) (default is true)
  140863. */
  140864. gammaSpace: boolean;
  140865. /**
  140866. * Gets the loaded texture
  140867. */
  140868. texture: EquiRectangularCubeTexture;
  140869. /**
  140870. * Callback called when the task is successful
  140871. */
  140872. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140873. /**
  140874. * Callback called when the task is successful
  140875. */
  140876. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140877. /**
  140878. * Creates a new EquiRectangularCubeTextureAssetTask object
  140879. * @param name defines the name of the task
  140880. * @param url defines the location of the file to load
  140881. * @param size defines the desired size (the more it increases the longer the generation will be)
  140882. * If the size is omitted this implies you are using a preprocessed cubemap.
  140883. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140884. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140885. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140886. * (default is true)
  140887. */
  140888. constructor(
  140889. /**
  140890. * Defines the name of the task
  140891. */
  140892. name: string,
  140893. /**
  140894. * Defines the location of the file to load
  140895. */
  140896. url: string,
  140897. /**
  140898. * Defines the desired size (the more it increases the longer the generation will be)
  140899. */
  140900. size: number,
  140901. /**
  140902. * Defines if mipmaps should not be generated (default is false)
  140903. */
  140904. noMipmap?: boolean,
  140905. /**
  140906. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140907. * but the standard material would require them in Gamma space) (default is true)
  140908. */
  140909. gammaSpace?: boolean);
  140910. /**
  140911. * Execute the current task
  140912. * @param scene defines the scene where you want your assets to be loaded
  140913. * @param onSuccess is a callback called when the task is successfully executed
  140914. * @param onError is a callback called if an error occurs
  140915. */
  140916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140917. }
  140918. /**
  140919. * This class can be used to easily import assets into a scene
  140920. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140921. */
  140922. export class AssetsManager {
  140923. private _scene;
  140924. private _isLoading;
  140925. protected _tasks: AbstractAssetTask[];
  140926. protected _waitingTasksCount: number;
  140927. protected _totalTasksCount: number;
  140928. /**
  140929. * Callback called when all tasks are processed
  140930. */
  140931. onFinish: (tasks: AbstractAssetTask[]) => void;
  140932. /**
  140933. * Callback called when a task is successful
  140934. */
  140935. onTaskSuccess: (task: AbstractAssetTask) => void;
  140936. /**
  140937. * Callback called when a task had an error
  140938. */
  140939. onTaskError: (task: AbstractAssetTask) => void;
  140940. /**
  140941. * Callback called when a task is done (whatever the result is)
  140942. */
  140943. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140944. /**
  140945. * Observable called when all tasks are processed
  140946. */
  140947. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140948. /**
  140949. * Observable called when a task had an error
  140950. */
  140951. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140952. /**
  140953. * Observable called when all tasks were executed
  140954. */
  140955. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140956. /**
  140957. * Observable called when a task is done (whatever the result is)
  140958. */
  140959. onProgressObservable: Observable<IAssetsProgressEvent>;
  140960. /**
  140961. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140962. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140963. */
  140964. useDefaultLoadingScreen: boolean;
  140965. /**
  140966. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140967. * when all assets have been downloaded.
  140968. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140969. */
  140970. autoHideLoadingUI: boolean;
  140971. /**
  140972. * Creates a new AssetsManager
  140973. * @param scene defines the scene to work on
  140974. */
  140975. constructor(scene: Scene);
  140976. /**
  140977. * Add a MeshAssetTask to the list of active tasks
  140978. * @param taskName defines the name of the new task
  140979. * @param meshesNames defines the name of meshes to load
  140980. * @param rootUrl defines the root url to use to locate files
  140981. * @param sceneFilename defines the filename of the scene file
  140982. * @returns a new MeshAssetTask object
  140983. */
  140984. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140985. /**
  140986. * Add a TextFileAssetTask to the list of active tasks
  140987. * @param taskName defines the name of the new task
  140988. * @param url defines the url of the file to load
  140989. * @returns a new TextFileAssetTask object
  140990. */
  140991. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140992. /**
  140993. * Add a BinaryFileAssetTask to the list of active tasks
  140994. * @param taskName defines the name of the new task
  140995. * @param url defines the url of the file to load
  140996. * @returns a new BinaryFileAssetTask object
  140997. */
  140998. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140999. /**
  141000. * Add a ImageAssetTask to the list of active tasks
  141001. * @param taskName defines the name of the new task
  141002. * @param url defines the url of the file to load
  141003. * @returns a new ImageAssetTask object
  141004. */
  141005. addImageTask(taskName: string, url: string): ImageAssetTask;
  141006. /**
  141007. * Add a TextureAssetTask to the list of active tasks
  141008. * @param taskName defines the name of the new task
  141009. * @param url defines the url of the file to load
  141010. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141011. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141012. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141013. * @returns a new TextureAssetTask object
  141014. */
  141015. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141016. /**
  141017. * Add a CubeTextureAssetTask to the list of active tasks
  141018. * @param taskName defines the name of the new task
  141019. * @param url defines the url of the file to load
  141020. * @param extensions defines the extension to use to load the cube map (can be null)
  141021. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141022. * @param files defines the list of files to load (can be null)
  141023. * @returns a new CubeTextureAssetTask object
  141024. */
  141025. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141026. /**
  141027. *
  141028. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141029. * @param taskName defines the name of the new task
  141030. * @param url defines the url of the file to load
  141031. * @param size defines the size you want for the cubemap (can be null)
  141032. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141033. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141034. * @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)
  141035. * @param reserved Internal use only
  141036. * @returns a new HDRCubeTextureAssetTask object
  141037. */
  141038. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141039. /**
  141040. *
  141041. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141042. * @param taskName defines the name of the new task
  141043. * @param url defines the url of the file to load
  141044. * @param size defines the size you want for the cubemap (can be null)
  141045. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141046. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141047. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141048. * @returns a new EquiRectangularCubeTextureAssetTask object
  141049. */
  141050. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141051. /**
  141052. * Remove a task from the assets manager.
  141053. * @param task the task to remove
  141054. */
  141055. removeTask(task: AbstractAssetTask): void;
  141056. private _decreaseWaitingTasksCount;
  141057. private _runTask;
  141058. /**
  141059. * Reset the AssetsManager and remove all tasks
  141060. * @return the current instance of the AssetsManager
  141061. */
  141062. reset(): AssetsManager;
  141063. /**
  141064. * Start the loading process
  141065. * @return the current instance of the AssetsManager
  141066. */
  141067. load(): AssetsManager;
  141068. /**
  141069. * Start the loading process as an async operation
  141070. * @return a promise returning the list of failed tasks
  141071. */
  141072. loadAsync(): Promise<void>;
  141073. }
  141074. }
  141075. declare module BABYLON {
  141076. /**
  141077. * Wrapper class for promise with external resolve and reject.
  141078. */
  141079. export class Deferred<T> {
  141080. /**
  141081. * The promise associated with this deferred object.
  141082. */
  141083. readonly promise: Promise<T>;
  141084. private _resolve;
  141085. private _reject;
  141086. /**
  141087. * The resolve method of the promise associated with this deferred object.
  141088. */
  141089. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141090. /**
  141091. * The reject method of the promise associated with this deferred object.
  141092. */
  141093. get reject(): (reason?: any) => void;
  141094. /**
  141095. * Constructor for this deferred object.
  141096. */
  141097. constructor();
  141098. }
  141099. }
  141100. declare module BABYLON {
  141101. /**
  141102. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141103. */
  141104. export class MeshExploder {
  141105. private _centerMesh;
  141106. private _meshes;
  141107. private _meshesOrigins;
  141108. private _toCenterVectors;
  141109. private _scaledDirection;
  141110. private _newPosition;
  141111. private _centerPosition;
  141112. /**
  141113. * Explodes meshes from a center mesh.
  141114. * @param meshes The meshes to explode.
  141115. * @param centerMesh The mesh to be center of explosion.
  141116. */
  141117. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141118. private _setCenterMesh;
  141119. /**
  141120. * Get class name
  141121. * @returns "MeshExploder"
  141122. */
  141123. getClassName(): string;
  141124. /**
  141125. * "Exploded meshes"
  141126. * @returns Array of meshes with the centerMesh at index 0.
  141127. */
  141128. getMeshes(): Array<Mesh>;
  141129. /**
  141130. * Explodes meshes giving a specific direction
  141131. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141132. */
  141133. explode(direction?: number): void;
  141134. }
  141135. }
  141136. declare module BABYLON {
  141137. /**
  141138. * Class used to help managing file picking and drag'n'drop
  141139. */
  141140. export class FilesInput {
  141141. /**
  141142. * List of files ready to be loaded
  141143. */
  141144. static get FilesToLoad(): {
  141145. [key: string]: File;
  141146. };
  141147. /**
  141148. * Callback called when a file is processed
  141149. */
  141150. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141151. private _engine;
  141152. private _currentScene;
  141153. private _sceneLoadedCallback;
  141154. private _progressCallback;
  141155. private _additionalRenderLoopLogicCallback;
  141156. private _textureLoadingCallback;
  141157. private _startingProcessingFilesCallback;
  141158. private _onReloadCallback;
  141159. private _errorCallback;
  141160. private _elementToMonitor;
  141161. private _sceneFileToLoad;
  141162. private _filesToLoad;
  141163. /**
  141164. * Creates a new FilesInput
  141165. * @param engine defines the rendering engine
  141166. * @param scene defines the hosting scene
  141167. * @param sceneLoadedCallback callback called when scene is loaded
  141168. * @param progressCallback callback called to track progress
  141169. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141170. * @param textureLoadingCallback callback called when a texture is loading
  141171. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141172. * @param onReloadCallback callback called when a reload is requested
  141173. * @param errorCallback callback call if an error occurs
  141174. */
  141175. 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);
  141176. private _dragEnterHandler;
  141177. private _dragOverHandler;
  141178. private _dropHandler;
  141179. /**
  141180. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141181. * @param elementToMonitor defines the DOM element to track
  141182. */
  141183. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141184. /**
  141185. * Release all associated resources
  141186. */
  141187. dispose(): void;
  141188. private renderFunction;
  141189. private drag;
  141190. private drop;
  141191. private _traverseFolder;
  141192. private _processFiles;
  141193. /**
  141194. * Load files from a drop event
  141195. * @param event defines the drop event to use as source
  141196. */
  141197. loadFiles(event: any): void;
  141198. private _processReload;
  141199. /**
  141200. * Reload the current scene from the loaded files
  141201. */
  141202. reload(): void;
  141203. }
  141204. }
  141205. declare module BABYLON {
  141206. /**
  141207. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141209. */
  141210. export class SceneOptimization {
  141211. /**
  141212. * Defines the priority of this optimization (0 by default which means first in the list)
  141213. */
  141214. priority: number;
  141215. /**
  141216. * Gets a string describing the action executed by the current optimization
  141217. * @returns description string
  141218. */
  141219. getDescription(): string;
  141220. /**
  141221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141222. * @param scene defines the current scene where to apply this optimization
  141223. * @param optimizer defines the current optimizer
  141224. * @returns true if everything that can be done was applied
  141225. */
  141226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141227. /**
  141228. * Creates the SceneOptimization object
  141229. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141230. * @param desc defines the description associated with the optimization
  141231. */
  141232. constructor(
  141233. /**
  141234. * Defines the priority of this optimization (0 by default which means first in the list)
  141235. */
  141236. priority?: number);
  141237. }
  141238. /**
  141239. * Defines an optimization used to reduce the size of render target textures
  141240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141241. */
  141242. export class TextureOptimization extends SceneOptimization {
  141243. /**
  141244. * Defines the priority of this optimization (0 by default which means first in the list)
  141245. */
  141246. priority: number;
  141247. /**
  141248. * 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
  141249. */
  141250. maximumSize: number;
  141251. /**
  141252. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141253. */
  141254. step: number;
  141255. /**
  141256. * Gets a string describing the action executed by the current optimization
  141257. * @returns description string
  141258. */
  141259. getDescription(): string;
  141260. /**
  141261. * Creates the TextureOptimization object
  141262. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141263. * @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
  141264. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141265. */
  141266. constructor(
  141267. /**
  141268. * Defines the priority of this optimization (0 by default which means first in the list)
  141269. */
  141270. priority?: number,
  141271. /**
  141272. * 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
  141273. */
  141274. maximumSize?: number,
  141275. /**
  141276. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141277. */
  141278. step?: number);
  141279. /**
  141280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141281. * @param scene defines the current scene where to apply this optimization
  141282. * @param optimizer defines the current optimizer
  141283. * @returns true if everything that can be done was applied
  141284. */
  141285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141286. }
  141287. /**
  141288. * Defines an optimization used to increase or decrease the rendering resolution
  141289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141290. */
  141291. export class HardwareScalingOptimization extends SceneOptimization {
  141292. /**
  141293. * Defines the priority of this optimization (0 by default which means first in the list)
  141294. */
  141295. priority: number;
  141296. /**
  141297. * Defines the maximum scale to use (2 by default)
  141298. */
  141299. maximumScale: number;
  141300. /**
  141301. * Defines the step to use between two passes (0.5 by default)
  141302. */
  141303. step: number;
  141304. private _currentScale;
  141305. private _directionOffset;
  141306. /**
  141307. * Gets a string describing the action executed by the current optimization
  141308. * @return description string
  141309. */
  141310. getDescription(): string;
  141311. /**
  141312. * Creates the HardwareScalingOptimization object
  141313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141314. * @param maximumScale defines the maximum scale to use (2 by default)
  141315. * @param step defines the step to use between two passes (0.5 by default)
  141316. */
  141317. constructor(
  141318. /**
  141319. * Defines the priority of this optimization (0 by default which means first in the list)
  141320. */
  141321. priority?: number,
  141322. /**
  141323. * Defines the maximum scale to use (2 by default)
  141324. */
  141325. maximumScale?: number,
  141326. /**
  141327. * Defines the step to use between two passes (0.5 by default)
  141328. */
  141329. step?: number);
  141330. /**
  141331. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141332. * @param scene defines the current scene where to apply this optimization
  141333. * @param optimizer defines the current optimizer
  141334. * @returns true if everything that can be done was applied
  141335. */
  141336. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141337. }
  141338. /**
  141339. * Defines an optimization used to remove shadows
  141340. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141341. */
  141342. export class ShadowsOptimization extends SceneOptimization {
  141343. /**
  141344. * Gets a string describing the action executed by the current optimization
  141345. * @return description string
  141346. */
  141347. getDescription(): string;
  141348. /**
  141349. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141350. * @param scene defines the current scene where to apply this optimization
  141351. * @param optimizer defines the current optimizer
  141352. * @returns true if everything that can be done was applied
  141353. */
  141354. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141355. }
  141356. /**
  141357. * Defines an optimization used to turn post-processes off
  141358. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141359. */
  141360. export class PostProcessesOptimization extends SceneOptimization {
  141361. /**
  141362. * Gets a string describing the action executed by the current optimization
  141363. * @return description string
  141364. */
  141365. getDescription(): string;
  141366. /**
  141367. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141368. * @param scene defines the current scene where to apply this optimization
  141369. * @param optimizer defines the current optimizer
  141370. * @returns true if everything that can be done was applied
  141371. */
  141372. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141373. }
  141374. /**
  141375. * Defines an optimization used to turn lens flares off
  141376. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141377. */
  141378. export class LensFlaresOptimization extends SceneOptimization {
  141379. /**
  141380. * Gets a string describing the action executed by the current optimization
  141381. * @return description string
  141382. */
  141383. getDescription(): string;
  141384. /**
  141385. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141386. * @param scene defines the current scene where to apply this optimization
  141387. * @param optimizer defines the current optimizer
  141388. * @returns true if everything that can be done was applied
  141389. */
  141390. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141391. }
  141392. /**
  141393. * Defines an optimization based on user defined callback.
  141394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141395. */
  141396. export class CustomOptimization extends SceneOptimization {
  141397. /**
  141398. * Callback called to apply the custom optimization.
  141399. */
  141400. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141401. /**
  141402. * Callback called to get custom description
  141403. */
  141404. onGetDescription: () => string;
  141405. /**
  141406. * Gets a string describing the action executed by the current optimization
  141407. * @returns description string
  141408. */
  141409. getDescription(): string;
  141410. /**
  141411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141412. * @param scene defines the current scene where to apply this optimization
  141413. * @param optimizer defines the current optimizer
  141414. * @returns true if everything that can be done was applied
  141415. */
  141416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141417. }
  141418. /**
  141419. * Defines an optimization used to turn particles off
  141420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141421. */
  141422. export class ParticlesOptimization extends SceneOptimization {
  141423. /**
  141424. * Gets a string describing the action executed by the current optimization
  141425. * @return description string
  141426. */
  141427. getDescription(): string;
  141428. /**
  141429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141430. * @param scene defines the current scene where to apply this optimization
  141431. * @param optimizer defines the current optimizer
  141432. * @returns true if everything that can be done was applied
  141433. */
  141434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141435. }
  141436. /**
  141437. * Defines an optimization used to turn render targets off
  141438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141439. */
  141440. export class RenderTargetsOptimization extends SceneOptimization {
  141441. /**
  141442. * Gets a string describing the action executed by the current optimization
  141443. * @return description string
  141444. */
  141445. getDescription(): string;
  141446. /**
  141447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141448. * @param scene defines the current scene where to apply this optimization
  141449. * @param optimizer defines the current optimizer
  141450. * @returns true if everything that can be done was applied
  141451. */
  141452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141453. }
  141454. /**
  141455. * Defines an optimization used to merge meshes with compatible materials
  141456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141457. */
  141458. export class MergeMeshesOptimization extends SceneOptimization {
  141459. private static _UpdateSelectionTree;
  141460. /**
  141461. * Gets or sets a boolean which defines if optimization octree has to be updated
  141462. */
  141463. static get UpdateSelectionTree(): boolean;
  141464. /**
  141465. * Gets or sets a boolean which defines if optimization octree has to be updated
  141466. */
  141467. static set UpdateSelectionTree(value: boolean);
  141468. /**
  141469. * Gets a string describing the action executed by the current optimization
  141470. * @return description string
  141471. */
  141472. getDescription(): string;
  141473. private _canBeMerged;
  141474. /**
  141475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141476. * @param scene defines the current scene where to apply this optimization
  141477. * @param optimizer defines the current optimizer
  141478. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141479. * @returns true if everything that can be done was applied
  141480. */
  141481. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141482. }
  141483. /**
  141484. * Defines a list of options used by SceneOptimizer
  141485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141486. */
  141487. export class SceneOptimizerOptions {
  141488. /**
  141489. * Defines the target frame rate to reach (60 by default)
  141490. */
  141491. targetFrameRate: number;
  141492. /**
  141493. * Defines the interval between two checkes (2000ms by default)
  141494. */
  141495. trackerDuration: number;
  141496. /**
  141497. * Gets the list of optimizations to apply
  141498. */
  141499. optimizations: SceneOptimization[];
  141500. /**
  141501. * Creates a new list of options used by SceneOptimizer
  141502. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141503. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141504. */
  141505. constructor(
  141506. /**
  141507. * Defines the target frame rate to reach (60 by default)
  141508. */
  141509. targetFrameRate?: number,
  141510. /**
  141511. * Defines the interval between two checkes (2000ms by default)
  141512. */
  141513. trackerDuration?: number);
  141514. /**
  141515. * Add a new optimization
  141516. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141517. * @returns the current SceneOptimizerOptions
  141518. */
  141519. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141520. /**
  141521. * Add a new custom optimization
  141522. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141523. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141524. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141525. * @returns the current SceneOptimizerOptions
  141526. */
  141527. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141528. /**
  141529. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141530. * @param targetFrameRate defines the target frame rate (60 by default)
  141531. * @returns a SceneOptimizerOptions object
  141532. */
  141533. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141534. /**
  141535. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141536. * @param targetFrameRate defines the target frame rate (60 by default)
  141537. * @returns a SceneOptimizerOptions object
  141538. */
  141539. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141540. /**
  141541. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141542. * @param targetFrameRate defines the target frame rate (60 by default)
  141543. * @returns a SceneOptimizerOptions object
  141544. */
  141545. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141546. }
  141547. /**
  141548. * Class used to run optimizations in order to reach a target frame rate
  141549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141550. */
  141551. export class SceneOptimizer implements IDisposable {
  141552. private _isRunning;
  141553. private _options;
  141554. private _scene;
  141555. private _currentPriorityLevel;
  141556. private _targetFrameRate;
  141557. private _trackerDuration;
  141558. private _currentFrameRate;
  141559. private _sceneDisposeObserver;
  141560. private _improvementMode;
  141561. /**
  141562. * Defines an observable called when the optimizer reaches the target frame rate
  141563. */
  141564. onSuccessObservable: Observable<SceneOptimizer>;
  141565. /**
  141566. * Defines an observable called when the optimizer enables an optimization
  141567. */
  141568. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141569. /**
  141570. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141571. */
  141572. onFailureObservable: Observable<SceneOptimizer>;
  141573. /**
  141574. * Gets a boolean indicating if the optimizer is in improvement mode
  141575. */
  141576. get isInImprovementMode(): boolean;
  141577. /**
  141578. * Gets the current priority level (0 at start)
  141579. */
  141580. get currentPriorityLevel(): number;
  141581. /**
  141582. * Gets the current frame rate checked by the SceneOptimizer
  141583. */
  141584. get currentFrameRate(): number;
  141585. /**
  141586. * Gets or sets the current target frame rate (60 by default)
  141587. */
  141588. get targetFrameRate(): number;
  141589. /**
  141590. * Gets or sets the current target frame rate (60 by default)
  141591. */
  141592. set targetFrameRate(value: number);
  141593. /**
  141594. * Gets or sets the current interval between two checks (every 2000ms by default)
  141595. */
  141596. get trackerDuration(): number;
  141597. /**
  141598. * Gets or sets the current interval between two checks (every 2000ms by default)
  141599. */
  141600. set trackerDuration(value: number);
  141601. /**
  141602. * Gets the list of active optimizations
  141603. */
  141604. get optimizations(): SceneOptimization[];
  141605. /**
  141606. * Creates a new SceneOptimizer
  141607. * @param scene defines the scene to work on
  141608. * @param options defines the options to use with the SceneOptimizer
  141609. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141610. * @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)
  141611. */
  141612. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141613. /**
  141614. * Stops the current optimizer
  141615. */
  141616. stop(): void;
  141617. /**
  141618. * Reset the optimizer to initial step (current priority level = 0)
  141619. */
  141620. reset(): void;
  141621. /**
  141622. * Start the optimizer. By default it will try to reach a specific framerate
  141623. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141624. */
  141625. start(): void;
  141626. private _checkCurrentState;
  141627. /**
  141628. * Release all resources
  141629. */
  141630. dispose(): void;
  141631. /**
  141632. * Helper function to create a SceneOptimizer with one single line of code
  141633. * @param scene defines the scene to work on
  141634. * @param options defines the options to use with the SceneOptimizer
  141635. * @param onSuccess defines a callback to call on success
  141636. * @param onFailure defines a callback to call on failure
  141637. * @returns the new SceneOptimizer object
  141638. */
  141639. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141640. }
  141641. }
  141642. declare module BABYLON {
  141643. /**
  141644. * Class used to serialize a scene into a string
  141645. */
  141646. export class SceneSerializer {
  141647. /**
  141648. * Clear cache used by a previous serialization
  141649. */
  141650. static ClearCache(): void;
  141651. /**
  141652. * Serialize a scene into a JSON compatible object
  141653. * @param scene defines the scene to serialize
  141654. * @returns a JSON compatible object
  141655. */
  141656. static Serialize(scene: Scene): any;
  141657. /**
  141658. * Serialize a mesh into a JSON compatible object
  141659. * @param toSerialize defines the mesh to serialize
  141660. * @param withParents defines if parents must be serialized as well
  141661. * @param withChildren defines if children must be serialized as well
  141662. * @returns a JSON compatible object
  141663. */
  141664. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141665. }
  141666. }
  141667. declare module BABYLON {
  141668. /**
  141669. * Class used to host texture specific utilities
  141670. */
  141671. export class TextureTools {
  141672. /**
  141673. * Uses the GPU to create a copy texture rescaled at a given size
  141674. * @param texture Texture to copy from
  141675. * @param width defines the desired width
  141676. * @param height defines the desired height
  141677. * @param useBilinearMode defines if bilinear mode has to be used
  141678. * @return the generated texture
  141679. */
  141680. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141681. }
  141682. }
  141683. declare module BABYLON {
  141684. /**
  141685. * This represents the different options available for the video capture.
  141686. */
  141687. export interface VideoRecorderOptions {
  141688. /** Defines the mime type of the video. */
  141689. mimeType: string;
  141690. /** Defines the FPS the video should be recorded at. */
  141691. fps: number;
  141692. /** Defines the chunk size for the recording data. */
  141693. recordChunckSize: number;
  141694. /** The audio tracks to attach to the recording. */
  141695. audioTracks?: MediaStreamTrack[];
  141696. }
  141697. /**
  141698. * This can help with recording videos from BabylonJS.
  141699. * This is based on the available WebRTC functionalities of the browser.
  141700. *
  141701. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141702. */
  141703. export class VideoRecorder {
  141704. private static readonly _defaultOptions;
  141705. /**
  141706. * Returns whether or not the VideoRecorder is available in your browser.
  141707. * @param engine Defines the Babylon Engine.
  141708. * @returns true if supported otherwise false.
  141709. */
  141710. static IsSupported(engine: Engine): boolean;
  141711. private readonly _options;
  141712. private _canvas;
  141713. private _mediaRecorder;
  141714. private _recordedChunks;
  141715. private _fileName;
  141716. private _resolve;
  141717. private _reject;
  141718. /**
  141719. * True when a recording is already in progress.
  141720. */
  141721. get isRecording(): boolean;
  141722. /**
  141723. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141724. * @param engine Defines the BabylonJS Engine you wish to record.
  141725. * @param options Defines options that can be used to customize the capture.
  141726. */
  141727. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141728. /**
  141729. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141730. */
  141731. stopRecording(): void;
  141732. /**
  141733. * Starts recording the canvas for a max duration specified in parameters.
  141734. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141735. * If null no automatic download will start and you can rely on the promise to get the data back.
  141736. * @param maxDuration Defines the maximum recording time in seconds.
  141737. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141738. * @return A promise callback at the end of the recording with the video data in Blob.
  141739. */
  141740. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141741. /**
  141742. * Releases internal resources used during the recording.
  141743. */
  141744. dispose(): void;
  141745. private _handleDataAvailable;
  141746. private _handleError;
  141747. private _handleStop;
  141748. }
  141749. }
  141750. declare module BABYLON {
  141751. /**
  141752. * Class containing a set of static utilities functions for screenshots
  141753. */
  141754. export class ScreenshotTools {
  141755. /**
  141756. * Captures a screenshot of the current rendering
  141757. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141758. * @param engine defines the rendering engine
  141759. * @param camera defines the source camera
  141760. * @param size This parameter can be set to a single number or to an object with the
  141761. * following (optional) properties: precision, width, height. If a single number is passed,
  141762. * it will be used for both width and height. If an object is passed, the screenshot size
  141763. * will be derived from the parameters. The precision property is a multiplier allowing
  141764. * rendering at a higher or lower resolution
  141765. * @param successCallback defines the callback receives a single parameter which contains the
  141766. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141767. * src parameter of an <img> to display it
  141768. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141769. * Check your browser for supported MIME types
  141770. */
  141771. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141772. /**
  141773. * Captures a screenshot of the current rendering
  141774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141775. * @param engine defines the rendering engine
  141776. * @param camera defines the source camera
  141777. * @param size This parameter can be set to a single number or to an object with the
  141778. * following (optional) properties: precision, width, height. If a single number is passed,
  141779. * it will be used for both width and height. If an object is passed, the screenshot size
  141780. * will be derived from the parameters. The precision property is a multiplier allowing
  141781. * rendering at a higher or lower resolution
  141782. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141783. * Check your browser for supported MIME types
  141784. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141785. * to the src parameter of an <img> to display it
  141786. */
  141787. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141788. /**
  141789. * Generates an image screenshot from the specified camera.
  141790. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141791. * @param engine The engine to use for rendering
  141792. * @param camera The camera to use for rendering
  141793. * @param size This parameter can be set to a single number or to an object with the
  141794. * following (optional) properties: precision, width, height. If a single number is passed,
  141795. * it will be used for both width and height. If an object is passed, the screenshot size
  141796. * will be derived from the parameters. The precision property is a multiplier allowing
  141797. * rendering at a higher or lower resolution
  141798. * @param successCallback The callback receives a single parameter which contains the
  141799. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141800. * src parameter of an <img> to display it
  141801. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141802. * Check your browser for supported MIME types
  141803. * @param samples Texture samples (default: 1)
  141804. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141805. * @param fileName A name for for the downloaded file.
  141806. */
  141807. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  141808. /**
  141809. * Generates an image screenshot from the specified camera.
  141810. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141811. * @param engine The engine to use for rendering
  141812. * @param camera The camera to use for rendering
  141813. * @param size This parameter can be set to a single number or to an object with the
  141814. * following (optional) properties: precision, width, height. If a single number is passed,
  141815. * it will be used for both width and height. If an object is passed, the screenshot size
  141816. * will be derived from the parameters. The precision property is a multiplier allowing
  141817. * rendering at a higher or lower resolution
  141818. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141819. * Check your browser for supported MIME types
  141820. * @param samples Texture samples (default: 1)
  141821. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141822. * @param fileName A name for for the downloaded file.
  141823. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141824. * to the src parameter of an <img> to display it
  141825. */
  141826. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  141827. /**
  141828. * Gets height and width for screenshot size
  141829. * @private
  141830. */
  141831. private static _getScreenshotSize;
  141832. }
  141833. }
  141834. declare module BABYLON {
  141835. /**
  141836. * Interface for a data buffer
  141837. */
  141838. export interface IDataBuffer {
  141839. /**
  141840. * Reads bytes from the data buffer.
  141841. * @param byteOffset The byte offset to read
  141842. * @param byteLength The byte length to read
  141843. * @returns A promise that resolves when the bytes are read
  141844. */
  141845. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141846. /**
  141847. * The byte length of the buffer.
  141848. */
  141849. readonly byteLength: number;
  141850. }
  141851. /**
  141852. * Utility class for reading from a data buffer
  141853. */
  141854. export class DataReader {
  141855. /**
  141856. * The data buffer associated with this data reader.
  141857. */
  141858. readonly buffer: IDataBuffer;
  141859. /**
  141860. * The current byte offset from the beginning of the data buffer.
  141861. */
  141862. byteOffset: number;
  141863. private _dataView;
  141864. private _dataByteOffset;
  141865. /**
  141866. * Constructor
  141867. * @param buffer The buffer to read
  141868. */
  141869. constructor(buffer: IDataBuffer);
  141870. /**
  141871. * Loads the given byte length.
  141872. * @param byteLength The byte length to load
  141873. * @returns A promise that resolves when the load is complete
  141874. */
  141875. loadAsync(byteLength: number): Promise<void>;
  141876. /**
  141877. * Read a unsigned 32-bit integer from the currently loaded data range.
  141878. * @returns The 32-bit integer read
  141879. */
  141880. readUint32(): number;
  141881. /**
  141882. * Read a byte array from the currently loaded data range.
  141883. * @param byteLength The byte length to read
  141884. * @returns The byte array read
  141885. */
  141886. readUint8Array(byteLength: number): Uint8Array;
  141887. /**
  141888. * Read a string from the currently loaded data range.
  141889. * @param byteLength The byte length to read
  141890. * @returns The string read
  141891. */
  141892. readString(byteLength: number): string;
  141893. /**
  141894. * Skips the given byte length the currently loaded data range.
  141895. * @param byteLength The byte length to skip
  141896. */
  141897. skipBytes(byteLength: number): void;
  141898. }
  141899. }
  141900. declare module BABYLON {
  141901. /**
  141902. * Options used for hit testing
  141903. */
  141904. export interface IWebXRHitTestOptions {
  141905. /**
  141906. * Only test when user interacted with the scene. Default - hit test every frame
  141907. */
  141908. testOnPointerDownOnly?: boolean;
  141909. /**
  141910. * The node to use to transform the local results to world coordinates
  141911. */
  141912. worldParentNode?: TransformNode;
  141913. }
  141914. /**
  141915. * Interface defining the babylon result of raycasting/hit-test
  141916. */
  141917. export interface IWebXRHitResult {
  141918. /**
  141919. * The native hit test result
  141920. */
  141921. xrHitResult: XRHitResult;
  141922. /**
  141923. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141924. */
  141925. transformationMatrix: Matrix;
  141926. }
  141927. /**
  141928. * The currently-working hit-test module.
  141929. * Hit test (or raycasting) is used to interact with the real world.
  141930. * For further information read here - https://github.com/immersive-web/hit-test
  141931. */
  141932. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141933. /**
  141934. * options to use when constructing this feature
  141935. */
  141936. readonly options: IWebXRHitTestOptions;
  141937. /**
  141938. * The module's name
  141939. */
  141940. static readonly Name: string;
  141941. /**
  141942. * The (Babylon) version of this module.
  141943. * This is an integer representing the implementation version.
  141944. * This number does not correspond to the webxr specs version
  141945. */
  141946. static readonly Version: number;
  141947. /**
  141948. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141949. * @param event the (select) event to use to select with
  141950. * @param referenceSpace the reference space to use for this hit test
  141951. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141952. */
  141953. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141954. /**
  141955. * execute a hit test with an XR Ray
  141956. *
  141957. * @param xrSession a native xrSession that will execute this hit test
  141958. * @param xrRay the ray (position and direction) to use for raycasting
  141959. * @param referenceSpace native XR reference space to use for the hit-test
  141960. * @param filter filter function that will filter the results
  141961. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141962. */
  141963. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141964. /**
  141965. * Triggered when new babylon (transformed) hit test results are available
  141966. */
  141967. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141968. private _onSelectEnabled;
  141969. /**
  141970. * Creates a new instance of the (legacy version) hit test feature
  141971. * @param _xrSessionManager an instance of WebXRSessionManager
  141972. * @param options options to use when constructing this feature
  141973. */
  141974. constructor(_xrSessionManager: WebXRSessionManager,
  141975. /**
  141976. * options to use when constructing this feature
  141977. */
  141978. options?: IWebXRHitTestOptions);
  141979. /**
  141980. * Populated with the last native XR Hit Results
  141981. */
  141982. lastNativeXRHitResults: XRHitResult[];
  141983. /**
  141984. * attach this feature
  141985. * Will usually be called by the features manager
  141986. *
  141987. * @returns true if successful.
  141988. */
  141989. attach(): boolean;
  141990. /**
  141991. * detach this feature.
  141992. * Will usually be called by the features manager
  141993. *
  141994. * @returns true if successful.
  141995. */
  141996. detach(): boolean;
  141997. private _onHitTestResults;
  141998. private _origin;
  141999. private _direction;
  142000. private _mat;
  142001. protected _onXRFrame(frame: XRFrame): void;
  142002. private _onSelect;
  142003. /**
  142004. * Dispose this feature and all of the resources attached
  142005. */
  142006. dispose(): void;
  142007. }
  142008. }
  142009. declare module BABYLON {
  142010. /**
  142011. * Options used in the plane detector module
  142012. */
  142013. export interface IWebXRPlaneDetectorOptions {
  142014. /**
  142015. * The node to use to transform the local results to world coordinates
  142016. */
  142017. worldParentNode?: TransformNode;
  142018. }
  142019. /**
  142020. * A babylon interface for a webxr plane.
  142021. * A Plane is actually a polygon, built from N points in space
  142022. *
  142023. * Supported in chrome 79, not supported in canary 81 ATM
  142024. */
  142025. export interface IWebXRPlane {
  142026. /**
  142027. * a babylon-assigned ID for this polygon
  142028. */
  142029. id: number;
  142030. /**
  142031. * the native xr-plane object
  142032. */
  142033. xrPlane: XRPlane;
  142034. /**
  142035. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142036. */
  142037. polygonDefinition: Array<Vector3>;
  142038. /**
  142039. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142040. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142041. */
  142042. transformationMatrix: Matrix;
  142043. }
  142044. /**
  142045. * The plane detector is used to detect planes in the real world when in AR
  142046. * For more information see https://github.com/immersive-web/real-world-geometry/
  142047. */
  142048. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142049. private _options;
  142050. /**
  142051. * The module's name
  142052. */
  142053. static readonly Name: string;
  142054. /**
  142055. * The (Babylon) version of this module.
  142056. * This is an integer representing the implementation version.
  142057. * This number does not correspond to the webxr specs version
  142058. */
  142059. static readonly Version: number;
  142060. /**
  142061. * Observers registered here will be executed when a new plane was added to the session
  142062. */
  142063. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142064. /**
  142065. * Observers registered here will be executed when a plane is no longer detected in the session
  142066. */
  142067. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142068. /**
  142069. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142070. * This can execute N times every frame
  142071. */
  142072. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142073. private _enabled;
  142074. private _detectedPlanes;
  142075. private _lastFrameDetected;
  142076. /**
  142077. * construct a new Plane Detector
  142078. * @param _xrSessionManager an instance of xr Session manager
  142079. * @param _options configuration to use when constructing this feature
  142080. */
  142081. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142082. private _init;
  142083. protected _onXRFrame(frame: XRFrame): void;
  142084. /**
  142085. * Dispose this feature and all of the resources attached
  142086. */
  142087. dispose(): void;
  142088. private _updatePlaneWithXRPlane;
  142089. /**
  142090. * avoiding using Array.find for global support.
  142091. * @param xrPlane the plane to find in the array
  142092. */
  142093. private findIndexInPlaneArray;
  142094. }
  142095. }
  142096. declare module BABYLON {
  142097. /**
  142098. * Configuration options of the anchor system
  142099. */
  142100. export interface IWebXRAnchorSystemOptions {
  142101. /**
  142102. * a node that will be used to convert local to world coordinates
  142103. */
  142104. worldParentNode?: TransformNode;
  142105. /**
  142106. * should the anchor system use plane detection.
  142107. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142108. */
  142109. usePlaneDetection?: boolean;
  142110. /**
  142111. * Should a new anchor be added every time a select event is triggered
  142112. */
  142113. addAnchorOnSelect?: boolean;
  142114. }
  142115. /**
  142116. * A babylon container for an XR Anchor
  142117. */
  142118. export interface IWebXRAnchor {
  142119. /**
  142120. * A babylon-assigned ID for this anchor
  142121. */
  142122. id: number;
  142123. /**
  142124. * The native anchor object
  142125. */
  142126. xrAnchor: XRAnchor;
  142127. /**
  142128. * Transformation matrix to apply to an object attached to this anchor
  142129. */
  142130. transformationMatrix: Matrix;
  142131. }
  142132. /**
  142133. * An implementation of the anchor system of WebXR.
  142134. * Note that the current documented implementation is not available in any browser. Future implementations
  142135. * will use the frame to create an anchor and not the session or a detected plane
  142136. * For further information see https://github.com/immersive-web/anchors/
  142137. */
  142138. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142139. private _options;
  142140. /**
  142141. * The module's name
  142142. */
  142143. static readonly Name: string;
  142144. /**
  142145. * The (Babylon) version of this module.
  142146. * This is an integer representing the implementation version.
  142147. * This number does not correspond to the webxr specs version
  142148. */
  142149. static readonly Version: number;
  142150. /**
  142151. * Observers registered here will be executed when a new anchor was added to the session
  142152. */
  142153. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142154. /**
  142155. * Observers registered here will be executed when an existing anchor updates
  142156. * This can execute N times every frame
  142157. */
  142158. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142159. /**
  142160. * Observers registered here will be executed when an anchor was removed from the session
  142161. */
  142162. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142163. private _planeDetector;
  142164. private _hitTestModule;
  142165. private _enabled;
  142166. private _trackedAnchors;
  142167. private _lastFrameDetected;
  142168. /**
  142169. * constructs a new anchor system
  142170. * @param _xrSessionManager an instance of WebXRSessionManager
  142171. * @param _options configuration object for this feature
  142172. */
  142173. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142174. /**
  142175. * set the plane detector to use in order to create anchors from frames
  142176. * @param planeDetector the plane-detector module to use
  142177. * @param enable enable plane-anchors. default is true
  142178. */
  142179. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142180. /**
  142181. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142182. * @param hitTestModule the hit-test module to use.
  142183. */
  142184. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142185. /**
  142186. * attach this feature
  142187. * Will usually be called by the features manager
  142188. *
  142189. * @returns true if successful.
  142190. */
  142191. attach(): boolean;
  142192. /**
  142193. * detach this feature.
  142194. * Will usually be called by the features manager
  142195. *
  142196. * @returns true if successful.
  142197. */
  142198. detach(): boolean;
  142199. /**
  142200. * Dispose this feature and all of the resources attached
  142201. */
  142202. dispose(): void;
  142203. protected _onXRFrame(frame: XRFrame): void;
  142204. private _onSelect;
  142205. /**
  142206. * Add anchor at a specific XR point.
  142207. *
  142208. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142209. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142210. * @returns a promise the fulfills when the anchor was created
  142211. */
  142212. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142213. private _updateAnchorWithXRFrame;
  142214. /**
  142215. * avoiding using Array.find for global support.
  142216. * @param xrAnchor the plane to find in the array
  142217. */
  142218. private _findIndexInAnchorArray;
  142219. }
  142220. }
  142221. declare module BABYLON {
  142222. /**
  142223. * Options interface for the background remover plugin
  142224. */
  142225. export interface IWebXRBackgroundRemoverOptions {
  142226. /**
  142227. * don't disable the environment helper
  142228. */
  142229. ignoreEnvironmentHelper?: boolean;
  142230. /**
  142231. * flags to configure the removal of the environment helper.
  142232. * If not set, the entire background will be removed. If set, flags should be set as well.
  142233. */
  142234. environmentHelperRemovalFlags?: {
  142235. /**
  142236. * Should the skybox be removed (default false)
  142237. */
  142238. skyBox?: boolean;
  142239. /**
  142240. * Should the ground be removed (default false)
  142241. */
  142242. ground?: boolean;
  142243. };
  142244. /**
  142245. * Further background meshes to disable when entering AR
  142246. */
  142247. backgroundMeshes?: AbstractMesh[];
  142248. }
  142249. /**
  142250. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142251. */
  142252. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142253. /**
  142254. * read-only options to be used in this module
  142255. */
  142256. readonly options: IWebXRBackgroundRemoverOptions;
  142257. /**
  142258. * The module's name
  142259. */
  142260. static readonly Name: string;
  142261. /**
  142262. * The (Babylon) version of this module.
  142263. * This is an integer representing the implementation version.
  142264. * This number does not correspond to the webxr specs version
  142265. */
  142266. static readonly Version: number;
  142267. /**
  142268. * registered observers will be triggered when the background state changes
  142269. */
  142270. onBackgroundStateChangedObservable: Observable<boolean>;
  142271. /**
  142272. * constructs a new background remover module
  142273. * @param _xrSessionManager the session manager for this module
  142274. * @param options read-only options to be used in this module
  142275. */
  142276. constructor(_xrSessionManager: WebXRSessionManager,
  142277. /**
  142278. * read-only options to be used in this module
  142279. */
  142280. options?: IWebXRBackgroundRemoverOptions);
  142281. /**
  142282. * attach this feature
  142283. * Will usually be called by the features manager
  142284. *
  142285. * @returns true if successful.
  142286. */
  142287. attach(): boolean;
  142288. /**
  142289. * detach this feature.
  142290. * Will usually be called by the features manager
  142291. *
  142292. * @returns true if successful.
  142293. */
  142294. detach(): boolean;
  142295. private _setBackgroundState;
  142296. /**
  142297. * Dispose this feature and all of the resources attached
  142298. */
  142299. dispose(): void;
  142300. protected _onXRFrame(_xrFrame: XRFrame): void;
  142301. }
  142302. }
  142303. declare module BABYLON {
  142304. /**
  142305. * Options for the controller physics feature
  142306. */
  142307. export class IWebXRControllerPhysicsOptions {
  142308. /**
  142309. * the xr input to use with this pointer selection
  142310. */
  142311. xrInput: WebXRInput;
  142312. /**
  142313. * The physics properties of the future impostors
  142314. */
  142315. physicsProperties?: {
  142316. /**
  142317. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142318. * Note that this requires a physics engine that supports mesh impostors!
  142319. */
  142320. useControllerMesh?: boolean;
  142321. /**
  142322. * The type of impostor to create. Default is sphere
  142323. */
  142324. impostorType?: number;
  142325. /**
  142326. * the size of the impostor. Defaults to 10cm
  142327. */
  142328. impostorSize?: number | {
  142329. width: number;
  142330. height: number;
  142331. depth: number;
  142332. };
  142333. /**
  142334. * Friction definitions
  142335. */
  142336. friction?: number;
  142337. /**
  142338. * Restitution
  142339. */
  142340. restitution?: number;
  142341. };
  142342. /**
  142343. * Should the headset get its own impostor
  142344. */
  142345. enableHeadsetImpostor?: boolean;
  142346. /**
  142347. * Optional parameters for the headset impostor
  142348. */
  142349. headsetImpostorParams?: {
  142350. /**
  142351. * The type of impostor to create. Default is sphere
  142352. */
  142353. impostorType: number;
  142354. /**
  142355. * the size of the impostor. Defaults to 10cm
  142356. */
  142357. impostorSize?: number | {
  142358. width: number;
  142359. height: number;
  142360. depth: number;
  142361. };
  142362. /**
  142363. * Friction definitions
  142364. */
  142365. friction?: number;
  142366. /**
  142367. * Restitution
  142368. */
  142369. restitution?: number;
  142370. };
  142371. }
  142372. /**
  142373. * Add physics impostor to your webxr controllers,
  142374. * including naive calculation of their linear and angular velocity
  142375. */
  142376. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142377. private readonly _options;
  142378. /**
  142379. * The module's name
  142380. */
  142381. static readonly Name: string;
  142382. /**
  142383. * The (Babylon) version of this module.
  142384. * This is an integer representing the implementation version.
  142385. * This number does not correspond to the webxr specs version
  142386. */
  142387. static readonly Version: number;
  142388. private _lastTimestamp;
  142389. private _delta;
  142390. private _controllers;
  142391. private _headsetImpostor?;
  142392. private _headsetMesh?;
  142393. private _tmpVector;
  142394. private _tmpQuaternion;
  142395. /**
  142396. * Construct a new Controller Physics Feature
  142397. * @param _xrSessionManager the corresponding xr session manager
  142398. * @param _options options to create this feature with
  142399. */
  142400. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142401. /**
  142402. * Update the physics properties provided in the constructor
  142403. * @param newProperties the new properties object
  142404. */
  142405. setPhysicsProperties(newProperties: {
  142406. impostorType?: number;
  142407. impostorSize?: number | {
  142408. width: number;
  142409. height: number;
  142410. depth: number;
  142411. };
  142412. friction?: number;
  142413. restitution?: number;
  142414. }): void;
  142415. /**
  142416. * Get the physics impostor of a specific controller.
  142417. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142418. * @param controller the controller or the controller id of which to get the impostor
  142419. * @returns the impostor or null
  142420. */
  142421. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142422. /**
  142423. * Get the headset impostor, if enabled
  142424. * @returns the impostor
  142425. */
  142426. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142427. /**
  142428. * attach this feature
  142429. * Will usually be called by the features manager
  142430. *
  142431. * @returns true if successful.
  142432. */
  142433. attach(): boolean;
  142434. /**
  142435. * detach this feature.
  142436. * Will usually be called by the features manager
  142437. *
  142438. * @returns true if successful.
  142439. */
  142440. detach(): boolean;
  142441. /**
  142442. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142443. * @param xrController the controller to add
  142444. */
  142445. addController(xrController: WebXRInputSource): void;
  142446. private _debugMode;
  142447. /**
  142448. * @hidden
  142449. * enable debugging - will show console outputs and the impostor mesh
  142450. */
  142451. _enablePhysicsDebug(): void;
  142452. private _attachController;
  142453. private _detachController;
  142454. protected _onXRFrame(_xrFrame: any): void;
  142455. }
  142456. }
  142457. declare module BABYLON {
  142458. /**
  142459. * The motion controller class for all microsoft mixed reality controllers
  142460. */
  142461. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142462. /**
  142463. * The base url used to load the left and right controller models
  142464. */
  142465. static MODEL_BASE_URL: string;
  142466. /**
  142467. * The name of the left controller model file
  142468. */
  142469. static MODEL_LEFT_FILENAME: string;
  142470. /**
  142471. * The name of the right controller model file
  142472. */
  142473. static MODEL_RIGHT_FILENAME: string;
  142474. profileId: string;
  142475. protected readonly _mapping: {
  142476. defaultButton: {
  142477. "valueNodeName": string;
  142478. "unpressedNodeName": string;
  142479. "pressedNodeName": string;
  142480. };
  142481. defaultAxis: {
  142482. "valueNodeName": string;
  142483. "minNodeName": string;
  142484. "maxNodeName": string;
  142485. };
  142486. buttons: {
  142487. "xr-standard-trigger": {
  142488. "rootNodeName": string;
  142489. "componentProperty": string;
  142490. "states": string[];
  142491. };
  142492. "xr-standard-squeeze": {
  142493. "rootNodeName": string;
  142494. "componentProperty": string;
  142495. "states": string[];
  142496. };
  142497. "xr-standard-touchpad": {
  142498. "rootNodeName": string;
  142499. "labelAnchorNodeName": string;
  142500. "touchPointNodeName": string;
  142501. };
  142502. "xr-standard-thumbstick": {
  142503. "rootNodeName": string;
  142504. "componentProperty": string;
  142505. "states": string[];
  142506. };
  142507. };
  142508. axes: {
  142509. "xr-standard-touchpad": {
  142510. "x-axis": {
  142511. "rootNodeName": string;
  142512. };
  142513. "y-axis": {
  142514. "rootNodeName": string;
  142515. };
  142516. };
  142517. "xr-standard-thumbstick": {
  142518. "x-axis": {
  142519. "rootNodeName": string;
  142520. };
  142521. "y-axis": {
  142522. "rootNodeName": string;
  142523. };
  142524. };
  142525. };
  142526. };
  142527. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142528. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142529. protected _getFilenameAndPath(): {
  142530. filename: string;
  142531. path: string;
  142532. };
  142533. protected _updateModel(): void;
  142534. protected _getModelLoadingConstraints(): boolean;
  142535. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142536. }
  142537. }
  142538. declare module BABYLON {
  142539. /**
  142540. * The motion controller class for oculus touch (quest, rift).
  142541. * This class supports legacy mapping as well the standard xr mapping
  142542. */
  142543. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142544. private _forceLegacyControllers;
  142545. /**
  142546. * The base url used to load the left and right controller models
  142547. */
  142548. static MODEL_BASE_URL: string;
  142549. /**
  142550. * The name of the left controller model file
  142551. */
  142552. static MODEL_LEFT_FILENAME: string;
  142553. /**
  142554. * The name of the right controller model file
  142555. */
  142556. static MODEL_RIGHT_FILENAME: string;
  142557. /**
  142558. * Base Url for the Quest controller model.
  142559. */
  142560. static QUEST_MODEL_BASE_URL: string;
  142561. profileId: string;
  142562. private _modelRootNode;
  142563. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142564. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142565. protected _getFilenameAndPath(): {
  142566. filename: string;
  142567. path: string;
  142568. };
  142569. /**
  142570. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142571. * between the touch and touch 2.
  142572. */
  142573. private _isQuest;
  142574. protected _updateModel(): void;
  142575. protected _getModelLoadingConstraints(): boolean;
  142576. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142577. }
  142578. }
  142579. declare module BABYLON {
  142580. /**
  142581. * The motion controller class for the standard HTC-Vive controllers
  142582. */
  142583. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142584. /**
  142585. * The base url used to load the left and right controller models
  142586. */
  142587. static MODEL_BASE_URL: string;
  142588. /**
  142589. * File name for the controller model.
  142590. */
  142591. static MODEL_FILENAME: string;
  142592. profileId: string;
  142593. private _modelRootNode;
  142594. /**
  142595. * Create a new Vive motion controller object
  142596. * @param scene the scene to use to create this controller
  142597. * @param gamepadObject the corresponding gamepad object
  142598. * @param handness the handness of the controller
  142599. */
  142600. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142601. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142602. protected _getFilenameAndPath(): {
  142603. filename: string;
  142604. path: string;
  142605. };
  142606. protected _updateModel(): void;
  142607. protected _getModelLoadingConstraints(): boolean;
  142608. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142609. }
  142610. }
  142611. declare module BABYLON {
  142612. /**
  142613. * A cursor which tracks a point on a path
  142614. */
  142615. export class PathCursor {
  142616. private path;
  142617. /**
  142618. * Stores path cursor callbacks for when an onchange event is triggered
  142619. */
  142620. private _onchange;
  142621. /**
  142622. * The value of the path cursor
  142623. */
  142624. value: number;
  142625. /**
  142626. * The animation array of the path cursor
  142627. */
  142628. animations: Animation[];
  142629. /**
  142630. * Initializes the path cursor
  142631. * @param path The path to track
  142632. */
  142633. constructor(path: Path2);
  142634. /**
  142635. * Gets the cursor point on the path
  142636. * @returns A point on the path cursor at the cursor location
  142637. */
  142638. getPoint(): Vector3;
  142639. /**
  142640. * Moves the cursor ahead by the step amount
  142641. * @param step The amount to move the cursor forward
  142642. * @returns This path cursor
  142643. */
  142644. moveAhead(step?: number): PathCursor;
  142645. /**
  142646. * Moves the cursor behind by the step amount
  142647. * @param step The amount to move the cursor back
  142648. * @returns This path cursor
  142649. */
  142650. moveBack(step?: number): PathCursor;
  142651. /**
  142652. * Moves the cursor by the step amount
  142653. * If the step amount is greater than one, an exception is thrown
  142654. * @param step The amount to move the cursor
  142655. * @returns This path cursor
  142656. */
  142657. move(step: number): PathCursor;
  142658. /**
  142659. * Ensures that the value is limited between zero and one
  142660. * @returns This path cursor
  142661. */
  142662. private ensureLimits;
  142663. /**
  142664. * Runs onchange callbacks on change (used by the animation engine)
  142665. * @returns This path cursor
  142666. */
  142667. private raiseOnChange;
  142668. /**
  142669. * Executes a function on change
  142670. * @param f A path cursor onchange callback
  142671. * @returns This path cursor
  142672. */
  142673. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142674. }
  142675. }
  142676. declare module BABYLON {
  142677. /** @hidden */
  142678. export var blurPixelShader: {
  142679. name: string;
  142680. shader: string;
  142681. };
  142682. }
  142683. declare module BABYLON {
  142684. /** @hidden */
  142685. export var pointCloudVertexDeclaration: {
  142686. name: string;
  142687. shader: string;
  142688. };
  142689. }
  142690. // Mixins
  142691. interface Window {
  142692. mozIndexedDB: IDBFactory;
  142693. webkitIndexedDB: IDBFactory;
  142694. msIndexedDB: IDBFactory;
  142695. webkitURL: typeof URL;
  142696. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142697. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142698. WebGLRenderingContext: WebGLRenderingContext;
  142699. MSGesture: MSGesture;
  142700. CANNON: any;
  142701. AudioContext: AudioContext;
  142702. webkitAudioContext: AudioContext;
  142703. PointerEvent: any;
  142704. Math: Math;
  142705. Uint8Array: Uint8ArrayConstructor;
  142706. Float32Array: Float32ArrayConstructor;
  142707. mozURL: typeof URL;
  142708. msURL: typeof URL;
  142709. VRFrameData: any; // WebVR, from specs 1.1
  142710. DracoDecoderModule: any;
  142711. setImmediate(handler: (...args: any[]) => void): number;
  142712. }
  142713. interface HTMLCanvasElement {
  142714. requestPointerLock(): void;
  142715. msRequestPointerLock?(): void;
  142716. mozRequestPointerLock?(): void;
  142717. webkitRequestPointerLock?(): void;
  142718. /** Track wether a record is in progress */
  142719. isRecording: boolean;
  142720. /** Capture Stream method defined by some browsers */
  142721. captureStream(fps?: number): MediaStream;
  142722. }
  142723. interface CanvasRenderingContext2D {
  142724. msImageSmoothingEnabled: boolean;
  142725. }
  142726. interface MouseEvent {
  142727. mozMovementX: number;
  142728. mozMovementY: number;
  142729. webkitMovementX: number;
  142730. webkitMovementY: number;
  142731. msMovementX: number;
  142732. msMovementY: number;
  142733. }
  142734. interface Navigator {
  142735. mozGetVRDevices: (any: any) => any;
  142736. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142737. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142738. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142739. webkitGetGamepads(): Gamepad[];
  142740. msGetGamepads(): Gamepad[];
  142741. webkitGamepads(): Gamepad[];
  142742. }
  142743. interface HTMLVideoElement {
  142744. mozSrcObject: any;
  142745. }
  142746. interface Math {
  142747. fround(x: number): number;
  142748. imul(a: number, b: number): number;
  142749. }
  142750. interface WebGLRenderingContext {
  142751. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142752. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142753. vertexAttribDivisor(index: number, divisor: number): void;
  142754. createVertexArray(): any;
  142755. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142756. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142757. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142758. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142759. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142760. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142761. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142762. // Queries
  142763. createQuery(): WebGLQuery;
  142764. deleteQuery(query: WebGLQuery): void;
  142765. beginQuery(target: number, query: WebGLQuery): void;
  142766. endQuery(target: number): void;
  142767. getQueryParameter(query: WebGLQuery, pname: number): any;
  142768. getQuery(target: number, pname: number): any;
  142769. MAX_SAMPLES: number;
  142770. RGBA8: number;
  142771. READ_FRAMEBUFFER: number;
  142772. DRAW_FRAMEBUFFER: number;
  142773. UNIFORM_BUFFER: number;
  142774. HALF_FLOAT_OES: number;
  142775. RGBA16F: number;
  142776. RGBA32F: number;
  142777. R32F: number;
  142778. RG32F: number;
  142779. RGB32F: number;
  142780. R16F: number;
  142781. RG16F: number;
  142782. RGB16F: number;
  142783. RED: number;
  142784. RG: number;
  142785. R8: number;
  142786. RG8: number;
  142787. UNSIGNED_INT_24_8: number;
  142788. DEPTH24_STENCIL8: number;
  142789. MIN: number;
  142790. MAX: number;
  142791. /* Multiple Render Targets */
  142792. drawBuffers(buffers: number[]): void;
  142793. readBuffer(src: number): void;
  142794. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142795. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142796. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142797. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142798. // Occlusion Query
  142799. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142800. ANY_SAMPLES_PASSED: number;
  142801. QUERY_RESULT_AVAILABLE: number;
  142802. QUERY_RESULT: number;
  142803. }
  142804. interface WebGLProgram {
  142805. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142806. }
  142807. interface EXT_disjoint_timer_query {
  142808. QUERY_COUNTER_BITS_EXT: number;
  142809. TIME_ELAPSED_EXT: number;
  142810. TIMESTAMP_EXT: number;
  142811. GPU_DISJOINT_EXT: number;
  142812. QUERY_RESULT_EXT: number;
  142813. QUERY_RESULT_AVAILABLE_EXT: number;
  142814. queryCounterEXT(query: WebGLQuery, target: number): void;
  142815. createQueryEXT(): WebGLQuery;
  142816. beginQueryEXT(target: number, query: WebGLQuery): void;
  142817. endQueryEXT(target: number): void;
  142818. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142819. deleteQueryEXT(query: WebGLQuery): void;
  142820. }
  142821. interface WebGLUniformLocation {
  142822. _currentState: any;
  142823. }
  142824. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142825. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142826. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142827. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142828. interface WebGLRenderingContext {
  142829. readonly RASTERIZER_DISCARD: number;
  142830. readonly DEPTH_COMPONENT24: number;
  142831. readonly TEXTURE_3D: number;
  142832. readonly TEXTURE_2D_ARRAY: number;
  142833. readonly TEXTURE_COMPARE_FUNC: number;
  142834. readonly TEXTURE_COMPARE_MODE: number;
  142835. readonly COMPARE_REF_TO_TEXTURE: number;
  142836. readonly TEXTURE_WRAP_R: number;
  142837. readonly HALF_FLOAT: number;
  142838. readonly RGB8: number;
  142839. readonly RED_INTEGER: number;
  142840. readonly RG_INTEGER: number;
  142841. readonly RGB_INTEGER: number;
  142842. readonly RGBA_INTEGER: number;
  142843. readonly R8_SNORM: number;
  142844. readonly RG8_SNORM: number;
  142845. readonly RGB8_SNORM: number;
  142846. readonly RGBA8_SNORM: number;
  142847. readonly R8I: number;
  142848. readonly RG8I: number;
  142849. readonly RGB8I: number;
  142850. readonly RGBA8I: number;
  142851. readonly R8UI: number;
  142852. readonly RG8UI: number;
  142853. readonly RGB8UI: number;
  142854. readonly RGBA8UI: number;
  142855. readonly R16I: number;
  142856. readonly RG16I: number;
  142857. readonly RGB16I: number;
  142858. readonly RGBA16I: number;
  142859. readonly R16UI: number;
  142860. readonly RG16UI: number;
  142861. readonly RGB16UI: number;
  142862. readonly RGBA16UI: number;
  142863. readonly R32I: number;
  142864. readonly RG32I: number;
  142865. readonly RGB32I: number;
  142866. readonly RGBA32I: number;
  142867. readonly R32UI: number;
  142868. readonly RG32UI: number;
  142869. readonly RGB32UI: number;
  142870. readonly RGBA32UI: number;
  142871. readonly RGB10_A2UI: number;
  142872. readonly R11F_G11F_B10F: number;
  142873. readonly RGB9_E5: number;
  142874. readonly RGB10_A2: number;
  142875. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142876. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142877. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142878. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142879. readonly DEPTH_COMPONENT32F: number;
  142880. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142881. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142882. 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;
  142883. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142884. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142885. readonly TRANSFORM_FEEDBACK: number;
  142886. readonly INTERLEAVED_ATTRIBS: number;
  142887. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142888. createTransformFeedback(): WebGLTransformFeedback;
  142889. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142890. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142891. beginTransformFeedback(primitiveMode: number): void;
  142892. endTransformFeedback(): void;
  142893. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142894. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142895. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142896. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142897. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142898. }
  142899. interface ImageBitmap {
  142900. readonly width: number;
  142901. readonly height: number;
  142902. close(): void;
  142903. }
  142904. interface WebGLQuery extends WebGLObject {
  142905. }
  142906. declare var WebGLQuery: {
  142907. prototype: WebGLQuery;
  142908. new(): WebGLQuery;
  142909. };
  142910. interface WebGLSampler extends WebGLObject {
  142911. }
  142912. declare var WebGLSampler: {
  142913. prototype: WebGLSampler;
  142914. new(): WebGLSampler;
  142915. };
  142916. interface WebGLSync extends WebGLObject {
  142917. }
  142918. declare var WebGLSync: {
  142919. prototype: WebGLSync;
  142920. new(): WebGLSync;
  142921. };
  142922. interface WebGLTransformFeedback extends WebGLObject {
  142923. }
  142924. declare var WebGLTransformFeedback: {
  142925. prototype: WebGLTransformFeedback;
  142926. new(): WebGLTransformFeedback;
  142927. };
  142928. interface WebGLVertexArrayObject extends WebGLObject {
  142929. }
  142930. declare var WebGLVertexArrayObject: {
  142931. prototype: WebGLVertexArrayObject;
  142932. new(): WebGLVertexArrayObject;
  142933. };
  142934. // Type definitions for WebVR API
  142935. // Project: https://w3c.github.io/webvr/
  142936. // Definitions by: six a <https://github.com/lostfictions>
  142937. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142938. interface VRDisplay extends EventTarget {
  142939. /**
  142940. * Dictionary of capabilities describing the VRDisplay.
  142941. */
  142942. readonly capabilities: VRDisplayCapabilities;
  142943. /**
  142944. * z-depth defining the far plane of the eye view frustum
  142945. * enables mapping of values in the render target depth
  142946. * attachment to scene coordinates. Initially set to 10000.0.
  142947. */
  142948. depthFar: number;
  142949. /**
  142950. * z-depth defining the near plane of the eye view frustum
  142951. * enables mapping of values in the render target depth
  142952. * attachment to scene coordinates. Initially set to 0.01.
  142953. */
  142954. depthNear: number;
  142955. /**
  142956. * An identifier for this distinct VRDisplay. Used as an
  142957. * association point in the Gamepad API.
  142958. */
  142959. readonly displayId: number;
  142960. /**
  142961. * A display name, a user-readable name identifying it.
  142962. */
  142963. readonly displayName: string;
  142964. readonly isConnected: boolean;
  142965. readonly isPresenting: boolean;
  142966. /**
  142967. * If this VRDisplay supports room-scale experiences, the optional
  142968. * stage attribute contains details on the room-scale parameters.
  142969. */
  142970. readonly stageParameters: VRStageParameters | null;
  142971. /**
  142972. * Passing the value returned by `requestAnimationFrame` to
  142973. * `cancelAnimationFrame` will unregister the callback.
  142974. * @param handle Define the hanle of the request to cancel
  142975. */
  142976. cancelAnimationFrame(handle: number): void;
  142977. /**
  142978. * Stops presenting to the VRDisplay.
  142979. * @returns a promise to know when it stopped
  142980. */
  142981. exitPresent(): Promise<void>;
  142982. /**
  142983. * Return the current VREyeParameters for the given eye.
  142984. * @param whichEye Define the eye we want the parameter for
  142985. * @returns the eye parameters
  142986. */
  142987. getEyeParameters(whichEye: string): VREyeParameters;
  142988. /**
  142989. * Populates the passed VRFrameData with the information required to render
  142990. * the current frame.
  142991. * @param frameData Define the data structure to populate
  142992. * @returns true if ok otherwise false
  142993. */
  142994. getFrameData(frameData: VRFrameData): boolean;
  142995. /**
  142996. * Get the layers currently being presented.
  142997. * @returns the list of VR layers
  142998. */
  142999. getLayers(): VRLayer[];
  143000. /**
  143001. * Return a VRPose containing the future predicted pose of the VRDisplay
  143002. * when the current frame will be presented. The value returned will not
  143003. * change until JavaScript has returned control to the browser.
  143004. *
  143005. * The VRPose will contain the position, orientation, velocity,
  143006. * and acceleration of each of these properties.
  143007. * @returns the pose object
  143008. */
  143009. getPose(): VRPose;
  143010. /**
  143011. * Return the current instantaneous pose of the VRDisplay, with no
  143012. * prediction applied.
  143013. * @returns the current instantaneous pose
  143014. */
  143015. getImmediatePose(): VRPose;
  143016. /**
  143017. * The callback passed to `requestAnimationFrame` will be called
  143018. * any time a new frame should be rendered. When the VRDisplay is
  143019. * presenting the callback will be called at the native refresh
  143020. * rate of the HMD. When not presenting this function acts
  143021. * identically to how window.requestAnimationFrame acts. Content should
  143022. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143023. * asynchronously from other displays and at differing refresh rates.
  143024. * @param callback Define the eaction to run next frame
  143025. * @returns the request handle it
  143026. */
  143027. requestAnimationFrame(callback: FrameRequestCallback): number;
  143028. /**
  143029. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143030. * Repeat calls while already presenting will update the VRLayers being displayed.
  143031. * @param layers Define the list of layer to present
  143032. * @returns a promise to know when the request has been fulfilled
  143033. */
  143034. requestPresent(layers: VRLayer[]): Promise<void>;
  143035. /**
  143036. * Reset the pose for this display, treating its current position and
  143037. * orientation as the "origin/zero" values. VRPose.position,
  143038. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143039. * updated when calling resetPose(). This should be called in only
  143040. * sitting-space experiences.
  143041. */
  143042. resetPose(): void;
  143043. /**
  143044. * The VRLayer provided to the VRDisplay will be captured and presented
  143045. * in the HMD. Calling this function has the same effect on the source
  143046. * canvas as any other operation that uses its source image, and canvases
  143047. * created without preserveDrawingBuffer set to true will be cleared.
  143048. * @param pose Define the pose to submit
  143049. */
  143050. submitFrame(pose?: VRPose): void;
  143051. }
  143052. declare var VRDisplay: {
  143053. prototype: VRDisplay;
  143054. new(): VRDisplay;
  143055. };
  143056. interface VRLayer {
  143057. leftBounds?: number[] | Float32Array | null;
  143058. rightBounds?: number[] | Float32Array | null;
  143059. source?: HTMLCanvasElement | null;
  143060. }
  143061. interface VRDisplayCapabilities {
  143062. readonly canPresent: boolean;
  143063. readonly hasExternalDisplay: boolean;
  143064. readonly hasOrientation: boolean;
  143065. readonly hasPosition: boolean;
  143066. readonly maxLayers: number;
  143067. }
  143068. interface VREyeParameters {
  143069. /** @deprecated */
  143070. readonly fieldOfView: VRFieldOfView;
  143071. readonly offset: Float32Array;
  143072. readonly renderHeight: number;
  143073. readonly renderWidth: number;
  143074. }
  143075. interface VRFieldOfView {
  143076. readonly downDegrees: number;
  143077. readonly leftDegrees: number;
  143078. readonly rightDegrees: number;
  143079. readonly upDegrees: number;
  143080. }
  143081. interface VRFrameData {
  143082. readonly leftProjectionMatrix: Float32Array;
  143083. readonly leftViewMatrix: Float32Array;
  143084. readonly pose: VRPose;
  143085. readonly rightProjectionMatrix: Float32Array;
  143086. readonly rightViewMatrix: Float32Array;
  143087. readonly timestamp: number;
  143088. }
  143089. interface VRPose {
  143090. readonly angularAcceleration: Float32Array | null;
  143091. readonly angularVelocity: Float32Array | null;
  143092. readonly linearAcceleration: Float32Array | null;
  143093. readonly linearVelocity: Float32Array | null;
  143094. readonly orientation: Float32Array | null;
  143095. readonly position: Float32Array | null;
  143096. readonly timestamp: number;
  143097. }
  143098. interface VRStageParameters {
  143099. sittingToStandingTransform?: Float32Array;
  143100. sizeX?: number;
  143101. sizeY?: number;
  143102. }
  143103. interface Navigator {
  143104. getVRDisplays(): Promise<VRDisplay[]>;
  143105. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143106. }
  143107. interface Window {
  143108. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143109. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143110. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143111. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143112. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143113. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143114. }
  143115. interface Gamepad {
  143116. readonly displayId: number;
  143117. }
  143118. type XRSessionMode =
  143119. | "inline"
  143120. | "immersive-vr"
  143121. | "immersive-ar";
  143122. type XRReferenceSpaceType =
  143123. | "viewer"
  143124. | "local"
  143125. | "local-floor"
  143126. | "bounded-floor"
  143127. | "unbounded";
  143128. type XREnvironmentBlendMode =
  143129. | "opaque"
  143130. | "additive"
  143131. | "alpha-blend";
  143132. type XRVisibilityState =
  143133. | "visible"
  143134. | "visible-blurred"
  143135. | "hidden";
  143136. type XRHandedness =
  143137. | "none"
  143138. | "left"
  143139. | "right";
  143140. type XRTargetRayMode =
  143141. | "gaze"
  143142. | "tracked-pointer"
  143143. | "screen";
  143144. type XREye =
  143145. | "none"
  143146. | "left"
  143147. | "right";
  143148. interface XRSpace extends EventTarget {
  143149. }
  143150. interface XRRenderState {
  143151. depthNear?: number;
  143152. depthFar?: number;
  143153. inlineVerticalFieldOfView?: number;
  143154. baseLayer?: XRWebGLLayer;
  143155. }
  143156. interface XRInputSource {
  143157. handedness: XRHandedness;
  143158. targetRayMode: XRTargetRayMode;
  143159. targetRaySpace: XRSpace;
  143160. gripSpace: XRSpace | undefined;
  143161. gamepad: Gamepad | undefined;
  143162. profiles: Array<string>;
  143163. }
  143164. interface XRSessionInit {
  143165. optionalFeatures?: XRReferenceSpaceType[];
  143166. requiredFeatures?: XRReferenceSpaceType[];
  143167. }
  143168. interface XRSession extends XRAnchorCreator {
  143169. addEventListener: Function;
  143170. removeEventListener: Function;
  143171. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143172. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143173. requestAnimationFrame: Function;
  143174. end(): Promise<void>;
  143175. renderState: XRRenderState;
  143176. inputSources: Array<XRInputSource>;
  143177. // AR hit test
  143178. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143179. updateWorldTrackingState(options: {
  143180. planeDetectionState?: { enabled: boolean; }
  143181. }): void;
  143182. }
  143183. interface XRReferenceSpace extends XRSpace {
  143184. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143185. onreset: any;
  143186. }
  143187. type XRPlaneSet = Set<XRPlane>;
  143188. type XRAnchorSet = Set<XRAnchor>;
  143189. interface XRFrame {
  143190. session: XRSession;
  143191. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143192. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143193. // Anchors
  143194. trackedAnchors?: XRAnchorSet;
  143195. // Planes
  143196. worldInformation: {
  143197. detectedPlanes?: XRPlaneSet;
  143198. };
  143199. }
  143200. interface XRViewerPose extends XRPose {
  143201. views: Array<XRView>;
  143202. }
  143203. interface XRPose {
  143204. transform: XRRigidTransform;
  143205. emulatedPosition: boolean;
  143206. }
  143207. interface XRWebGLLayerOptions {
  143208. antialias?: boolean;
  143209. depth?: boolean;
  143210. stencil?: boolean;
  143211. alpha?: boolean;
  143212. multiview?: boolean;
  143213. framebufferScaleFactor?: number;
  143214. }
  143215. declare var XRWebGLLayer: {
  143216. prototype: XRWebGLLayer;
  143217. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143218. };
  143219. interface XRWebGLLayer {
  143220. framebuffer: WebGLFramebuffer;
  143221. framebufferWidth: number;
  143222. framebufferHeight: number;
  143223. getViewport: Function;
  143224. }
  143225. declare class XRRigidTransform {
  143226. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143227. position: DOMPointReadOnly;
  143228. orientation: DOMPointReadOnly;
  143229. matrix: Float32Array;
  143230. inverse: XRRigidTransform;
  143231. }
  143232. interface XRView {
  143233. eye: XREye;
  143234. projectionMatrix: Float32Array;
  143235. transform: XRRigidTransform;
  143236. }
  143237. interface XRInputSourceChangeEvent {
  143238. session: XRSession;
  143239. removed: Array<XRInputSource>;
  143240. added: Array<XRInputSource>;
  143241. }
  143242. interface XRInputSourceEvent extends Event {
  143243. readonly frame: XRFrame;
  143244. readonly inputSource: XRInputSource;
  143245. }
  143246. // Experimental(er) features
  143247. declare class XRRay {
  143248. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143249. origin: DOMPointReadOnly;
  143250. direction: DOMPointReadOnly;
  143251. matrix: Float32Array;
  143252. }
  143253. interface XRHitResult {
  143254. hitMatrix: Float32Array;
  143255. }
  143256. interface XRAnchor {
  143257. // remove?
  143258. id?: string;
  143259. anchorSpace: XRSpace;
  143260. lastChangedTime: number;
  143261. detach(): void;
  143262. }
  143263. interface XRPlane extends XRAnchorCreator {
  143264. orientation: "Horizontal" | "Vertical";
  143265. planeSpace: XRSpace;
  143266. polygon: Array<DOMPointReadOnly>;
  143267. lastChangedTime: number;
  143268. }
  143269. interface XRAnchorCreator {
  143270. // AR Anchors
  143271. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143272. }